Beispiel #1
0
/**
 * Delete an exclude rule
 *
 * @access public
 * @return void
 */
function hmbkp_remove_exclude_rule()
{
    check_admin_referer('hmbkp_remove_exclude_rule', 'hmbkp-remove_exclude_rule_nonce');
    if (!isset($_GET['hmbkp_remove_exclude'])) {
        die;
    }
    $schedule = new HM\BackUpWordPress\Scheduled_Backup(sanitize_text_field($_GET['hmbkp_schedule_id']));
    $excludes = $schedule->get_excludes();
    $schedule->set_excludes(array_diff($excludes, (array) stripslashes(sanitize_text_field($_GET['hmbkp_remove_exclude']))));
    $schedule->save();
    wp_safe_redirect(wp_get_referer(), '303');
    die;
}
 function hmbkp_remove_exclude_rule()
 {
     if (!isset($_POST['remove_rule']) || empty($_POST['remove_rule'])) {
         return array('error' => __("Error: Empty exclude directory path."));
     }
     $schedule_id = $this->check_schedule();
     $schedule = new HM\BackUpWordPress\Scheduled_Backup(sanitize_text_field($schedule_id));
     $excludes = $schedule->get_excludes();
     $schedule->set_excludes(array_diff($excludes, (array) stripslashes(sanitize_text_field($_POST['remove_rule']))));
     $schedule->save();
     $current_path = urldecode($_POST['browse_dir']);
     if (empty($current_path)) {
         $current_path = null;
     }
     $return = $this->get_excluded($current_path);
     $out['e'] = $return['e'];
     $out['current_browse_dir'] = $_POST['browse_dir'];
     return $out;
 }
Beispiel #3
0
/**
 * Setup the default backup schedules
 */
function hmbkp_setup_default_schedules()
{
    $schedules = HM\BackUpWordPress\Schedules::get_instance();
    if ($schedules->get_schedules()) {
        return;
    }
    /**
     * Schedule a database backup daily and store backups
     * for the last 2 weeks
     */
    $database_daily = new HM\BackUpWordPress\Scheduled_Backup((string) time());
    $database_daily->set_type('database');
    $database_daily->set_schedule_start_time(hmbkp_determine_start_time('daily', array('hours' => '23', 'minutes' => '0')));
    $database_daily->set_reoccurrence('daily');
    $database_daily->set_max_backups(7);
    $database_daily->save();
    /**
     * Schedule a complete backup to run weekly and store backups for
     * the last 3 months
     */
    $complete_weekly = new HM\BackUpWordPress\Scheduled_Backup((string) (time() + 1));
    $complete_weekly->set_type('complete');
    $complete_weekly->set_schedule_start_time(hmbkp_determine_start_time('weekly', array('day_of_week' => 'sunday', 'hours' => '3', 'minutes' => '0')));
    $complete_weekly->set_reoccurrence('weekly');
    $complete_weekly->set_max_backups(3);
    $complete_weekly->save();
    $schedules->refresh_schedules();
    add_action('admin_notices', function () {
        echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __('BackUpWordPress has set up your default schedules.', 'backupwordpress') . '</strong> ' . __('By default BackUpWordPress performs a daily backup of your database and a weekly backup of your database &amp; files. You can modify these schedules.', 'backupwordpress') . '</p></div>';
    });
}