/** * Metabox to show the backup scheduling options * * @since 1.0.2 * * @param string $title - Title to be displayed in header of metabox * @param array $item - The current viewed item * * @return none */ function snapshot_metabox_show_schedule_options($title, $item) { ?> <div class="postbox"> <h3 class="hndle"><span><?php echo $title; ?> </span></h3> <div class="inside"> <table class="form-table snapshot-backup-interval"> <tr class="form-field"> <td colspan="2"> <?php if (isset($_GET['page']) && sanitize_text_field($_GET['page']) == "snapshots_new_panel") { ?> <p><?php _e("Select a backup interval from the options below. If you select 'Immediate' the backup will start immediately and will only occur once. If you select any other value the initial backup will start within a few minutes then repeat on the selected interval.", SNAPSHOT_I18N_DOMAIN); ?> </p><?php } else { ?> <p><?php _e("You can change the interval when a backup occurs by selecting from the options below. If you select 'Suspend' the recurring backups will be stopped. If you select to schedule a backup or change the interval, the initial backup will start within a few minutes then repeat on the selected interval", SNAPSHOT_I18N_DOMAIN); ?> </p><?php } if (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON == true) { ?> <p style="color: #FF0000"><?php _e('Your site has disabled the WordPress Cron scheduler (WP_CRON). When scheduling an archive to be created it may not run. Check your wp-config.php for the DISABLE_WP_CRON define. If found either remove it or set the value to "false".', SNAPSHOT_I18N_DOMAIN); ?> </p><?php } ?> </td> </tr> <tr class="form-field"> <th> <label for="snapshot-interval"><?php _e('Backup Interval', SNAPSHOT_I18N_DOMAIN); ?> </label> </th> <td> <?php if (isset($_GET['show_cron_schedules'])) { $scheds = (array) wp_get_schedules(); echo "scheds<pre>"; print_r($scheds); echo "</pre>"; global $wp_filter; if (isset($wp_filter['cron_schedules'])) { echo "cron_schedules<pre>"; print_r($wp_filter['cron_schedules']); echo "</pre>"; } else { echo "no cron_schedules filters<br />"; } } ?> <?php if (isset($item['interval'])) { $item_interval = $item['interval']; } else { $item_interval = ''; } ?> <select name="snapshot-interval" id="snapshot-interval"> <optgroup label="<?php _e("Immediate Options", SNAPSHOT_I18N_DOMAIN); ?> "> <?php if (isset($_GET['page']) && sanitize_text_field($_GET['page']) == "snapshots_new_panel") { ?> <option value="immediate"><?php _e('Run immediate', SNAPSHOT_I18N_DOMAIN); ?> </option><?php } else { if (!empty($item_interval) && $item_interval != "immediate") { ?> <option value=""><?php _e('Manual', SNAPSHOT_I18N_DOMAIN); ?> </option><?php } else { ?> <option value=""><?php _e('Save only', SNAPSHOT_I18N_DOMAIN); ?> </option><?php } ?> <option value="immediate"><?php _e('Run immediate', SNAPSHOT_I18N_DOMAIN); ?> </option><?php } ?> </optgroup> <?php //if ( (!defined('DISABLE_WP_CRON')) || (DISABLE_WP_CRON == false)) { ?> <optgroup label="<?php _e("Scheduled Options", SNAPSHOT_I18N_DOMAIN); ?> "> <?php $scheds = (array) wp_get_schedules(); foreach ($scheds as $sched_key => $sched_item) { if (substr($sched_key, 0, strlen('snapshot-')) == "snapshot-") { ?> <option value="<?php echo $sched_key; ?> " <?php if ($item_interval == $sched_key) { echo ' selected="selected" '; } ?> ><?php echo $sched_item['display']; ?> </option><?php } } ?> </optgroup> <?php //} ?> </select> <sup>1</sup> </td> </tr> <?php if (!defined('DISABLE_WP_CRON') || DISABLE_WP_CRON == false) { ?> <tr class="form-field"> <th> <label for="snapshot-interval-offset"><?php _e('Start Backup', SNAPSHOT_I18N_DOMAIN); ?> </label> </th> <td> <?php $timestamp = time() + get_option('gmt_offset') * 3600; $localtime = localtime($timestamp, true); ?> <div id="interval-offset"> <div class="interval-offset-none" <?php if (empty($item_interval) || $item_interval == "immediate") { echo ' style="display: block;" '; } else { echo ' style="display: none;" '; } ?> ><?php _e("None", SNAPSHOT_I18N_DOMAIN); ?> </div> <div class="interval-offset-hourly" <?php if ($item_interval == "snapshot-hourly") { echo ' style="display: block;" '; } else { echo ' style="display: none;" '; } ?> > <label for="snapshot-interval-offset-hourly-minute"><?php _e('Minute', SNAPSHOT_I18N_DOMAIN); ?> </label> <select id="snapshot-interval-offset-hourly-minute" name="snapshot-interval-offset[snapshot-hourly][tm_min]"> <?php if (!isset($item['interval-offset']['snapshot-hourly']['tm_min'])) { $item['interval-offset']['snapshot-hourly']['tm_min'] = $localtime['tm_min']; } Snapshot_Helper_UI::form_show_minute_selector_options($item['interval-offset']['snapshot-hourly']['tm_min']); ?> </select> </div> <div class="interval-offset-daily" <?php if ($item_interval == "snapshot-daily" || $item_interval == "snapshot-twicedaily") { echo ' style="display: block;" '; } else { echo ' style="display: none;" '; } ?> > <label for="snapshot-interval-offset-daily-hour"><?php _e('Hour', SNAPSHOT_I18N_DOMAIN); ?> </label> <select id="snapshot-interval-offset-daily-hour" name="snapshot-interval-offset[snapshot-daily][tm_hour]"> <?php $_hour = 0; if (!isset($item['interval-offset']['snapshot-daily']['tm_hour'])) { $item['interval-offset']['snapshot-daily']['tm_hour'] = $localtime['tm_hour']; } Snapshot_Helper_UI::form_show_hour_selector_options($item['interval-offset']['snapshot-daily']['tm_hour']); ?> </select> <label for="snapshot-interval-offset-daily-minute"><?php _e('Minute', SNAPSHOT_I18N_DOMAIN); ?> </label> <select id="snapshot-interval-offset-daily-minute" name="snapshot-interval-offset[snapshot-daily][tm_min]"> <?php if (!isset($item['interval-offset']['snapshot-daily']['tm_min'])) { $item['interval-offset']['snapshot-daily']['tm_min'] = $localtime['tm_min']; } Snapshot_Helper_UI::form_show_minute_selector_options($item['interval-offset']['snapshot-daily']['tm_min']); ?> </select> </div> <div class="interval-offset-weekly" <?php if ($item_interval == "snapshot-weekly") { echo ' style="display: block;" '; } else { echo ' style="display: none;" '; } ?> > <label for="snapshot-interval-offset-weekly-wday"><?php _e('Weekday', SNAPSHOT_I18N_DOMAIN); ?> </label> <select id="snapshot-interval-offset-weekly-wday" name="snapshot-interval-offset[snapshot-weekly][tm_wday]"> <?php if (!isset($item['interval-offset']['snapshot-weekly']['tm_wday'])) { $item['interval-offset']['snapshot-weekly']['tm_wday'] = $localtime['tm_wday']; } Snapshot_Helper_UI::form_show_wday_selector_options($item['interval-offset']['snapshot-weekly']['tm_wday']); ?> </select> <label for="snapshot-interval-offset-weekly-hour"><?php _e('Hour', SNAPSHOT_I18N_DOMAIN); ?> </label> <select id="snapshot-interval-offset-weekly-hour" name="snapshot-interval-offset[snapshot-weekly][tm_hour]"> <?php if (!isset($item['interval-offset']['snapshot-weekly']['tm_hour'])) { $item['interval-offset']['snapshot-weekly']['tm_hour'] = $localtime['tm_hour']; } Snapshot_Helper_UI::form_show_hour_selector_options($item['interval-offset']['snapshot-weekly']['tm_hour']); ?> </select> <label for="snapshot-interval-offset-weekly-minute"><?php _e('Minute', SNAPSHOT_I18N_DOMAIN); ?> </label> <select id="snapshot-interval-offset-weekly-minute" name="snapshot-interval-offset[snapshot-weekly][tm_min]"> <?php if (!isset($item['interval-offset']['snapshot-weekly']['tm_min'])) { $item['interval-offset']['snapshot-weekly']['tm_min'] = $localtime['tm_min']; } Snapshot_Helper_UI::form_show_minute_selector_options($item['interval-offset']['snapshot-weekly']['tm_min']); ?> </select> </div> <div class="interval-offset-monthly" <?php if ($item_interval == "snapshot-monthly" || $item_interval == "snapshot-twicemonthly") { echo ' style="display: block;" '; } else { echo ' style="display: none;" '; } ?> > <label for="snapshot-interval-offset-monthly-mday"><?php _e('Day', SNAPSHOT_I18N_DOMAIN); ?> </label> <select id="snapshot-interval-offset-monthly-mday" name="snapshot-interval-offset[snapshot-monthly][tm_mday]"> <?php if (!isset($item['interval-offset']['snapshot-monthly']['tm_mday'])) { $item['interval-offset']['snapshot-monthly']['tm_mday'] = $localtime['tm_mday']; } Snapshot_Helper_UI::form_show_mday_selector_options($item['interval-offset']['snapshot-monthly']['tm_mday']); ?> </select> <label for="snapshot-interval-offset-monthly-hour"><?php _e('Hour', SNAPSHOT_I18N_DOMAIN); ?> </label> <select id="snapshot-interval-offset-monthly-hour" name="snapshot-interval-offset[snapshot-monthly][tm_hour]"> <?php if (!isset($item['interval-offset']['snapshot-monthly']['tm_hour'])) { $item['interval-offset']['snapshot-monthly']['tm_hour'] = $localtime['tm_hour']; } Snapshot_Helper_UI::form_show_hour_selector_options($item['interval-offset']['snapshot-monthly']['tm_hour']); ?> </select> <label for="snapshot-interval-offset-monthly-minutes"><?php _e('Minute', SNAPSHOT_I18N_DOMAIN); ?> </label> <select id="snapshot-interval-offset-monthly-minutes" name="snapshot-interval-offset[snapshot-monthly][tm_min]"> <?php if (!isset($item['interval-offset']['snapshot-monthly']['tm_min'])) { $item['interval-offset']['snapshot-monthly']['tm_min'] = $localtime['tm_min']; } Snapshot_Helper_UI::form_show_minute_selector_options($item['interval-offset']['snapshot-monthly']['tm_min']); ?> </select> </div> </div> </td> </tr> <tr class="form-field"> <td scope="row" colspan="2"> <p><strong><sup>1</sup> - <?php _e("The Snapshot scheduling process uses the WordPress Cron (WPCron) system. This is the same process used to run daily checks for updates to core, plugins and themes. It should be understood this WPCron process is not precise. If you schedule a Snapshot for a specific minute of the hour WPCron may not execute at exactly that time. WPCron relies on regular front-end traffic to your website to kickoff the processing.", SNAPSHOT_I18N_DOMAIN); ?> </strong></p> </td> </tr> <?php } ?> <tr class="form-field"> <td scope="row" colspan="2"> <p><?php _e("Control the total number of <strong>local</strong> archives to keep for this snapshot. Once the archive limit is reached, older locally stored archives will be removed. In common cases you may want to set the backup interval to once a week. Then set the number of archives to keep to 52 which would give you a year or backups. But keep in mind on a large site this will be a lot of extra disk space required.", SNAPSHOT_I18N_DOMAIN); ?> </p> </td> <tr class="form-field"> <th scope="row"> <label for="snapshot-name"><?php _e('Maximum number of local archives', SNAPSHOT_I18N_DOMAIN); ?> </label> </th> <td> <?php if (!isset($item['archive-count'])) { $item['archive-count'] = 0; } ?> <input type="text" name="snapshot-archive-count" id="snapshot-archive-count" value="<?php echo stripslashes($item['archive-count']); ?> "/> <p class="description"><?php _e('Example: 10, 100. Enter 0 to keep all', SNAPSHOT_I18N_DOMAIN); ?> </p> </td> </tr> </table> </div> <!-- end inside --> </div><!-- end postbox --> <?php }