本文整理汇总了PHP中backupbuddy_core::addNotification方法的典型用法代码示例。如果您正苦于以下问题:PHP backupbuddy_core::addNotification方法的具体用法?PHP backupbuddy_core::addNotification怎么用?PHP backupbuddy_core::addNotification使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backupbuddy_core
的用法示例。
在下文中一共展示了backupbuddy_core::addNotification方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run($arguments)
{
$arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
pb_backupbuddy::$options['remote_destinations'][] = $arguments['settings'];
pb_backupbuddy::save();
$newDestination = array();
$newDestination['title'] = $arguments['settings']['title'];
$newDestination['type'] = $arguments['settings']['type'];
backupbuddy_core::addNotification('destination_created', 'Remote destination created', 'A new remote destination "' . $newDestination['title'] . '" has been created.', $newDestination);
$highest_destination_index = end(array_keys(pb_backupbuddy::$options['remote_destinations']));
return array('api' => '1', 'status' => 'ok', 'message' => 'Destination added.', 'destination_id' => $highest_destination_index);
}
示例2: 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;
}
示例3: array
</script>
<?php
pb_backupbuddy::$ui->title(__('Settings', 'it-l10n-backupbuddy'));
backupbuddy_core::versions_confirm();
pb_backupbuddy::disalert('profile_suggest', '<span class="pb_label" style="font-size: 12px; margin-left: 10px; position: relative;">Tip</span> You can create & customize multiple different backup types with profiles on the <a href="?page=pb_backupbuddy_backup">Backups</a> page by selecting the gear icon next to each profile.');
$data = array();
// To pass to view.
// Reset settings to defaults.
if (pb_backupbuddy::_POST('reset_defaults') != '') {
pb_backupbuddy::verify_nonce();
if (call_user_func('pb_backupbuddy::reset_options', true) === true) {
backupbuddy_core::verify_directories($skipTempGeneration = true);
// Re-verify directories such as backup dir, temp, etc.
//pb_backupbuddy::alert( 'Plugin settings have been reset to defaults.' );
backupbuddy_core::addNotification('settings_reset', 'Plugin settigns reset', 'All plugin settings have been reset to defaults.');
} else {
pb_backupbuddy::alert('Unable to reset plugin settings. Verify you are running the latest version.');
}
}
/* BEGIN VERIFYING BACKUP DIRECTORY */
if (isset($_POST['pb_backupbuddy_backup_directory'])) {
$backup_directory = pb_backupbuddy::_POST('pb_backupbuddy_backup_directory');
if ('' == $backup_directory) {
// blank so set to default.
$backup_directory = backupbuddy_core::_getBackupDirectoryDefault();
}
$backup_directory = str_replace('\\', '/', $backup_directory);
$backup_directory = rtrim($backup_directory, '/\\') . '/';
// Enforce single trailing slash.
if (!is_dir($backup_directory)) {
示例4: process_backup
//.........这里部分代码省略.........
/********* End Running Step Function **********/
//unset( $step );
if ($response === false) {
// Function finished but reported failure.
// Failure caused by backup cancellation.
if (true == get_transient('pb_backupbuddy_stop_backup-' . $serial)) {
pb_backupbuddy::status('haltScript', '');
// Halt JS on page.
return false;
}
pb_backupbuddy::status('error', 'Failed function `' . $this->_backup['steps'][$step_index]['function'] . '`. Backup terminated.');
pb_backupbuddy::status('errorFunction', $this->_backup['steps'][$step_index]['function']);
pb_backupbuddy::status('details', __('Peak memory usage', 'it-l10n-backupbuddy') . ': ' . round(memory_get_peak_usage() / 1048576, 3) . ' MB');
pb_backupbuddy::status('haltScript', '');
// Halt JS on page.
$args = print_r($this->_backup['steps'][$step_index]['args'], true);
$attachment = NULL;
$attachment_note = 'Enable full logging for troubleshooting (a log will be sent with future error emails while enabled).';
if (pb_backupbuddy::$options['log_level'] == '3') {
// Full logging enabled.
// Log file will be attached.
$log_file = backupbuddy_core::getLogDirectory() . 'status-' . $serial . '_' . pb_backupbuddy::$options['log_serial'] . '.txt';
if (file_exists($log_file)) {
$attachment = $log_file;
$attachment_note = 'A log file is attached which may provide further details.';
} else {
$attachment = NULL;
}
}
// Send error notification email.
backupbuddy_core::mail_error('One or more backup steps reported a failure. ' . $attachment_note . ' Backup failure running function `' . $this->_backup['steps'][$step_index]['function'] . '` with the arguments `' . $args . '` with backup serial `' . $serial . '`. Please run a manual backup of the same type to verify backups are working properly or view the backup status log.', NULL, $attachment);
return false;
} else {
// Function finished successfully.
$this->_backup['steps'][$step_index]['finish_time'] = microtime(true);
if ('backup_create_database_dump' != $this->_backup['steps'][$step_index]['function'] && 'send_remote_destination' != $this->_backup['steps'][$step_index]['function']) {
// Wipe arguments. Keeps fileoptions for growing crazily for finished steps containing state data such as deployment or new zip functionality passing chunking state.
$this->_backup['steps'][$step_index]['args'] = time();
}
$this->_backup['updated_time'] = microtime(true);
$this->_backup_options->save();
pb_backupbuddy::status('details', sprintf(__('Finished function `%s`. Peak memory usage', 'it-l10n-backupbuddy') . ': ' . round(memory_get_peak_usage() / 1048576, 3) . ' MB', $this->_backup['steps'][$step_index]['function']) . ' with BackupBuddy v' . pb_backupbuddy::settings('version')) . '.';
pb_backupbuddy::status('finishFunction', json_encode(array('function' => $this->_backup['steps'][$step_index]['function'])));
pb_backupbuddy::status('details', '-----');
$found_another_step = false;
foreach ($this->_backup['steps'] as $next_step) {
// Loop through each step and see if any have not started yet.
if ($next_step['start_time'] == 0) {
// Another unstarted step exists. Schedule it.
$found_another_step = true;
if ($this->_backup['profile']['backup_mode'] == '2') {
// Modern mode with crons.
$this->cron_next_step(null, null, $next_step['function']);
} elseif ($this->_backup['profile']['backup_mode'] == '1') {
// classic mode
pb_backupbuddy::status('details', 'Classic mode; skipping cron & triggering next step.');
$this->process_backup($this->_backup['serial'], $trigger);
} else {
pb_backupbuddy::status('error', 'Error #3838932: Fatal error. Unknown backup mode `' . $this->_backup['profile']['backup_mode'] . '`. Expected 1 (classic) or 2 (modern).');
return false;
}
break;
}
}
// End foreach().
if ($found_another_step == false) {
pb_backupbuddy::status('details', __('No more backup steps remain. Finishing...', 'it-l10n-backupbuddy'));
$this->_backup['finish_time'] = microtime(true);
$this->_backup_options->save();
pb_backupbuddy::status('startFunction', json_encode(array('function' => 'backup_success', 'title' => __('Backup completed successfully.', 'it-l10n-backupbuddy'))));
pb_backupbuddy::status('finishFunction', json_encode(array('function' => 'backup_success')));
// Notification for manual and scheduled backups (omits deployment stuff).
if ($this->_backup['trigger'] == 'manual' || 'scheduled' == $this->_backup['trigger']) {
$data = array();
$data['serial'] = $this->_backup['serial'];
$data['type'] = $this->_backup['type'];
$data['profile_title'] = $this->_backup['profile']['title'];
if ('' != $this->_backup['schedule_title']) {
$data['schedule_title'] = $this->_backup['schedule_title'];
}
backupbuddy_core::addNotification('backup_success', 'Backup completed successfully', 'A ' . $this->_backup['trigger'] . ' backup has completed successfully on your site.', $data);
}
} else {
pb_backupbuddy::status('details', 'Completed step function `' . $step['function'] . '`.');
//pb_backupbuddy::status( 'details', 'The next should run in a moment. If it does not please check for plugin conflicts and that the next step is scheduled in the cron on the Server Information page.' );
}
// If full logging, output fileoptions state data to brwoser for display in console.
if (pb_backupbuddy::$options['log_level'] == '3') {
// Full logging enabled.
$thisBackup = $this->_backup;
if ('' != $this->_backup['deployment_direction']) {
// Remove steps for deployment because it gets too large.
$thisBackup['steps'] = '** Removed since deployment type **';
}
pb_backupbuddy::status('backupState', json_encode($thisBackup));
//base64_encode( json_encode( $this->_backup ) ) );
}
return true;
}
}
示例5: wp_next_scheduled
//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'] ) . '`.' );
$editedSchedule = $submitted_schedule['data'];
backupbuddy_core::addNotification('schedule_updated', 'Backup schedule updated', 'An existing schedule "' . $editedSchedule['title'] . '" has been updated.', $editedSchedule);
}
} elseif (count($submitted_schedule['errors']) > 0) {
foreach ($submitted_schedule['errors'] as $error) {
pb_backupbuddy::alert($error);
}
}
$data['schedule_form'] = $schedule_form;
// Validate that all internal schedules are properly registered in the WordPress cron
backupbuddy_core::validateSchedules();
$schedules = array();
foreach (pb_backupbuddy::$options['schedules'] as $schedule_id => $schedule) {
$profile = pb_backupbuddy::$options['profiles'][(int) $schedule['profile']];
$title = $schedule['title'];
if ($profile['type'] == 'full') {
$type = 'Full';
示例6: array
// ADD NEW.
// Copy over dropbox token.
$save_result['data']['token'] = pb_backupbuddy::$options['dropboxtemptoken'];
pb_backupbuddy::$options['remote_destinations'][] = $save_result['data'];
$newDestination = array();
$newDestination['title'] = $save_result['data']['title'];
$newDestination['type'] = $save_result['data']['type'];
backupbuddy_core::addNotification('destination_created', 'Remote destination created', 'A new remote destination "' . $newDestination['title'] . '" has been created.', $newDestination);
pb_backupbuddy::save();
echo 'Destination Added.';
} elseif (!isset(pb_backupbuddy::$options['remote_destinations'][$destination_id])) {
// EDITING NONEXISTANT.
echo 'Error #54859. Invalid destination ID `' . $destination_id . '`.';
} else {
// EDITING EXISTING -- Save!
// Copy over dropbox token.
//$token_copy_holder = pb_backupbuddy::$options['remote_destinations'][$destination_id]['token'];
pb_backupbuddy::$options['remote_destinations'][$destination_id] = array_merge(pb_backupbuddy::$options['remote_destinations'][$destination_id], $save_result['data']);
//echo '<pre>' . print_r( pb_backupbuddy::$options['remote_destinations'][$destination_id], true ) . '</pre>';
pb_backupbuddy::save();
echo 'Settings saved.';
$editedDestination = array();
$editedDestination['title'] = $save_result['data']['title'];
$editedDestination['type'] = $save_result['data']['type'];
backupbuddy_core::addNotification('destination_updated', 'Remote destination updated', 'An existing remote destination "' . $editedDestination['title'] . '" has been updated.', $editedDestination);
}
} else {
echo "Error saving settings.\n\n";
echo implode("\n", $save_result['errors']);
}
die;
示例7: __
// Reset settings to defaults.
if (pb_backupbuddy::_POST('reset_defaults') != '') {
pb_backupbuddy::verify_nonce();
$keepDestNote = '';
$remote_destinations = pb_backupbuddy::$options['remote_destinations'];
pb_backupbuddy::$options = pb_backupbuddy::settings('default_options');
if ('1' == pb_backupbuddy::_POST('keep_destinations')) {
pb_backupbuddy::$options['remote_destinations'] = $remote_destinations;
$keepDestNote = ' ' . __('Remote destination settings were not reset.', 'it-l10n-backupbuddy');
}
pb_backupbuddy::save();
backupbuddy_core::verify_directories($skipTempGeneration = true);
// Re-verify directories such as backup dir, temp, etc.
$resetNote = __('Plugin settings have been reset to defaults.', 'it-l10n-backupbuddy');
pb_backupbuddy::alert($resetNote . $keepDestNote);
backupbuddy_core::addNotification('settings_reset', 'Plugin settings reset', $resetNote . $keepDestNote);
}
/* BEGIN VERIFYING BACKUP DIRECTORY */
if (isset($_POST['pb_backupbuddy_backup_directory'])) {
$backup_directory = pb_backupbuddy::_POST('pb_backupbuddy_backup_directory');
if ('' == $backup_directory) {
// blank so set to default.
$backup_directory = backupbuddy_core::_getBackupDirectoryDefault();
}
$backup_directory = str_replace('\\', '/', $backup_directory);
$backup_directory = rtrim($backup_directory, '/\\') . '/';
// Enforce single trailing slash.
if (!is_dir($backup_directory)) {
if (false === @mkdir($backup_directory, 0755)) {
pb_backupbuddy::alert('Error #4838594589: Selected backup directory does not exist and it could not be created. Verify the path is correct or manually create the directory and set proper permissions. Reset to default path.');
$_POST['pb_backupbuddy_backup_directory'] = backupbuddy_core::getBackupDirectory();
示例8: _e
</span></h3>
<div class="inside">
<label><?php
_e('Malware', 'it-l10n-backupbuddy');
?>
</label>
<?php
if (!empty($scan['MALWARE']['WARN'])) {
// Malware found.
echo lined_array($scan['MALWARE']['WARN']);
backupbuddy_core::addNotification('malware_found', 'Malware detected on `' . $url . '`.', 'A malware scan was run on the site and detected malware.', array(), true);
// Urgent
} else {
// No malware found.
echo '<i>', __('none', 'it-l10n-backupbuddy'), '</i><br />';
backupbuddy_core::addNotification('malware_not_found', 'No malware detected on `' . $url . '`.', 'A malware scan was run on the site and did not detect malware.');
}
?>
<br />
</div>
</div>
<div id="breadcrumbslike" class="postbox">
<div class="handlediv" title="<?php
_e('Click to toggle', 'it-l10n-backupbuddy');
?>
"><br /></div>
<h3 class="hndle"><span><?php
_e('Web server details', 'it-l10n-backupbuddy');
?>
</span></h3>
示例9: wp_next_scheduled
<?php
if (true !== $confirm) {
return false;
}
$next_scheduled_time = wp_next_scheduled('pb_backupbuddy-cron_scheduled_backup', array((int) $scheduleID));
if (FALSE === backupbuddy_core::unschedule_event($next_scheduled_time, 'pb_backupbuddy-cron_scheduled_backup', array((int) $scheduleID))) {
return false;
}
$deletedSchedule = pb_backupbuddy::$options['schedules'][$scheduleID];
unset(pb_backupbuddy::$options['schedules'][$scheduleID]);
pb_backupbuddy::save();
backupbuddy_core::addNotification('schedule_deleted', 'Backup schedule deleted', 'An existing backup schedule "' . $deletedSchedule['title'] . '" has been deleted.', $deletedSchedule);
return true;
示例10: delete_destination
public static function delete_destination($destination_id, $confirm = false)
{
if ($confirm === false) {
return 'Error #54858597. Not deleted. Confirmation parameter missing.';
}
// Delete destination.
$deletedDestination = array();
$deletedDestination['type'] = pb_backupbuddy::$options['remote_destinations'][$destination_id]['type'];
$deletedDestination['title'] = pb_backupbuddy::$options['remote_destinations'][$destination_id]['title'];
unset(pb_backupbuddy::$options['remote_destinations'][$destination_id]);
// Remove this destination from all schedules using it.
foreach (pb_backupbuddy::$options['schedules'] as $schedule_id => $schedule) {
$remote_list = '';
$trimmed_destination = false;
$remote_destinations = explode('|', $schedule['remote_destinations']);
foreach ($remote_destinations as $remote_destination) {
if ($remote_destination == $destination_id) {
$trimmed_destination = true;
} else {
$remote_list .= $remote_destination . '|';
}
}
if ($trimmed_destination === true) {
pb_backupbuddy::$options['schedules'][$schedule_id]['remote_destinations'] = $remote_list;
}
}
// end foreach.
pb_backupbuddy::save();
backupbuddy_core::addNotification('destination_deleted', 'Remote destination deleted', 'An existing remote destination "' . $deletedDestination['title'] . '" has been deleted.', $deletedDestination);
return true;
}
示例11: _step_run_remote_snapshot
public static function _step_run_remote_snapshot()
{
if (false === self::_load_state()) {
return false;
}
// If not all files have uploaded, skip snapshot for now.
if (self::$_state['stats']['files_pending_send'] > 0 || self::$_state['stats']['tables_pending_send'] > 0) {
pb_backupbuddy::status('details', '`' . self::$_state['stats']['files_pending_send'] . '` files and `' . self::$_state['stats']['tables_pending_send'] . '` database tables are still pending transfer. Waiting for transfers to finish before creating Snapshot.');
self::$_state['stats']['wait_on_transfers_start'] = microtime(true);
backupbuddy_live::queue_step($step = 'wait_on_transfers', $args = array(), $skip_run_now = true);
return true;
}
if (0 == self::$_state['stats']['files_total_count'] || 0 == self::$_state['stats']['tables_total_count']) {
$error = 'Error #3489349834: Made it to the snapshot stage but there are zero files and/or tables. Halting to protect backup integrity. Files: `' . self::$_state['stats']['files_total_count'] . '`. Tables: `' . self::$_state['stats']['tables_total_count'] . '`.';
backupbuddy_core::addNotification('live_error', 'BackupBuddy Stash Live Error', $error);
return $error;
}
if (false !== self::$_state['stats']['manual_snapshot']) {
pb_backupbuddy::status('details', 'Manual snapshot requested at `' . pb_backupbuddy::$format->date(pb_backupbuddy::$format->localize_time(self::$_state['stats']['manual_snapshot'])) . '` (' . pb_backupbuddy::$format->time_ago(self::$_state['stats']['manual_snapshot']) . ' ago). Triggering remote snapshot now.');
$trigger = 'manual';
} else {
$trigger = 'automatic';
$destination_settings = self::get_destination_settings();
$schedule_times = wp_get_schedules();
if (!isset($schedule_times[$destination_settings['remote_snapshot_period']])) {
pb_backupbuddy::status('error', 'Error #383927494: Invalid schedule interval/period `' . $destination_settings['remote_snapshot_period'] . '`. Not found in wp_get_schedules().');
return false;
}
$delay_between_runs = $schedule_times[$destination_settings['remote_snapshot_period']]['interval'];
$adjusted_delay_between_runs = $delay_between_runs - self::REMOTE_SNAPSHOT_PERIOD_WIGGLE_ROOM;
$time_since_last_run = microtime(true) - self::$_state['stats']['last_remote_snapshot'];
pb_backupbuddy::status('details', 'Period between remote snapshots: `' . $destination_settings['remote_snapshot_period'] . '` (`' . $delay_between_runs . '` seconds). Time since last run: `' . $time_since_last_run . '`. Allowed to run `' . self::REMOTE_SNAPSHOT_PERIOD_WIGGLE_ROOM . '` secs early. Adjusted min delay between runs: `' . $adjusted_delay_between_runs . '`.');
if ($time_since_last_run < $adjusted_delay_between_runs) {
pb_backupbuddy::status('details', 'Not enough time has passed since last remote snapshot. Skipping this pass.');
return true;
}
// Made it here so trigger remote snapshot.
pb_backupbuddy::status('details', 'Enough time has passed since last remote snapshot. Triggering remote snapshot now.');
}
$response = backupbuddy_live_periodic::_run_remote_snapshot($trigger);
if (!is_array($response)) {
$error = 'Error #2397734: Unable to initiate Live snapshot. See log above for details or here: `' . $response . '`.';
pb_backupbuddy::status('error', $error);
backupbuddy_core::addNotification('live_error', 'BackupBuddy Stash Live Error', $error);
return false;
} else {
// Either triggered snapshot or one already running.
if (true === $response['success']) {
// Triggered new snapshot.
$snapshot_id = $response['snapshot'];
backupbuddy_live_periodic::update_last_remote_snapshot_time($snapshot_id);
pb_backupbuddy::status('details', 'Triggered new remote snapshot with ID `' . $snapshot_id . '`.');
// TODO: Keeping in place until new tmtrim-settings and passing tmtrim data with snapshot trigger is verified. Deprecating as of 7.0.5.5.
// Schedule to run trim cleanup.
$cronArgs = array();
$schedule_result = backupbuddy_core::schedule_single_event(time() + 60 * 60, 'live_after_snapshot', $cronArgs);
// 1hr
if (true === $schedule_result) {
pb_backupbuddy::status('details', 'Next Live trim cron event scheduled.');
} else {
pb_backupbuddy::status('error', 'Next Live trim cron event FAILED to be scheduled.');
}
if ('1' != pb_backupbuddy::$options['skip_spawn_cron_call']) {
pb_backupbuddy::status('details', 'Spawning cron now.');
update_option('_transient_doing_cron', 0);
// Prevent cron-blocking for next item.
spawn_cron(time() + 150);
// Adds > 60 seconds to get around once per minute cron running limit.
}
return true;
} elseif (false === $response['success']) {
// Failed to trigger new snapshot. Most likely one is already in progress.
if (isset($response['snapshot'])) {
pb_backupbuddy::status('details', 'Did NOT trigger a new snapshot. One is already in progress with ID `' . $response['snapshot'] . '`.');
return true;
} else {
pb_backupbuddy::status('error', 'Error #2898923: Something went wrong triggering snapshot. Details: `' . print_r($response) . '`.');
return false;
}
} else {
pb_backupbuddy::status('error', 'Error #3832792397: Something went wrong triggering snapshot. Details: `' . print_r($response) . '`.');
return false;
}
}
pb_backupbuddy::status('error', 'Error #8028434. This should never happen. This code should not be reached.');
return false;
}