예제 #1
0
<?php

namespace HM\BackUpWordPress;

if (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()), 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()), get_settings_url()));
예제 #2
0
 /**
  * Function to run when the schedule cron fires.
  *
  * @param $schedule_id
  */
 public function schedule_hook_run($schedule_id)
 {
     if (!hmbkp_possible()) {
         return;
     }
     $schedules = Schedules::get_instance();
     $schedule = $schedules->get_schedule($schedule_id);
     if (!$schedule) {
         return;
     }
     $schedule->run();
 }
예제 #3
0
    echo esc_html(translated_schedule_title($schedule->get_slug(), $schedule->get_name()));
    ?>
 <span class="count">(<?php 
    echo esc_html(count($schedule->get_backups()));
    ?>
)</span></a></li>

		<?php 
}
?>

		<li><a href="<?php 
echo esc_url(add_query_arg(array('hmbkp_add_schedule' => '1', 'action' => 'hmbkp_edit_schedule', 'hmbkp_schedule_id' => time(), 'hmbkp_panel' => 'hmbkp_edit_schedule_settings'), HMBKP_ADMIN_URL));
?>
" class="<?php 
if (!Schedules::get_instance()->get_schedule($current_schedule->get_id())) {
    ?>
 current<?php 
}
?>
"> + <?php 
_e('add schedule', 'backupwordpress');
?>
</a></li>

	</ul>
</div>

<?php 
// Don't continue if we don't have a schedule
if (!($schedule = $current_schedule)) {
예제 #4
0
 /**
  * Gets the settings for a similar destination from the existing schedules
  * so that we can copy them into the form to avoid having to type them again
  *
  * @return array
  */
 protected function fetch_destination_settings()
 {
     $service = $this->get_slug();
     $schedules_obj = Schedules::get_instance();
     $schedules = $schedules_obj->get_schedules();
     foreach ($schedules as $schedule) {
         if ($schedule->get_id() != $this->schedule->get_id()) {
             $options = $schedule->get_service_options($service);
             if (!empty($options)) {
                 return $options;
             }
         }
     }
     return array();
 }
/**
 * Setup the default backup schedules
 */
function setup_default_schedules()
{
    $schedules = Schedules::get_instance();
    if ($schedules->get_schedules()) {
        return;
    }
    /**
     * Schedule a database backup daily and store backups
     * for the last 2 weeks
     */
    $database_daily = new Scheduled_Backup((string) time());
    $database_daily->set_type('database');
    $database_daily->set_schedule_start_time(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 Scheduled_Backup((string) (time() + 1));
    $complete_weekly->set_type('complete');
    $complete_weekly->set_schedule_start_time(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>';
    });
}
예제 #6
0
 /**
  * @return array
  */
 public static function test()
 {
     $backup_sizes = array();
     $schedules = Schedules::get_instance();
     foreach ($schedules->get_schedules() as $schedule) {
         $site_size = new Site_Size($schedule->get_type(), $schedule->get_excludes());
         if ($site_size->is_site_size_cached()) {
             $backup_sizes[$schedule->get_type()] = $site_size->get_formatted_site_size();
         }
     }
     return $backup_sizes;
 }
예제 #7
0
 /**
  * @return array
  */
 protected function test()
 {
     $backup_sizes = array();
     $schedules = Schedules::get_instance();
     foreach ($schedules->get_schedules() as $schedule) {
         if ($schedule->is_site_size_cached()) {
             $backup_sizes[$schedule->get_id()] = $schedule->get_formatted_site_size();
         }
     }
     return $backup_sizes;
 }