本文整理汇总了PHP中backupbuddy_core::schedule_event方法的典型用法代码示例。如果您正苦于以下问题:PHP backupbuddy_core::schedule_event方法的具体用法?PHP backupbuddy_core::schedule_event怎么用?PHP backupbuddy_core::schedule_event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backupbuddy_core
的用法示例。
在下文中一共展示了backupbuddy_core::schedule_event方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: unset
backupbuddy_core::verify_directories();
require_once pb_backupbuddy::plugin_path() . '/controllers/activation.php';
}
unset($options);
// Check if data version is behind & run activation upgrades if needed.
$default_options = pb_backupbuddy::settings('default_options');
if (pb_backupbuddy::$options['data_version'] < $default_options['data_version']) {
backupbuddy_core::verify_directories();
pb_backupbuddy::status('details', 'Data structure version of `' . pb_backupbuddy::$options['data_version'] . '` behind current version of `' . $default_options['data_version'] . '`. Running activation upgrade.');
require_once pb_backupbuddy::plugin_path() . '/controllers/activation.php';
}
/* END HANDLING DATA STRUCTURE UPGRADE */
// Schedule daily housekeeping.
if (false === wp_next_scheduled(pb_backupbuddy::cron_tag('housekeeping'))) {
// if schedule does not exist...
backupbuddy_core::schedule_event(time() + 60 * 60 * 2, 'daily', pb_backupbuddy::cron_tag('housekeeping'), array());
// Add schedule.
}
/********** ACTIONS (admin) **********/
// Set up reminders if enabled.
if (pb_backupbuddy::$options['backup_reminders'] == '1') {
pb_backupbuddy::add_action(array('load-update-core.php', 'wp_update_backup_reminder'));
pb_backupbuddy::add_action(array('post_updated_messages', 'content_editor_backup_reminder_on_update'));
}
// Display warning to network activate if running in normal mode on a MultiSite Network.
if (is_multisite() && !backupbuddy_core::is_network_activated()) {
pb_backupbuddy::add_action(array('all_admin_notices', 'multisite_network_warning'));
// BB should be network activated while on Multisite.
}
/********** AJAX (admin) **********/
// Backup process.
示例2: pre_backup
function pre_backup($serial, $archiveFile, $profile, $trigger, $pre_backup = array(), $post_backup = array(), $schedule_title = '', $export_plugins = array(), $deployDirection, $deployDestinationSettings)
{
pb_backupbuddy::status('startFunction', json_encode(array('function' => 'pre_backup', 'title' => 'Getting ready to backup')));
$type = $profile['type'];
// Log some status information.
pb_backupbuddy::status('details', __('Performing pre-backup procedures.', 'it-l10n-backupbuddy'));
if ($type == 'full') {
pb_backupbuddy::status('message', __('Full backup mode.', 'it-l10n-backupbuddy'));
} elseif ($type == 'db') {
pb_backupbuddy::status('message', __('Database only backup mode.', 'it-l10n-backupbuddy'));
} elseif ($type == 'files') {
pb_backupbuddy::status('message', __('Files only backup mode.', 'it-l10n-backupbuddy'));
//$profile['skip_database_dump'] = '1';
} elseif ($type == 'export') {
pb_backupbuddy::status('message', __('Multisite subsite export mode.', 'it-l10n-backupbuddy'));
} else {
pb_backupbuddy::status('error', 'Error #8587383: Unknown backup mode `' . htmlentities($type) . '`.');
}
if ('' != $deployDirection) {
pb_backupbuddy::status('details', 'Deployment direction: `' . $deployDirection . '`.');
}
if ('1' == pb_backupbuddy::$options['prevent_flush']) {
pb_backupbuddy::status('details', 'Flushing will be skipped based on advanced settings.');
} else {
pb_backupbuddy::status('details', 'Flushing will not be skipped (default).');
}
// Schedule daily housekeeping.
if (false === wp_next_scheduled(pb_backupbuddy::cron_tag('housekeeping'))) {
// if schedule does not exist...
backupbuddy_core::schedule_event(time() + 60 * 60 * 2, 'daily', pb_backupbuddy::cron_tag('housekeeping'), array());
// Add schedule.
}
// Verify directories.
pb_backupbuddy::status('details', 'Verifying directories ...');
if (false === backupbuddy_core::verify_directories()) {
pb_backupbuddy::status('error', 'Error #18573. Error verifying directories. See details above. Backup halted.');
pb_backupbuddy::status('haltScript', '');
// Halt JS on page.
die;
} else {
pb_backupbuddy::status('details', 'Directories verified.');
}
// Delete all backup archives if this troubleshooting option is enabled.
if (pb_backupbuddy::$options['delete_archives_pre_backup'] == '1') {
pb_backupbuddy::status('message', 'Deleting all existing backups prior to backup as configured on the settings page.');
$file_list = glob(backupbuddy_core::getBackupDirectory() . 'backup*.zip');
if (is_array($file_list) && !empty($file_list)) {
foreach ($file_list as $file) {
if (@unlink($file) === true) {
pb_backupbuddy::status('details', 'Deleted backup archive `' . basename($file) . '` based on settings to delete all backups.');
} else {
pb_backupbuddy::status('details', 'Unable to delete backup archive `' . basename($file) . '` based on settings to delete all backups. Verify permissions.');
}
}
}
}
// Generate unique serial ID.
pb_backupbuddy::status('details', 'Backup serial generated: `' . $serial . '`.');
pb_backupbuddy::status('details', 'About to load fileoptions data in create mode.');
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
pb_backupbuddy::status('details', 'Fileoptions instance #40.');
$this->_backup_options = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt', $read_only = false, $ignore_lock = false, $create_file = true);
if (true !== ($result = $this->_backup_options->is_ok())) {
pb_backupbuddy::status('error', __('Fatal Error #9034 A. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
pb_backupbuddy::status('haltScript', '');
// Halt JS on page.
return false;
}
pb_backupbuddy::status('details', 'Fileoptions data loaded.');
$this->_backup =& $this->_backup_options->options;
// Set reference.
// Cleanup internal stats. Deployments should not impact stats.
if ('' == $deployDirection) {
pb_backupbuddy::status('details', 'Updating statistics for last backup start.');
pb_backupbuddy::$options['last_backup_start'] = time();
// Reset time since last backup.
pb_backupbuddy::$options['last_backup_serial'] = $serial;
pb_backupbuddy::save();
}
// Output active plugins list for debugging...
$activePlugins = get_option('active_plugins');
pb_backupbuddy::status('details', 'Active WordPress plugins: `' . implode('; ', $activePlugins) . '`.');
pb_backupbuddy::status('startSubFunction', json_encode(array('function' => 'wp_plugins_found', 'title' => 'Found ' . count($activePlugins) . ' active WordPress plugins.')));
unset($activePlugins);
// Compression to bool.
/*
if ( $profile['compression'] == '1' ) {
$profile['compression'] = true;
} else {
$profile['compression'] = false;
}
*/
if (pb_backupbuddy::$options['compression'] == '1') {
$compression = true;
} else {
$compression = false;
}
$archiveURL = '';
$abspath = str_replace('\\', '/', ABSPATH);
// Change slashes to handle Windows as we store backup_directory with Linux-style slashes even on Windows.
//.........这里部分代码省略.........
示例3: validateSchedules
public static function validateSchedules()
{
foreach (pb_backupbuddy::$options['schedules'] as $schedule_id => $schedule) {
// Retrieve current interval WordPress cron thinks the schedule is at.
$cron_inverval = wp_get_schedule('pb_backupbuddy-cron_scheduled_backup', array((int) $schedule_id));
$intervals = wp_get_schedules();
if (FALSE === $cron_inverval) {
// Schedule MISSING. Re-schedule.
$result = backupbuddy_core::schedule_event($schedule['first_run'], $schedule['interval'], 'pb_backupbuddy-cron_scheduled_backup', array((int) $schedule_id));
// Add new schedule.
if ($result === FALSE) {
$message = 'Error #83443784: A missing schedule was identified but unable to be re-created. Your schedule may not work properly & need manual attention.';
pb_backupbuddy::alert($message, true);
} else {
pb_backupbuddy::alert('Warning #2389373: A missing schedule was identified and re-created. This should have corrected any problem with this schedule.', true);
}
continue;
}
if ($cron_inverval != $schedule['interval']) {
// Schedule exists BUT interval is WRONG. Fix it.
$cron_run = wp_next_scheduled('pb_backupbuddy-cron_scheduled_backup', array((int) $schedule_id));
$result = backupbuddy_core::unschedule_event($cron_run, 'pb_backupbuddy-cron_scheduled_backup', array((int) $schedule_id));
// Delete existing schedule.
if ($result === FALSE) {
$message = 'Error removing invalid event from WordPress. Your schedule may not work properly. Please try again. Error #38279343. Check your BackupBuddy error log for details.';
pb_backupbuddy::alert($message, true);
continue;
}
// Determine when the next run time SHOULD be.
if (0 == $schedule['last_run']) {
$next_run = $schedule['first_run'];
} else {
$next_run = (int) $schedule['last_run'] + (int) $intervals[$schedule['interval']]['interval'];
}
$result = backupbuddy_core::schedule_event($next_run, $schedule['interval'], 'pb_backupbuddy-cron_scheduled_backup', array((int) $schedule_id));
// Add new schedule.
if ($result === FALSE) {
$message = 'Error #237836464: An invalid schedule with the incorrect interval was identified & deleted but unable to be re-created. Your schedule may not work properly & need manual attention.';
pb_backupbuddy::alert($message, true);
continue;
} else {
pb_backupbuddy::alert('Warning #2423484: An invalid schedule with the incorrect interval was identified and updated. This should have corrected any problem with this schedule.', true);
}
}
}
// end foreach.
//wp_get_schedule($hook, $args = array())
}
示例4: implode
return false;
}
$schedule = pb_backupbuddy::settings('schedule_defaults');
$schedule['title'] = $title;
$schedule['profile'] = (int) $profile;
$schedule['interval'] = $interval;
$schedule['first_run'] = $first_run;
$schedule['remote_destinations'] = implode('|', $remote_destinations);
if (true == $delete_after) {
$schedule['delete_after'] = '1';
} else {
$schedule['delete_after'] = '0';
}
if (false == $enabled) {
$schedule['on_off'] = '0';
} else {
$schedule['on_off'] = '1';
}
$next_index = pb_backupbuddy::$options['next_schedule_index'];
// v2.1.3: $next_index = end( array_keys( pb_backupbuddy::$options['schedules'] ) ) + 1;
pb_backupbuddy::$options['next_schedule_index']++;
// This change will be saved in savesettings function below.
pb_backupbuddy::$options['schedules'][$next_index] = $schedule;
$result = backupbuddy_core::schedule_event($schedule['first_run'], $schedule['interval'], 'pb_backupbuddy-cron_scheduled_backup', array($next_index));
if ($result === false) {
return 'Error scheduling event with WordPress. Your schedule may not work properly. Please try again. Error #3488439b. Check your BackupBuddy error log for details.';
} else {
pb_backupbuddy::save();
backupbuddy_core::addNotification('schedule_created', 'Backup schedule created', 'A new backup schedule "' . $schedule['title'] . '" has been created.', $schedule);
return true;
}
示例5: wp_next_scheduled
} else {
// EDIT SCHEDULE. Form handles saving; just need to update timestamp.
$first_run = pb_backupbuddy::$format->unlocalize_time(strtotime($submitted_schedule['data']['first_run']));
if ($first_run == 0 || $first_run == 18000) {
pb_backupbuddy::alert(sprintf(__('Invalid time format. Please use the specified format / example %s', 'it-l10n-backupbuddy'), $date_format_example));
$error = true;
}
pb_backupbuddy::$options['schedules'][pb_backupbuddy::_GET('edit')]['first_run'] = $first_run;
//echo 'first: ' . $first_run;
$next_scheduled_time = wp_next_scheduled('pb_backupbuddy-cron_scheduled_backup', array((int) $_GET['edit']));
$result = backupbuddy_core::unschedule_event($next_scheduled_time, 'pb_backupbuddy-cron_scheduled_backup', array((int) $_GET['edit']));
// Remove old schedule. pb_backupbuddy::$options['schedules'][$_GET['edit']]['first_run']
if ($result === FALSE) {
pb_backupbuddy::alert('Error #589689. Unable to unschedule scheduled cron job with WordPress. Please see your BackupBuddy error log for details.');
}
$result = backupbuddy_core::schedule_event($first_run, $submitted_schedule['data']['interval'], 'pb_backupbuddy-cron_scheduled_backup', array((int) $_GET['edit']));
// Add new schedule.
if ($result === FALSE) {
pb_backupbuddy::alert('Error scheduling event with WordPress. Your schedule may not work properly. Please try again. Error #3488439. Check your BackupBuddy error log for details.', true);
}
pb_backupbuddy::save();
pb_backupbuddy::alert('Edited schedule `' . htmlentities($submitted_schedule['data']['title']) . '`.');
}
} elseif (count($submitted_schedule['errors']) > 0) {
foreach ($submitted_schedule['errors'] as $error) {
pb_backupbuddy::alert($error);
}
}
$data['schedule_form'] = $schedule_form;
$schedules = array();
foreach (pb_backupbuddy::$options['schedules'] as $schedule_id => $schedule) {
示例6: verifyHousekeeping
public static function verifyHousekeeping()
{
if (false === wp_next_scheduled('backupbuddy_cron', array('housekeeping', array()))) {
// if schedule does not exist...
backupbuddy_core::schedule_event(time() + 60 * 60 * 2, 'daily', 'housekeeping', array());
// Add schedule.
}
}
示例7: add_backup_schedule
public static function add_backup_schedule($title, $profile, $interval, $first_run, $remote_destinations = array(), $delete_after = false, $enabled = true)
{
$schedule = pb_backupbuddy::settings('schedule_defaults');
$schedule['title'] = $title;
$schedule['profile'] = (int) $profile;
$schedule['interval'] = $interval;
$schedule['first_run'] = $first_run;
$schedule['remote_destinations'] = implode('|', $remote_destinations);
if (true == $delete_after) {
$schedule['delete_after'] = '1';
} else {
$schedule['delete_after'] = '0';
}
if (false == $enabled) {
$schedule['on_off'] = '0';
} else {
$schedule['on_off'] = '1';
}
$next_index = pb_backupbuddy::$options['next_schedule_index'];
// v2.1.3: $next_index = end( array_keys( pb_backupbuddy::$options['schedules'] ) ) + 1;
pb_backupbuddy::$options['next_schedule_index']++;
// This change will be saved in savesettings function below.
pb_backupbuddy::$options['schedules'][$next_index] = $schedule;
$result = backupbuddy_core::schedule_event($schedule['first_run'], $schedule['interval'], 'pb_backupbuddy-cron_scheduled_backup', array($next_index));
if ($result === false) {
return 'Error scheduling event with WordPress. Your schedule may not work properly. Please try again. Error #3488439b. Check your BackupBuddy error log for details.';
} else {
pb_backupbuddy::save();
return true;
}
}
示例8: remove_wp_schedules_with_no_bb_schedule
public static function remove_wp_schedules_with_no_bb_schedule()
{
$cron = get_option('cron');
foreach ((array) $cron as $time => $cron_item) {
// Times
if (is_numeric($time)) {
// Loop through each schedule for this time
foreach ((array) $cron_item as $hook_name => $event) {
// Methods
foreach ((array) $event as $item_name => $item) {
// Full args for method
if ('backupbuddy_cron' == $hook_name && 'run_scheduled_backup' == $item['args'][0]) {
// scheduled backup
if (!empty($item['args'])) {
if (!isset(pb_backupbuddy::$options['schedules'][$item['args'][1][0]])) {
// BB schedule does not exist so delete this cron item.
if (FALSE === backupbuddy_core::unschedule_event($time, $hook_name, $item['args'])) {
// Delete the scheduled cron.
pb_backupbuddy::status('error', 'Error #5657667675b. Unable to delete CRON job. Please see your BackupBuddy error log for details.');
} else {
pb_backupbuddy::status('warning', 'Removed stale cron scheduled backup.');
}
}
} else {
// No args, something wrong so delete it.
if (FALSE === backupbuddy_core::unschedule_event($time, $hook_name, $item['args'])) {
// Delete the scheduled cron.
pb_backupbuddy::status('error', 'Error #5657667675c. Unable to delete CRON job. Please see your BackupBuddy error log for details.');
} else {
pb_backupbuddy::status('warning', 'Removed stale cron scheduled backup which had no arguments.');
}
}
} elseif ('pb_backupbuddy-cron_scheduled_backup' == $hook_name) {
// Upgrade hook name to 'backupbuddy_cron'.
if (FALSE === wp_unschedule_event($time, $hook_name, $item['args'])) {
// Delete the scheduled cron.
pb_backupbuddy::status('error', 'Error #327237. Unable to delete CRON job for migration to new tag. Please see your BackupBuddy error log for details.');
} else {
pb_backupbuddy::status('details', 'Removed cron with old tag format.');
}
if (isset(pb_backupbuddy::$options['schedules'][$item['args'][0]])) {
// BB schedule exists so recreate.
$result = backupbuddy_core::schedule_event($time, pb_backupbuddy::$options['schedules'][$item['args'][0]]['interval'], 'run_scheduled_backup', $item['args']);
if ($result === false) {
pb_backupbuddy::status('error', 'Error #8923832: Unable to reschedule with new cron tag.');
} else {
pb_backupbuddy::status('details', 'Replaced cron with old tag format with new format.');
}
} else {
pb_backupbuddy::status('warning', 'Stale schedule found with WordPress without corresponding BackupBuddy schedule. Not keeping when migrating to new cron tag.');
}
} elseif ('pb_backupbuddy_cron' == $hook_name) {
// Remove.
wp_unschedule_event($time, $hook_name, $item['args']);
} elseif ('pb_backupbuddy_corn' == $hook_name) {
// Remove.
wp_unschedule_event($time, $hook_name, $item['args']);
} elseif ('pb_backupbuddy_housekeeping' == $hook_name) {
// Remove.
wp_unschedule_event($time, $hook_name, $item['args']);
}
}
// End foreach.
unset($item);
unset($item_name);
}
// End foreach.
unset($event);
unset($hook_name);
}
// End if is_numeric.
}
// End foreach.
unset($cron_item);
unset($time);
}