Exemplo n.º 1
0
<?php

if (HM\BackUpWordPress\Schedules::get_instance()->get_schedule($schedule->get_id())) {
    ?>

	<div class="hmbkp-schedule-actions row-actions">

		<a class="hmbkp-run" href="<?php 
    echo esc_url(wp_nonce_url(add_query_arg(array('action' => 'hmbkp_run_schedule', 'hmbkp_schedule_id' => $schedule->get_id()), admin_url('admin-ajax.php')), 'hmbkp_run_schedule', 'hmbkp_run_schedule_nonce'));
    ?>
"><?php 
    _e('Run now', 'backupwordpress');
    ?>
</a>  |

		<a href="<?php 
    echo esc_url(add_query_arg(array('action' => 'hmbkp_edit_schedule', 'hmbkp_panel' => 'hmbkp_edit_schedule_settings', 'hmbkp_schedule_id' => $schedule->get_id()), hmbkp_get_settings_url()), 'hmbkp-edit-schedule');
    ?>
"><?php 
    _e('Settings', 'backupwordpress');
    ?>
</a> |

		<?php 
    // Only show excludes if we are backing up files
    if ('database' !== $schedule->get_type()) {
        ?>
			<a href="<?php 
        echo esc_url(add_query_arg(array('action' => 'hmbkp_edit_schedule', 'hmbkp_panel' => 'hmbkp_edit_schedule_excludes', 'hmbkp_schedule_id' => $schedule->get_id()), hmbkp_get_settings_url()));
        ?>
"><?php 
Exemplo n.º 2
0
function hmbkp_calculate_site_size()
{
    if (isset($_GET['hmbkp_schedule_id'])) {
        $current_schedule = new HM\BackUpWordPress\Scheduled_Backup(sanitize_text_field($_GET['hmbkp_schedule_id']));
    } else {
        // Refresh the schedules from the database to make sure we have the latest changes
        HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
        $schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
        $current_schedule = reset($schedules);
    }
    if (!$current_schedule->is_site_size_cached()) {
        $root = new SplFileInfo($current_schedule->backup->get_root());
        $current_schedule->filesize($root);
    }
}
 function reload_backups()
 {
     $scheduleIds = isset($_POST['schedule_ids']) ? $_POST['schedule_ids'] : array();
     HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
     $all_schedules_ids = array();
     $schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
     foreach ($schedules as $sch) {
         $all_schedules_ids[] = $sch->get_id();
     }
     if (empty($all_schedules_ids)) {
         return array('error' => __("Not found schedules.", 'mainwp-child'));
     }
     foreach ($all_schedules_ids as $schedule_id) {
         if (!HM\BackUpWordPress\Schedules::get_instance()->get_schedule($schedule_id)) {
             continue;
         }
         $schedule = new HM\BackUpWordPress\Scheduled_Backup(sanitize_text_field(urldecode($schedule_id)));
         $out = array('b' => $this->get_backupslist_html($schedule), 'count' => count($schedule->get_backups()), 'file_size_text' => $this->hmbkp_get_site_size_text($schedule), 'scheduleStatus' => $schedule->get_status(), 'started_ago' => human_time_diff($schedule->get_schedule_running_start_time()));
         $information['backups'][$schedule_id] = $out;
     }
     $send_back_schedules = array();
     $schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
     foreach ($schedules as $schedule) {
         $sch_id = $schedule->get_id();
         if (!in_array($sch_id, $scheduleIds)) {
             $current_option = get_option('hmbkp_schedule_' . $sch_id);
             if (is_array($current_option)) {
                 unset($current_option['excludes']);
                 // not send this value
                 $send_back_schedules[$sch_id] = array('options' => $current_option, 'b' => $this->get_backupslist_html($schedule), 'count' => count($schedule->get_backups()), 'file_size_text' => $this->hmbkp_get_site_size_text($schedule), 'scheduleStatus' => $schedule->get_status(), 'started_ago' => human_time_diff($schedule->get_schedule_running_start_time()));
             }
         }
     }
     $information['backups_path'] = str_replace(HM\BackUpWordPress\Backup::get_home_path(), '', hmbkp_path());
     $information['send_back_schedules'] = $send_back_schedules;
     $information['result'] = 'SUCCESS';
     return $information;
 }
Exemplo n.º 4
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>';
    });
}