Plugin Updates
This commit is contained in:
@@ -1,26 +1,39 @@
|
||||
/**
|
||||
* Functionality related to Crontrol.
|
||||
* Functionality related to WP Crontrol.
|
||||
*/
|
||||
|
||||
jQuery(function($){
|
||||
$('#crontrol_next_run_date_local_custom_date,#crontrol_next_run_date_local_custom_time').on('change', function() {
|
||||
$('#crontrol_next_run_date_local_custom').prop('checked',true);
|
||||
});
|
||||
document.addEventListener( 'DOMContentLoaded', () => {
|
||||
const checkCustom = () => {
|
||||
document.getElementById( 'crontrol_next_run_date_local_custom' ).checked = true;
|
||||
};
|
||||
|
||||
if ( $('input[value="new_php_cron"]').length ) {
|
||||
$('input[value="new_cron"]').on('click',function(){
|
||||
$('.crontrol-edit-event').removeClass('crontrol-edit-event-php').addClass('crontrol-edit-event-standard');
|
||||
$('#crontrol_hookname').attr('required',true);
|
||||
});
|
||||
$('input[value="new_php_cron"]').on('click',function(){
|
||||
$('.crontrol-edit-event').removeClass('crontrol-edit-event-standard').addClass('crontrol-edit-event-php');
|
||||
$('#crontrol_hookname').attr('required',false);
|
||||
if ( ! $('#crontrol_hookcode').hasClass('crontrol-editor-initialized') ) {
|
||||
const customDateElement = document.getElementById( 'crontrol_next_run_date_local_custom_date' );
|
||||
const customTimeElement = document.getElementById( 'crontrol_next_run_date_local_custom_time' );
|
||||
const newCronElement = document.querySelector( 'input[value="new_cron"]' );
|
||||
const newPHPCronElement = document.querySelector( 'input[value="new_php_cron"]' );
|
||||
const hookCodeElement = document.getElementById( 'crontrol_hookcode' );
|
||||
const hookNameElement = document.getElementById( 'crontrol_hookname' );
|
||||
const editEventElement = document.querySelector( '.crontrol-edit-event' );
|
||||
|
||||
customDateElement && customDateElement.addEventListener( 'change', checkCustom );
|
||||
customTimeElement && customTimeElement.addEventListener( 'change', checkCustom );
|
||||
|
||||
if ( newPHPCronElement ) {
|
||||
newCronElement.addEventListener( 'click', () => {
|
||||
editEventElement.classList.remove( 'crontrol-edit-event-php' );
|
||||
editEventElement.classList.add( 'crontrol-edit-event-standard' );
|
||||
hookNameElement.setAttribute( 'required', true );
|
||||
} );
|
||||
newPHPCronElement.addEventListener( 'click', () => {
|
||||
editEventElement.classList.remove( 'crontrol-edit-event-standard' );
|
||||
editEventElement.classList.add( 'crontrol-edit-event-php' );
|
||||
hookNameElement.removeAttribute( 'required' );
|
||||
if ( ! hookCodeElement.classList.contains( 'crontrol-editor-initialized' ) ) {
|
||||
wp.codeEditor.initialize( 'crontrol_hookcode', window.wpCrontrol.codeEditor );
|
||||
}
|
||||
$('#crontrol_hookcode').addClass('crontrol-editor-initialized');
|
||||
});
|
||||
} else if ( $('#crontrol_hookcode').length ) {
|
||||
hookCodeElement.classList.add( 'crontrol-editor-initialized' );
|
||||
} );
|
||||
} else if ( hookCodeElement ) {
|
||||
wp.codeEditor.initialize( 'crontrol_hookcode', window.wpCrontrol.codeEditor );
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
Reference in New Issue
Block a user