/** * 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(); }
function backups_number(Scheduled_Backup $schedule) { $number = count($schedule->get_backups()); if (0 === $number) { $output = sprintf(__('No backups completed', 'backupwordpress')); } else { $output = sprintf(_nx('One backup completed', '%1$s backups completed', $number, 'backups count', 'backupwordpress'), number_format_i18n($number)); } echo apply_filters('hmbkp_backups_number', $output, $number); }
/** * Display the running status via ajax */ function ajax_is_backup_in_progress() { check_ajax_referer('hmbkp_nonce', 'nonce'); if (empty($_POST['hmbkp_schedule_id'])) { die; } $schedule = new Scheduled_Backup(sanitize_text_field(urldecode($_POST['hmbkp_schedule_id']))); if (!$schedule->get_status()) { echo 0; } else { hmbkp_schedule_status($schedule); } die; }
/** * Returns a formatted string containing the calculated total site size or a message * to indicate it is being calculated. * * @param HM\BackUpWordPress\Scheduled_Backup $schedule * * @return string */ function get_site_size_text(Scheduled_Backup $schedule) { if (isset($_GET['hmbkp_add_schedule'])) { return ''; } $site_size = new Site_Size($schedule->get_type(), $schedule->get_excludes()); if ('database' === $schedule->get_type() || $site_size->is_site_size_cached()) { return sprintf('(<code title="' . __('Backups will be compressed and should be smaller than this.', 'backupwordpress') . '">%s</code>)', esc_html($site_size->get_formatted_site_size())); } return ''; }
/** * 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 & files. You can modify these schedules.', 'backupwordpress') . '</p></div>'; }); }
/** * Returns a formatted string containing the calculated total site size or a message * to indicate it is being calculated. * * @param HM\BackUpWordPress\Scheduled_Backup $schedule * * @return string */ function get_site_size_text(Scheduled_Backup $schedule) { if (isset($_GET['hmbkp_add_schedule'])) { return ''; } $site_size = new Site_Size($schedule->get_type(), $schedule->get_excludes()); if ('database' === $schedule->get_type() || $site_size->is_site_size_cached()) { return sprintf('(<code title="' . __('Backups will be compressed and should be smaller than this.', 'backupwordpress') . '">%s</code>)', esc_attr($site_size->get_formatted_site_size())); } else { return sprintf('(<code class="calculating" title="' . __('this shouldn\'t take long…', 'backupwordpress') . '">' . __('calculating the size of your site…', 'backupwordpress') . '</code>)'); } }