<label for="hmbkp_automatic_on"> <input name="hmbkp_automatic" type="radio" id="hmbkp_automatic_on" value="1" <?php checked(!hmbkp_get_disable_automatic_backup()); ?> <?php disabled(defined('HMBKP_DISABLE_AUTOMATIC_BACKUP')); ?> > <?php _e('Backup my site automatically.', 'hmbkp'); ?> </label><br/> <label for="hmbkp_automatic_off"> <input name="hmbkp_automatic" type="radio" id="hmbkp_automatic_off" value="0" <?php checked(hmbkp_get_disable_automatic_backup()); ?> <?php disabled(defined('HMBKP_DISABLE_AUTOMATIC_BACKUP')); ?> > <?php _e('No automatic backups.', 'hmbkp'); ?> </label> </td> </tr> <tr align="top">
<?php // If the form has been submitted, things may have changed. if (!empty($_POST['hmbkp_settings_submit']) && (!wp_next_scheduled('hmbkp_schedule_backup_hook') || hmbkp_get_disable_automatic_backup())) { hmbkp_constant_changes(); } ?> <p>✓ <?php if (hmbkp_get_disable_automatic_backup() && !wp_next_scheduled('hmbkp_schedule_backup_hook')) { ?> <?php printf(__('Automatic backups are %s.', 'hmbkp'), '<strong>' . __('disabled', 'hmbkp') . '</strong>'); ?> <?php } else { if (!hmbkp_get_database_only() && !hmbkp_get_files_only()) { $what_to_backup = '<code>' . __('database', 'hmbkp') . '</code> ' . __('&', 'hmbkp') . ' <code>' . __('files', 'hmbkp') . '</code>'; } elseif (hmbkp_get_database_only()) { $what_to_backup = '<code>' . __('database', 'hmbkp') . '</code>'; } else { $what_to_backup = '<code>' . __('files', 'hmbkp') . '</code>'; } ?> <?php $offset = current_time('timestamp') - time();
/** * Handles changes in the defined Constants * that users can define to control advanced * settings * * @return null */ function hmbkp_constant_changes() { // Check whether we need to disable the cron if (hmbkp_get_disable_automatic_backup() && wp_next_scheduled('hmbkp_schedule_backup_hook')) { wp_clear_scheduled_hook('hmbkp_schedule_backup_hook'); } // Or whether we need to re-enable it if (!hmbkp_get_disable_automatic_backup() && !wp_next_scheduled('hmbkp_schedule_backup_hook')) { hmbkp_setup_schedule(); } // Allow the time of the daily backup to be changed if (wp_get_schedule('hmbkp_schedule_backup_hook') != get_option('hmbkp_schedule_frequency')) { hmbkp_setup_schedule(); } // Reset if custom time is removed if ((defined('HMBKP_DAILY_SCHEDULE_TIME') && !HMBKP_DAILY_SCHEDULE_TIME || !defined('HMBKP_DAILY_SCHEDULE_TIME')) && get_option('hmbkp_schedule_frequency') == 'daily' && date('H:i', wp_next_scheduled('hmbkp_schedule_backup_hook')) != '23:00' && !hmbkp_get_disable_automatic_backup()) { hmbkp_setup_schedule(); } // If a custom backup path has been set or changed if (defined('HMBKP_PATH') && HMBKP_PATH && hmbkp_conform_dir(HMBKP_PATH) != ($from = hmbkp_conform_dir(get_option('hmbkp_path')))) { hmbkp_path_move($from, HMBKP_PATH); } // If a custom backup path has been removed if (defined('HMBKP_PATH') && !HMBKP_PATH || !defined('HMBKP_PATH') && hmbkp_conform_dir(hmbkp_path_default()) != ($from = hmbkp_conform_dir(get_option('hmbkp_path')))) { hmbkp_path_move($from, hmbkp_path_default()); } // If the custom path has changed and the new directory isn't writable if (defined('HMBKP_PATH') && HMBKP_PATH && hmbkp_conform_dir(HMBKP_PATH) != ($from = hmbkp_conform_dir(get_option('hmbkp_path'))) && $from != hmbkp_path_default() && !is_writable(HMBKP_PATH) && is_dir($from)) { hmbkp_path_move($from, hmbkp_path_default()); } }