updated plugin Companion Auto Update version 3.8.0

This commit is contained in:
2021-01-17 21:29:01 +00:00
committed by Gitium
parent 8a03c72181
commit 93745b9ce4
7 changed files with 264 additions and 224 deletions

View File

@ -70,11 +70,12 @@ if( isset( $_POST['submit'] ) ) {
// Intervals
// Set variables
$plugin_sc = sanitize_text_field( $_POST['plugin_schedule'] );
$theme_sc = sanitize_text_field( $_POST['theme_schedule'] );
$core_sc = sanitize_text_field( $_POST['core_schedule'] );
$schedule_mail = sanitize_text_field( $_POST['schedule_mail'] );
$html_or_text = sanitize_text_field( $_POST['html_or_text'] );
$plugin_sc = sanitize_text_field( $_POST['plugin_schedule'] );
$theme_sc = sanitize_text_field( $_POST['theme_schedule'] );
$core_sc = sanitize_text_field( $_POST['core_schedule'] );
$schedule_mail = sanitize_text_field( $_POST['update_notifications'] );
$outdated_notifier = sanitize_text_field( $_POST['outdated_notifier'] );
$html_or_text = sanitize_text_field( $_POST['html_or_text'] );
// First clear schedules
wp_clear_scheduled_hook('wp_update_plugins');
@ -84,6 +85,7 @@ if( isset( $_POST['submit'] ) ) {
wp_clear_scheduled_hook('cau_custom_hooks_plugins');
wp_clear_scheduled_hook('cau_custom_hooks_themes');
wp_clear_scheduled_hook('cau_log_updater');
wp_clear_scheduled_hook('cau_outdated_notifier');
// Then set the new times
@ -91,8 +93,8 @@ if( isset( $_POST['submit'] ) ) {
if( $plugin_sc == 'daily' ) {
$date = date( 'Y-m-d' );
$hours = sanitize_text_field( $_POST['pluginScheduleTimeH'] );
$minutes = sanitize_text_field( $_POST['pluginScheduleTimeM'] );
$hours = sanitize_text_field( $_POST['plugin_schedule-sethour'] );
$minutes = sanitize_text_field( $_POST['plugin_schedule-setminutes'] );
$seconds = date( 's' );
$fullDate = $date.' '.$hours.':'.$minutes.':'.$seconds;
$pluginSetTime = strtotime( $fullDate );
@ -113,8 +115,8 @@ if( isset( $_POST['submit'] ) ) {
if( $theme_sc == 'daily' ) {
$dateT = date( 'Y-m-d' );
$hoursT = sanitize_text_field( $_POST['ThemeScheduleTimeH'] );
$minutesT = sanitize_text_field( $_POST['ThemeScheduleTimeM'] );
$hoursT = sanitize_text_field( $_POST['theme_schedule-sethour'] );
$minutesT = sanitize_text_field( $_POST['theme_schedule-setminutes'] );
$secondsT = date( 's' );
$fullDateT = $dateT.' '.$hoursT.':'.$minutesT.':'.$secondsT;
$themeSetTime = strtotime( $fullDateT );
@ -133,8 +135,8 @@ if( isset( $_POST['submit'] ) ) {
if( $core_sc == 'daily' ) {
$dateC = date( 'Y-m-d' );
$hoursC = sanitize_text_field( $_POST['CoreScheduleTimeH'] );
$minutesC = sanitize_text_field( $_POST['CoreScheduleTimeM'] );
$hoursC = sanitize_text_field( $_POST['core_schedule-sethour'] );
$minutesC = sanitize_text_field( $_POST['core_schedule-setminutes'] );
$secondsC = date( 's' );
$fullDateC = $dateC.' '.$hoursC.':'.$minutesC.':'.$secondsC;
$coreSetTime = strtotime( $fullDateC );
@ -147,12 +149,12 @@ if( isset( $_POST['submit'] ) ) {
}
// Emails
// Update notifications
if( $schedule_mail == 'daily' ) {
$dateT = date( 'Y-m-d' );
$hoursT = sanitize_text_field( $_POST['timeScheduleEmailTimeH'] );
$minutesT = sanitize_text_field( $_POST['timeScheduleEmailTimeM'] );
$hoursT = sanitize_text_field( $_POST['update_notifications-sethour'] );
$minutesT = sanitize_text_field( $_POST['update_notifications-setminutes'] );
$secondsT = date( 's' );
$fullDateT = $dateT.' '.$hoursT.':'.$minutesT.':'.$secondsT;
$emailSetTime = strtotime( $fullDateT );
@ -165,6 +167,25 @@ if( isset( $_POST['submit'] ) ) {
}
// Outdated notifications
if( $outdated_notifier == 'daily' ) {
$dateT = date( 'Y-m-d' );
$hoursT = sanitize_text_field( $_POST['outdated_notifier-sethour'] );
$minutesT = sanitize_text_field( $_POST['outdated_notifier-setminutes'] );
$secondsT = date( 's' );
$fullDateT = $dateT.' '.$hoursT.':'.$minutesT.':'.$secondsT;
$emailSetTime = strtotime( $fullDateT );
wp_schedule_event( $emailSetTime, $outdated_notifier, 'cau_outdated_notifier' );
} else {
wp_schedule_event( time(), $outdated_notifier, 'cau_outdated_notifier' );
}
echo '<div id="message" class="updated"><p><b>'.__( 'Settings saved.' ).'</b></p></div>';
}
@ -191,6 +212,7 @@ $plugin_schedule = wp_get_schedule( 'wp_update_plugins' );
$theme_schedule = wp_get_schedule( 'wp_update_themes' );
$core_schedule = wp_get_schedule( 'wp_version_check' );
$schedule_mail = wp_get_schedule( 'cau_set_schedule_mail' );
$outdated_notifier = wp_get_schedule( 'cau_outdated_notifier' );
$cs_hooks_p = wp_get_schedule( 'cau_custom_hooks_plugins' );
$cs_hooks_t = wp_get_schedule( 'cau_custom_hooks_themes' );
$availableIntervals = cau_wp_get_schedules();
@ -252,21 +274,16 @@ $availableIntervals = cau_wp_get_schedules();
<table class="form-table">
<tr>
<th scope="row"><?php _e( 'Update available', 'companion-auto-update' );?></th>
<td>
<p>
<input id="cau_send" name="cau_send" type="checkbox" <?php if( cau_get_db_value( 'send' ) == 'on' ) { echo 'checked'; } ?> />
<label for="cau_send"><?php _e('Send me emails when an update is available.', 'companion-auto-update');?></label>
</p>
</td>
</tr>
<tr>
<th scope="row"><?php _e( 'Successful update', 'companion-auto-update' );?></th>
<th scope="row"><?php _e( 'Update notifications', 'companion-auto-update' );?></th>
<td>
<p>
<input id="cau_send_update" name="cau_send_update" type="checkbox" <?php if( cau_get_db_value( 'sendupdate' ) == 'on' ) { echo 'checked'; } ?> />
<label for="cau_send_update"><?php _e( 'Send me emails when something has been updated.', 'companion-auto-update' );?></label>
</p>
<p>
<input id="cau_send" name="cau_send" type="checkbox" <?php if( cau_get_db_value( 'send' ) == 'on' ) { echo 'checked'; } ?> />
<label for="cau_send"><?php _e('Send me emails when an update is available.', 'companion-auto-update');?></label>
</p>
</td>
</tr>
<tr>
@ -274,12 +291,12 @@ $availableIntervals = cau_wp_get_schedules();
<td>
<p>
<input id="cau_send_outdated" name="cau_send_outdated" type="checkbox" <?php if( cau_get_db_value( 'sendoutdated' ) == 'on' ) { echo 'checked'; } ?> />
<label for="cau_send_outdated"><?php _e( 'Be notified of plugins that have not been tested with your current version of WordPress.', 'companion-auto-update' );?></label>
<label for="cau_send_outdated"><?php _e( 'Be notified of plugins that have not been tested with the 3 latest major versions of WordPress.', 'companion-auto-update' );?></label>
</p>
</td>
</tr>
<tr>
<th scope="row"><?php _e( 'Email Address' );?></th>
<th scope="row"><?php _e( 'Email Address', 'companion-auto-update' );?></th>
<td>
<p>
<label for="cau_email"><?php _e( 'To', 'companion-auto-update' ); ?>:</label>
@ -330,142 +347,83 @@ $availableIntervals = cau_wp_get_schedules();
<div class="welcome-to-cau interval-bg welcome-panel cau-dashboard-box" style="overflow: hidden;">
<h2 class="title"><?php _e('Intervals', 'companion-auto-update');?></h2>
<div class="welcome-column welcome-column-quarter">
<h2 class="title"><?php _e( 'Intervals', 'companion-auto-update' );?></h2>
<?php
function cau_show_interval_selection( $identiefier, $schedule ) {
// Get the info
$setValue = wp_get_schedule( $schedule );
$setTime = wp_next_scheduled( $schedule );
$setHour = date( 'H' , $setTime );
$setMinutes = date( 'i' , $setTime );
// Show interval selection
echo "<p>";
echo "<select name='$identiefier' id='$identiefier' class='schedule_interval wide interval_scheduler' data-timeblock='$identiefier'>";
foreach ( cau_wp_get_schedules() as $key => $value ) {
echo "<option "; if( $setValue == $key ) { echo "selected "; } echo "value='".$key."'>".$value."</option>";
}
echo "</select>";
echo "</p>";
// Set the time when daily is selected
echo "<div class='timeblock-$identiefier' style='display: none;'>";
echo "<div class='cau_schedule_input'>
<input type='number' min='0' max='23' name='".$identiefier."-sethour' value='$setHour' maxlength='2' >
</div><div class='cau_schedule_input_div'>
:
</div><div class='cau_schedule_input'>
<input type='number' min='0' max='59' name='".$identiefier."-setminutes' value='$setMinutes' maxlength='2' >
</div><div class='cau_shedule_notation'>
<span class='cau_tooltip'><span class='dashicons dashicons-editor-help'></span>
<span class='cau_tooltip_text'>".__( 'At what time should the updater run? Only works when set to <u>daily</u>.', 'companion-auto-update' )." - ".__( 'Time notation: 24H', 'companion-auto-update' )."</span>
</span>
</div>";
echo "</div>";
}
?>
<div class="welcome-column">
<h4><?php _e( 'Plugin update interval', 'companion-auto-update' );?></h4>
<p>
<select name='plugin_schedule' id='plugin_schedule' class='schedule_interval wide'>
<?php foreach ( $availableIntervals as $key => $value ) {
echo "<option "; if( $plugin_schedule == $key ) { echo "selected "; } echo "value='".$key."'>".$value."</option>";
} ?>
</select>
</p>
<div class='timeSchedulePlugins' <?php if( $plugin_schedule != 'daily' ) { echo "style='display: none;'"; } ?> >
<?php
$setTimePlugins = wp_next_scheduled( 'wp_update_plugins' );
$setTimePluginsHour = date( 'H' , $setTimePlugins );
$setTimePluginsMin = date( 'i' , $setTimePlugins );
?>
<div class='cau_schedule_input'>
<input type='number' min='0' max='23' name='pluginScheduleTimeH' value='<?php echo $setTimePluginsHour; ?>' maxlength='2' >
</div><div class='cau_schedule_input_div'>
:
</div><div class='cau_schedule_input'>
<input type='number' min='0' max='59' name='pluginScheduleTimeM' value='<?php echo $setTimePluginsMin; ?>' maxlength='2' >
</div><div class='cau_shedule_notation'>
<span class='cau_tooltip'><span class="dashicons dashicons-editor-help"></span>
<span class='cau_tooltip_text'><?php _e('At what time should the updater run? Only works when set to <u>daily</u>.', 'companion-auto-update'); ?> - <?php _e( 'Time notation: 24H', 'companion-auto-update'); ?></span>
</span>
</div>
</div>
</div><div class="welcome-column welcome-column-quarter">
<h4><?php _e( 'Theme update interval', 'companion-auto-update' );?></h4>
<p>
<select name='theme_schedule' id='theme_schedule' class='schedule_interval wide'>
<?php foreach ( $availableIntervals as $key => $value ) {
echo "<option "; if( $theme_schedule == $key ) { echo "selected "; } echo "value='".$key."'>".$value."</option>";
} ?>
</select>
</p>
<div class='timeScheduleThemes' <?php if( $theme_schedule != 'daily' ) { echo "style='display: none;'"; } ?> >
<?php
$setTimeThemes = wp_next_scheduled( 'wp_update_themes' );
$setTimeThemesHour = date( 'H' , $setTimeThemes );
$setTimeThemesMins = date( 'i' , $setTimeThemes );
?>
<div class='cau_schedule_input'>
<input type='number' min='0' max='23' name='ThemeScheduleTimeH' value='<?php echo $setTimeThemesHour; ?>' maxlength='2' >
</div><div class='cau_schedule_input_div'>
:
</div><div class='cau_schedule_input'>
<input type='number' min='0' max='59' name='ThemeScheduleTimeM' value='<?php echo $setTimeThemesMins; ?>' maxlength='2' >
</div><div class='cau_shedule_notation'>
<span class='cau_tooltip'><span class="dashicons dashicons-editor-help"></span>
<span class='cau_tooltip_text'><?php _e('At what time should the updater run? Only works when set to <u>daily</u>.', 'companion-auto-update'); ?> - <?php _e( 'Time notation: 24H', 'companion-auto-update'); ?></span>
</span>
</div>
</div>
</div><div class="welcome-column welcome-column-quarter">
<h4><?php _e( 'Core update interval', 'companion-auto-update' );?></h4>
<p>
<select name='core_schedule' id='core_schedule' class='schedule_interval wide'>
<?php foreach ( $availableIntervals as $key => $value ) {
echo "<option "; if( $core_schedule == $key ) { echo "selected "; } echo "value='".$key."'>".$value."</option>";
} ?>
</select>
</p>
<div class='timeScheduleCore' <?php if( $core_schedule != 'daily' ) { echo "style='display: none;'"; } ?> >
<?php
$setTimeCore = wp_next_scheduled( 'wp_version_check' );
$setTimeCoreHour = date( 'H' , $setTimeCore );
$setTimeCoreMins = date( 'i' , $setTimeCore );
?>
<div class='cau_schedule_input'>
<input type='number' min='0' max='23' name='CoreScheduleTimeH' value='<?php echo $setTimeCoreHour; ?>' maxlength='2' >
</div><div class='cau_schedule_input_div'>
:
</div><div class='cau_schedule_input'>
<input type='number' min='0' max='59' name='CoreScheduleTimeM' value='<?php echo $setTimeCoreMins; ?>' maxlength='2' >
</div><div class='cau_shedule_notation'>
<span class='cau_tooltip'><span class="dashicons dashicons-editor-help"></span>
<span class='cau_tooltip_text'><?php _e('At what time should the updater run? Only works when set to <u>daily</u>.', 'companion-auto-update'); ?> - <?php _e( 'Time notation: 24H', 'companion-auto-update'); ?></span>
</span>
</div>
</div>
</div><div class="welcome-column welcome-column-quarter">
<h4><?php _e( 'Email Notifications', 'companion-auto-update' );?></h4>
<p>
<select id='schedule_mail' name='schedule_mail' class='schedule_interval wide'>
<?php foreach ( $availableIntervals as $key => $value ) {
echo "<option "; if( $schedule_mail == $key ) { echo "selected "; } echo "value='".$key."'>".$value."</option>";
} ?>
</select>
</p>
<div class='timeScheduleEmail' <?php if( $schedule_mail != 'daily' ) { echo "style='display: none;'"; } ?> >
<?php
$setTimeEmails = wp_next_scheduled( 'cau_set_schedule_mail' );
$setTimeEmailHour = date( 'H' , $setTimeEmails );
$setTimeEmailMins = date( 'i' , $setTimeEmails );
?>
<div class='cau_schedule_input'>
<input type='number' min='0' max='23' name='timeScheduleEmailTimeH' value='<?php echo $setTimeEmailHour; ?>' maxlength='2' >
</div><div class='cau_schedule_input_div'>
:
</div><div class='cau_schedule_input'>
<input type='number' min='0' max='59' name='timeScheduleEmailTimeM' value='<?php echo $setTimeEmailMins; ?>' maxlength='2' >
</div><div class='cau_shedule_notation'>
<span class='cau_tooltip'><span class="dashicons dashicons-editor-help"></span>
<span class='cau_tooltip_text'><?php _e( 'Time notation: 24H', 'companion-auto-update'); ?></span>
</span>
</div>
</div>
<?php cau_show_interval_selection( 'plugin_schedule', 'wp_update_plugins' ); ?>
</div>
<div class="welcome-column">
<h4><?php _e( 'Theme update interval', 'companion-auto-update' );?></h4>
<?php cau_show_interval_selection( 'theme_schedule', 'wp_update_themes' ); ?>
</div>
<div class="welcome-column">
<h4><?php _e( 'Core update interval', 'companion-auto-update' );?></h4>
<?php cau_show_interval_selection( 'core_schedule', 'wp_version_check' ); ?>
</div>
<div class="welcome-column">
<h4><?php _e( 'Update notifications', 'companion-auto-update' );?></h4>
<?php cau_show_interval_selection( 'update_notifications', 'cau_set_schedule_mail' ); ?>
</div>
<div class="welcome-column">
<h4><?php _e( 'Outdated software', 'companion-auto-update' );?></h4>
<?php cau_show_interval_selection( 'outdated_notifier', 'cau_outdated_notifier' ); ?>
</div>
</div>
<div class="welcome-to-cau advanced-bg welcome-panel cau-dashboard-box">
@ -477,15 +435,15 @@ $availableIntervals = cau_wp_get_schedules();
<tr>
<th scope="row"><label><?php _e( 'Allow access to:', 'companion-auto-update' ); ?></label></th>
<td>
<p><label for="allow_administrator"><input name="allow_administrator" type="checkbox" id="allow_administrator" disabled="" checked=""><?php _e( 'Administrator' ); ?></label></p>
<p><label for="allow_editor"><input name="allow_editor" type="checkbox" id="allow_editor" <?php if( cau_get_db_value( 'allow_editor' ) == 'on' ) { echo "CHECKED"; } ?>><?php _e( 'Editor' ); ?></label></p>
<p><label for="allow_author"><input name="allow_author" type="checkbox" id="allow_author" <?php if( cau_get_db_value( 'allow_author' ) == 'on' ) { echo "CHECKED"; } ?>><?php _e( 'Author' ); ?></label></p>
<p><label for="allow_administrator"><input name="allow_administrator" type="checkbox" id="allow_administrator" disabled="" checked=""><?php _e( 'Administrator', 'companion-auto-update' ); ?></label></p>
<p><label for="allow_editor"><input name="allow_editor" type="checkbox" id="allow_editor" <?php if( cau_get_db_value( 'allow_editor' ) == 'on' ) { echo "CHECKED"; } ?>><?php _e( 'Editor', 'companion-auto-update' ); ?></label></p>
<p><label for="allow_author"><input name="allow_author" type="checkbox" id="allow_author" <?php if( cau_get_db_value( 'allow_author' ) == 'on' ) { echo "CHECKED"; } ?>><?php _e( 'Author', 'companion-auto-update' ); ?></label></p>
</td>
</tr>
<tr>
<th scope="row"><label><?php _e( 'Delay updates', 'companion-auto-update' ); ?></label></th>
<td>
<p><label for="update_delay"><input name="update_delay" type="checkbox" id="update_delay" <?php if( cau_get_db_value( 'update_delay' ) == 'on' ) { echo "CHECKED"; } ?>><?php _e( 'Delay updates' ); ?></label></p>
<p><label for="update_delay"><input name="update_delay" type="checkbox" id="update_delay" <?php if( cau_get_db_value( 'update_delay' ) == 'on' ) { echo "CHECKED"; } ?>><?php _e( 'Delay updates', 'companion-auto-update' ); ?></label></p>
</td>
</tr>
<tr id='update_delay_days_block' <?php if( cau_get_db_value( 'update_delay' ) != 'on' ) { echo "class='disabled_option'"; } ?>>
@ -548,7 +506,14 @@ $availableIntervals = cau_wp_get_schedules();
<a href="<?php echo cau_donateUrl(); ?>" target="_blank" class="button button-primary button-hero">
<?php _e('Donate to help development', 'companion-auto-update'); ?>
</a>
<p style="font-size: 12px; color: #BDBDBD;">Donations via PayPal. Amount can be changed.</p>
<p style="font-size: 12px; color: #BDBDBD;"><?php _e( 'Donations via PayPal. Amount can be changed.', 'companion-auto-update'); ?></p>
</div>
<div class="welcome-to-cau welcome-panel cau-dashboard-box">
<h3><span style='background: #EBE3F7; color: #BCADD3; padding: 1px 5px; border-radius: 3px; font-size: .8em'>Plugin Promotion</span></h3>
<h3>Keep your site fast with our Revision Manager</h3>
<p>Post Revisions are great, but will also slow down your site. Take back control over revisions with Companion Revision Manager!</p>
<a href="https://codeermeneer.nl/portfolio/plugin/companion-revision-manager/" target="_blank" class="button button-alt">Read more</a>
</div>
</div>
@ -565,50 +530,28 @@ $availableIntervals = cau_wp_get_schedules();
jQuery( '#update_delay_days_block' ).toggleClass( 'disabled_option' );
});
jQuery( '#plugin_schedule' ).change( function() {
jQuery( '.interval_scheduler' ).change( function() {
var selected = jQuery(this).val();
var selected = jQuery(this).val(); // Selected value
var timeblock = jQuery(this).data( 'timeblock' ); // Corresponding time block
if( selected == 'daily' ) {
jQuery('.timeSchedulePlugins').show();
jQuery( '.timeblock-'+timeblock ).show();
} else {
jQuery('.timeSchedulePlugins').hide();
jQuery( '.timeblock-'+timeblock ).hide();
}
});
jQuery( '#theme_schedule' ).change( function() {
jQuery( '.interval_scheduler' ).each( function() {
var selected = jQuery(this).val();
var selected = jQuery(this).val(); // Selected value
var timeblock = jQuery(this).data( 'timeblock' ); // Corresponding time block
if( selected == 'daily' ) {
jQuery('.timeScheduleThemes').show();
jQuery( '.timeblock-'+timeblock ).show();
} else {
jQuery('.timeScheduleThemes').hide();
}
});
jQuery( '#core_schedule' ).change( function() {
var selected = jQuery(this).val();
if( selected == 'daily' ) {
jQuery('.timeScheduleCore').show();
} else {
jQuery('.timeScheduleCore').hide();
}
});
jQuery( '#schedule_mail' ).change( function() {
var selected = jQuery(this).val();
if( selected == 'daily' ) {
jQuery('.timeScheduleEmail').show();
} else {
jQuery('.timeScheduleEmail').hide();
jQuery( '.timeblock-'+timeblock ).hide();
}
});