本文整理汇总了PHP中UpdraftPlus_Options::delete_updraft_option方法的典型用法代码示例。如果您正苦于以下问题:PHP UpdraftPlus_Options::delete_updraft_option方法的具体用法?PHP UpdraftPlus_Options::delete_updraft_option怎么用?PHP UpdraftPlus_Options::delete_updraft_option使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UpdraftPlus_Options
的用法示例。
在下文中一共展示了UpdraftPlus_Options::delete_updraft_option方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: die
<?php
if (!defined('UPDRAFTPLUS_DIR')) {
die('No direct access allowed.');
}
require_once UPDRAFTPLUS_DIR . '/methods/s3.php';
# Migrate options to new-style storage - Jan 2014
if (!is_array(UpdraftPlus_Options::get_updraft_option('updraft_s3generic')) && '' != UpdraftPlus_Options::get_updraft_option('updraft_s3generic_login', '')) {
$opts = array('accesskey' => UpdraftPlus_Options::get_updraft_option('updraft_s3generic_login'), 'secretkey' => UpdraftPlus_Options::get_updraft_option('updraft_s3generic_pass'), 'path' => UpdraftPlus_Options::get_updraft_option('updraft_s3generic_remote_path'), 'endpoint' => UpdraftPlus_Options::get_updraft_option('updraft_s3generic_endpoint'));
UpdraftPlus_Options::update_updraft_option('updraft_s3generic', $opts);
UpdraftPlus_Options::delete_updraft_option('updraft_s3generic_login');
UpdraftPlus_Options::delete_updraft_option('updraft_s3generic_pass');
UpdraftPlus_Options::delete_updraft_option('updraft_s3generic_remote_path');
UpdraftPlus_Options::delete_updraft_option('updraft_s3generic_endpoint');
}
class UpdraftPlus_BackupModule_s3generic extends UpdraftPlus_BackupModule_s3
{
protected function set_region($obj, $region = '')
{
$config = $this->get_config();
$endpoint = $region != '' && $region != 'n/a' ? $region : $config['endpoint'];
global $updraftplus;
$updraftplus->log("Set endpoint: {$endpoint}");
$obj->setEndpoint($endpoint);
}
public function get_credentials()
{
return array('updraft_s3generic');
}
function get_config()
{
示例2: restore_configuration_bundle
private function restore_configuration_bundle($table)
{
global $updraftplus;
$updraftplus->log("Restoring prior UD configuration (table: {$table}; keys: " . count($this->configuration_bundle) . ")");
foreach ($this->configuration_bundle as $key => $value) {
UpdraftPlus_Options::delete_updraft_option($key, $value);
UpdraftPlus_Options::update_updraft_option($key, $value);
}
}
示例3: settings_output
//.........这里部分代码省略.........
// This is used by Microsoft OneDrive authorisation failures (May 15). I am not sure what may have been using the 'error' GET parameter otherwise - but it is harmless.
if (!empty($_GET['error_description'])) {
$this->show_admin_warning(htmlspecialchars($_GET['error_description']) . ' (' . htmlspecialchars($_GET['error']) . ')', 'error');
} else {
$this->show_admin_warning(htmlspecialchars($_GET['error']), 'error');
}
}
if (isset($_GET['message'])) {
$this->show_admin_warning(htmlspecialchars($_GET['message']));
}
if (isset($_GET['action']) && $_GET['action'] == 'updraft_create_backup_dir' && isset($_GET['nonce']) && wp_verify_nonce($_GET['nonce'], 'create_backup_dir')) {
$created = $this->create_backup_dir();
if (is_wp_error($created)) {
echo '<p>' . __('Backup directory could not be created', 'updraftplus') . '...<br/>';
echo '<ul class="disc">';
foreach ($created->get_error_messages() as $key => $msg) {
echo '<li>' . htmlspecialchars($msg) . '</li>';
}
echo '</ul></p>';
} elseif ($created !== false) {
echo '<p>' . __('Backup directory successfully created.', 'updraftplus') . '</p><br/>';
}
echo '<b>' . __('Actions', 'updraftplus') . ':</b> <a href="' . UpdraftPlus_Options::admin_page_url() . '?page=updraftplus">' . __('Return to UpdraftPlus Configuration', 'updraftplus') . '</a>';
return;
}
echo '<div id="updraft_backup_started" class="updated updraft-hidden" style="display:none;"></div>';
if (isset($_POST['action']) && 'updraft_backup_debug_all' == $_POST['action']) {
$updraftplus->boot_backup(true, true);
} elseif (isset($_POST['action']) && 'updraft_backup_debug_db' == $_POST['action']) {
$updraftplus->boot_backup(false, true, false, true);
} elseif (isset($_POST['action']) && 'updraft_wipesettings' == $_POST['action']) {
$settings = $updraftplus->get_settings_keys();
foreach ($settings as $s) {
UpdraftPlus_Options::delete_updraft_option($s);
}
// These aren't in get_settings_keys() because they are always in the options table, regardless of context
global $wpdb;
$wpdb->query("DELETE FROM {$wpdb->options} WHERE ( option_name LIKE 'updraftplus_unlocked_%' OR option_name LIKE 'updraftplus_locked_%' OR option_name LIKE 'updraftplus_last_lock_time_%' OR option_name LIKE 'updraftplus_semaphore_%' OR option_name LIKE 'updraft_jobdata_%' OR option_name LIKE 'updraft_last_scheduled_%' )");
$site_options = array('updraft_oneshotnonce');
foreach ($site_options as $s) {
delete_site_option($s);
}
$this->show_admin_warning(__("Your settings have been wiped.", 'updraftplus'));
}
// This opens a div
$this->settings_header();
?>
<div id="updraft-hidethis">
<p>
<strong><?php
_e('Warning:', 'updraftplus');
?>
<?php
_e("If you can still read these words after the page finishes loading, then there is a JavaScript or jQuery problem in the site.", 'updraftplus');
?>
</strong>
<?php
if (false !== strpos(basename(UPDRAFTPLUS_URL), ' ')) {
?>
<strong><?php
_e('The UpdraftPlus directory in wp-content/plugins has white-space in it; WordPress does not like this. You should rename the directory to wp-content/plugins/updraftplus to fix this problem.', 'updraftplus');
?>
</strong>
<?php
示例4: die
// https://www.dropbox.com/developers/apply?cont=/developers/apps
if (!defined('UPDRAFTPLUS_DIR')) {
die('No direct access allowed.');
}
# Converted to job_options: yes
# Converted to array options: yes
# Migrate options to new-style storage - May 2014
# appkey, secret, folder, updraft_dropboxtk_request_token, updraft_dropboxtk_access_token
if (!is_array(UpdraftPlus_Options::get_updraft_option('updraft_dropbox'))) {
$opts = array('appkey' => UpdraftPlus_Options::get_updraft_option('updraft_dropbox_appkey'), 'secret' => UpdraftPlus_Options::get_updraft_option('updraft_dropbox_secret'), 'folder' => UpdraftPlus_Options::get_updraft_option('updraft_dropbox_folder'), 'tk_request_token' => UpdraftPlus_Options::get_updraft_option('updraft_dropboxtk_request_token'), 'tk_access_token' => UpdraftPlus_Options::get_updraft_option('updraft_dropboxtk_access_token'));
UpdraftPlus_Options::update_updraft_option('updraft_dropbox', $opts);
UpdraftPlus_Options::delete_updraft_option('updraft_dropbox_appkey');
UpdraftPlus_Options::delete_updraft_option('updraft_dropbox_secret');
UpdraftPlus_Options::delete_updraft_option('updraft_dropbox_folder');
UpdraftPlus_Options::delete_updraft_option('updraft_dropboxtk_request_token');
UpdraftPlus_Options::delete_updraft_option('updraft_dropboxtk_access_token');
}
class UpdraftPlus_BackupModule_dropbox
{
private $current_file_hash;
private $current_file_size;
private $dropbox_object;
public function chunked_callback($offset, $uploadid, $fullpath = false)
{
global $updraftplus;
// Update upload ID
$updraftplus->jobdata_set('updraf_dbid_' . $this->current_file_hash, $uploadid);
$updraftplus->jobdata_set('updraf_dbof_' . $this->current_file_hash, $offset);
$this->upload_tick = time();
if ($this->current_file_size > 0) {
$percent = round(100 * ($offset / $this->current_file_size), 1);
示例5: die
<?php
if (!defined('UPDRAFTPLUS_DIR')) {
die('No direct access allowed.');
}
# Migrate options to new-style storage - Jan 2014
if (!is_array(UpdraftPlus_Options::get_updraft_option('updraft_s3')) && '' != UpdraftPlus_Options::get_updraft_option('updraft_s3_login', '')) {
$opts = array('accesskey' => UpdraftPlus_Options::get_updraft_option('updraft_s3_login'), 'secretkey' => UpdraftPlus_Options::get_updraft_option('updraft_s3_pass'), 'path' => UpdraftPlus_Options::get_updraft_option('updraft_s3_remote_path'));
UpdraftPlus_Options::update_updraft_option('updraft_s3', $opts);
UpdraftPlus_Options::delete_updraft_option('updraft_s3_login');
UpdraftPlus_Options::delete_updraft_option('updraft_s3_pass');
UpdraftPlus_Options::delete_updraft_option('updraft_s3_remote_path');
}
// This class is used by both UpdraftPlus_S3 and UpdraftPlus_S3_Compat
class UpdraftPlus_S3Exception extends Exception
{
function __construct($message, $file, $line, $code = 0)
{
parent::__construct($message, $code);
$this->file = $file;
$this->line = $line;
}
}
class UpdraftPlus_BackupModule_s3
{
private $s3_object;
private $got_with;
protected function get_config()
{
global $updraftplus;
$opts = $updraftplus->get_job_option('updraft_s3');
示例6: settings_output
public function settings_output()
{
if (false == ($render = apply_filters('updraftplus_settings_page_render', true))) {
do_action('updraftplus_settings_page_render_abort', $render);
return;
}
do_action('updraftplus_settings_page_init');
global $updraftplus;
/*
we use request here because the initial restore is triggered by a POSTed form. we then may need to obtain credentials
for the WP_Filesystem. to do this WP outputs a form, but we don't pass our parameters via that. So the values are
passed back in as GET parameters.
*/
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'updraft_restore' && isset($_REQUEST['backup_timestamp'])) {
$backup_success = $this->restore_backup($_REQUEST['backup_timestamp']);
if (empty($updraftplus->errors) && $backup_success === true) {
// If we restored the database, then that will have out-of-date information which may confuse the user - so automatically re-scan for them.
$this->rebuild_backup_history();
echo '<p><strong>';
$updraftplus->log_e('Restore successful!');
echo '</strong></p>';
$updraftplus->log("Restore successful");
$s_val = 1;
if (!empty($this->entities_to_restore) && is_array($this->entities_to_restore)) {
foreach ($this->entities_to_restore as $k => $v) {
if ('db' != $v) {
$s_val = 2;
}
}
}
$pval = $updraftplus->have_addons ? 1 : 0;
echo '<strong>' . __('Actions', 'updraftplus') . ':</strong> <a href="' . UpdraftPlus_Options::admin_page_url() . '?page=updraftplus&updraft_restore_success=' . $s_val . '&pval=' . $pval . '">' . __('Return to UpdraftPlus Configuration', 'updraftplus') . '</a>';
return;
} elseif (is_wp_error($backup_success)) {
echo '<p>';
$updraftplus->log_e('Restore failed...');
echo '</p>';
$updraftplus->log_wp_error($backup_success);
$updraftplus->log("Restore failed");
$updraftplus->list_errors();
echo '<strong>' . __('Actions', 'updraftplus') . ':</strong> <a href="' . UpdraftPlus_Options::admin_page_url() . '?page=updraftplus">' . __('Return to UpdraftPlus Configuration', 'updraftplus') . '</a>';
return;
} elseif (false === $backup_success) {
# This means, "not yet - but stay on the page because we may be able to do it later, e.g. if the user types in the requested information"
return;
}
}
if (isset($_REQUEST['action']) && 'updraft_delete_old_dirs' == $_REQUEST['action']) {
$nonce = empty($_REQUEST['_wpnonce']) ? "" : $_REQUEST['_wpnonce'];
if (!wp_verify_nonce($nonce, 'updraftplus-credentialtest-nonce')) {
die('Security check');
}
$this->delete_old_dirs_go();
return;
}
if (!empty($_REQUEST['action']) && 'updraftplus_broadcastaction' == $_REQUEST['action'] && !empty($_REQUEST['subaction'])) {
$nonce = empty($_REQUEST['nonce']) ? "" : $_REQUEST['nonce'];
if (!wp_verify_nonce($nonce, 'updraftplus-credentialtest-nonce')) {
die('Security check');
}
do_action($_REQUEST['subaction']);
return;
}
if (isset($_GET['error'])) {
$this->show_admin_warning(htmlspecialchars($_GET['error']), 'error');
}
if (isset($_GET['message'])) {
$this->show_admin_warning(htmlspecialchars($_GET['message']));
}
if (isset($_GET['action']) && $_GET['action'] == 'updraft_create_backup_dir' && isset($_GET['nonce']) && wp_verify_nonce($_GET['nonce'], 'create_backup_dir')) {
$created = $this->create_backup_dir();
if (is_wp_error($created)) {
echo '<p>' . __('Backup directory could not be created', 'updraftplus') . '...<br/>';
echo '<ul style="list-style: disc inside;">';
foreach ($created->get_error_messages() as $key => $msg) {
echo '<li>' . htmlspecialchars($msg) . '</li>';
}
echo '</ul></p>';
} elseif ($created !== false) {
echo '<p>' . __('Backup directory successfully created.', 'updraftplus') . '</p><br/>';
}
echo '<b>' . __('Actions', 'updraftplus') . ':</b> <a href="' . UpdraftPlus_Options::admin_page_url() . '?page=updraftplus">' . __('Return to UpdraftPlus Configuration', 'updraftplus') . '</a>';
return;
}
echo '<div id="updraft_backup_started" class="updated" style="display:none; max-width: 800px; font-size:140%; line-height: 140%; padding:14px; clear:left;"></div>';
if (isset($_POST['action']) && 'updraft_backup_debug_all' == $_POST['action']) {
$updraftplus->boot_backup(true, true);
} elseif (isset($_POST['action']) && 'updraft_backup_debug_db' == $_POST['action']) {
$updraftplus->boot_backup(false, true, false, true);
} elseif (isset($_POST['action']) && 'updraft_wipesettings' == $_POST['action']) {
$settings = $this->get_settings_keys();
foreach ($settings as $s) {
UpdraftPlus_Options::delete_updraft_option($s);
}
# These aren't in get_settings_keys() because they are always in the options table, regardless of context
global $wpdb;
$wpdb->query("DELETE FROM {$wpdb->options} WHERE ( option_name LIKE 'updraftplus_unlocked_%' OR option_name LIKE 'updraftplus_locked_%' OR option_name LIKE 'updraftplus_last_lock_time_%' OR option_name LIKE 'updraftplus_semaphore_%')");
$site_options = array('updraft_oneshotnonce');
foreach ($site_options as $s) {
delete_site_option($s);
//.........这里部分代码省略.........
示例7: die
<?php
if (!defined('UPDRAFTPLUS_DIR')) {
die('No direct access allowed.');
}
# Converted to array options: yes
# Converted to job_options: yes
# Migrate options to new-style storage - May 2014
if (!is_array(UpdraftPlus_Options::get_updraft_option('updraft_ftp')) && '' != UpdraftPlus_Options::get_updraft_option('updraft_server_address', '')) {
$opts = array('user' => UpdraftPlus_Options::get_updraft_option('updraft_ftp_login'), 'pass' => UpdraftPlus_Options::get_updraft_option('updraft_ftp_pass'), 'host' => UpdraftPlus_Options::get_updraft_option('updraft_server_address'), 'path' => UpdraftPlus_Options::get_updraft_option('updraft_ftp_remote_path'), 'passive' => true);
UpdraftPlus_Options::update_updraft_option('updraft_ftp', $opts);
UpdraftPlus_Options::delete_updraft_option('updraft_server_address');
UpdraftPlus_Options::delete_updraft_option('updraft_ftp_pass');
UpdraftPlus_Options::delete_updraft_option('updraft_ftp_remote_path');
UpdraftPlus_Options::delete_updraft_option('updraft_ftp_login');
}
class UpdraftPlus_BackupModule_ftp
{
// Get FTP object with parameters set
private function getFTP($server, $user, $pass, $disable_ssl = false, $disable_verify = true, $use_server_certs = false, $passive = true)
{
if ('' == trim($server) || '' == trim($user) || '' == trim($pass)) {
return new WP_Error('no_settings', sprintf(__('No %s settings were found', 'updraftplus'), 'FTP'));
}
if (!class_exists('UpdraftPlus_ftp_wrapper')) {
require_once UPDRAFTPLUS_DIR . '/includes/ftp.class.php';
}
$port = 21;
if (preg_match('/^(.*):(\\d+)$/', $server, $matches)) {
$server = $matches[1];
$port = $matches[2];
示例8: die
<?php
if (!defined('UPDRAFTPLUS_DIR')) {
die('No direct access allowed.');
}
require_once UPDRAFTPLUS_DIR . '/methods/s3.php';
# Migrate options to new-style storage - Jan 2014
if (!is_array(UpdraftPlus_Options::get_updraft_option('updraft_dreamobjects')) && '' != UpdraftPlus_Options::get_updraft_option('updraft_dreamobjects_login', '')) {
$opts = array('accesskey' => UpdraftPlus_Options::get_updraft_option('updraft_dreamobjects_login'), 'secretkey' => UpdraftPlus_Options::get_updraft_option('updraft_dreamobjects_pass'), 'path' => UpdraftPlus_Options::get_updraft_option('updraft_dreamobjects_remote_path'));
UpdraftPlus_Options::update_updraft_option('updraft_dreamobjects', $opts);
UpdraftPlus_Options::delete_updraft_option('updraft_dreamobjects_login');
UpdraftPlus_Options::delete_updraft_option('updraft_dreamobjects_pass');
UpdraftPlus_Options::delete_updraft_option('updraft_dreamobjects_remote_path');
}
class UpdraftPlus_BackupModule_dreamobjects extends UpdraftPlus_BackupModule_s3
{
protected function set_region($obj, $region, $bucket_name = '')
{
$config = $this->get_config();
global $updraftplus;
$updraftplus->log("Set endpoint: " . $config['endpoint']);
$obj->setEndpoint($config['endpoint']);
}
public function get_credentials()
{
return array('updraft_dreamobjects');
}
protected function get_config()
{
global $updraftplus;
$opts = $updraftplus->get_job_option('updraft_dreamobjects');
示例9: settings_output
public function settings_output()
{
if (false == ($render = apply_filters('updraftplus_settings_page_render', true))) {
do_action('updraftplus_settings_page_render_abort', $render);
return;
}
do_action('updraftplus_settings_page_init');
global $updraftplus;
/*
we use request here because the initial restore is triggered by a POSTed form. we then may need to obtain credentials
for the WP_Filesystem. to do this WP outputs a form, but we don't pass our parameters via that. So the values are
passed back in as GET parameters.
*/
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'updraft_restore' && isset($_REQUEST['backup_timestamp'])) {
$backup_success = $this->restore_backup($_REQUEST['backup_timestamp']);
if (empty($updraftplus->errors) && $backup_success === true) {
// If we restored the database, then that will have out-of-date information which may confuse the user - so automatically re-scan for them.
$this->rebuild_backup_history();
echo '<p><strong>';
$updraftplus->log_e('Restore successful!');
echo '</strong></p>';
$updraftplus->log("Restore successful");
$s_val = 1;
if (!empty($this->entities_to_restore) && is_array($this->entities_to_restore)) {
foreach ($this->entities_to_restore as $k => $v) {
if ('db' != $v) {
$s_val = 2;
}
}
}
echo '<strong>' . __('Actions', 'updraftplus') . ':</strong> <a href="' . UpdraftPlus_Options::admin_page_url() . '?page=updraftplus&updraft_restore_success=' . $s_val . '">' . __('Return to UpdraftPlus Configuration', 'updraftplus') . '</a>';
return;
} elseif (is_wp_error($backup_success)) {
echo '<p>';
$updraftplus->log_e('Restore failed...');
echo '</p>';
$updraftplus->log_wp_error($backup_success);
$updraftplus->log("Restore failed");
$updraftplus->list_errors();
echo '<strong>' . __('Actions', 'updraftplus') . ':</strong> <a href="' . UpdraftPlus_Options::admin_page_url() . '?page=updraftplus">' . __('Return to UpdraftPlus Configuration', 'updraftplus') . '</a>';
return;
} elseif (false === $backup_success) {
# This means, "not yet - but stay on the page because we may be able to do it later, e.g. if the user types in the requested information"
return;
}
}
if (isset($_REQUEST['action']) && 'updraft_delete_old_dirs' == $_REQUEST['action']) {
$nonce = empty($_REQUEST['_wpnonce']) ? "" : $_REQUEST['_wpnonce'];
if (!wp_verify_nonce($nonce, 'updraftplus-credentialtest-nonce')) {
die('Security check');
}
$this->delete_old_dirs_go();
return;
}
if (!empty($_REQUEST['action']) && 'updraftplus_broadcastaction' == $_REQUEST['action'] && !empty($_REQUEST['subaction'])) {
$nonce = empty($_REQUEST['nonce']) ? "" : $_REQUEST['nonce'];
if (!wp_verify_nonce($nonce, 'updraftplus-credentialtest-nonce')) {
die('Security check');
}
do_action($_REQUEST['subaction']);
return;
}
if (isset($_GET['error'])) {
$this->show_admin_warning(htmlspecialchars($_GET['error']), 'error');
}
if (isset($_GET['message'])) {
$this->show_admin_warning(htmlspecialchars($_GET['message']));
}
if (isset($_GET['action']) && $_GET['action'] == 'updraft_create_backup_dir' && isset($_GET['nonce']) && wp_verify_nonce($_GET['nonce'], 'create_backup_dir')) {
$created = $this->create_backup_dir();
if (is_wp_error($created)) {
echo '<p>' . __('Backup directory could not be created', 'updraftplus') . '...<br/>';
echo '<ul style="list-style: disc inside;">';
foreach ($created->get_error_messages() as $key => $msg) {
echo '<li>' . htmlspecialchars($msg) . '</li>';
}
echo '</ul></p>';
} elseif ($created !== false) {
echo '<p>' . __('Backup directory successfully created.', 'updraftplus') . '</p><br/>';
}
echo '<b>' . __('Actions', 'updraftplus') . ':</b> <a href="' . UpdraftPlus_Options::admin_page_url() . '?page=updraftplus">' . __('Return to UpdraftPlus Configuration', 'updraftplus') . '</a>';
return;
}
echo '<div id="updraft_backup_started" class="updated fade" style="display:none; max-width: 800px; font-size:140%; line-height: 140%; padding:14px; clear:left;"></div>';
if (isset($_POST['action']) && 'updraft_backup_debug_all' == $_POST['action']) {
$updraftplus->boot_backup(true, true);
} elseif (isset($_POST['action']) && 'updraft_backup_debug_db' == $_POST['action']) {
$updraftplus->boot_backup(false, true, false, true);
} elseif (isset($_POST['action']) && 'updraft_wipesettings' == $_POST['action']) {
$settings = $this->get_settings_keys();
foreach ($settings as $s) {
UpdraftPlus_Options::delete_updraft_option($s);
}
# These aren't in get_settings_keys() because they are always in the options table, regardless of context
global $wpdb;
$wpdb->query("DELETE FROM {$wpdb->options} WHERE ( option_name LIKE 'updraftplus_unlocked_%' OR option_name LIKE 'updraftplus_locked_%' OR option_name LIKE 'updraftplus_last_lock_time_%' OR option_name LIKE 'updraftplus_semaphore_%')");
$site_options = array('updraft_oneshotnonce');
foreach ($site_options as $s) {
delete_site_option($s);
}
//.........这里部分代码省略.........
示例10: array
# Converted to job_options: yes
# Converted to array options: yes
# Migrate options to new-style storage - Apr 2014
# clientid, secret, remotepath
if (!is_array(UpdraftPlus_Options::get_updraft_option('updraft_googledrive')) && '' != UpdraftPlus_Options::get_updraft_option('updraft_googledrive_clientid', '')) {
$opts = array('clientid' => UpdraftPlus_Options::get_updraft_option('updraft_googledrive_clientid'), 'secret' => UpdraftPlus_Options::get_updraft_option('updraft_googledrive_secret'), 'parentid' => UpdraftPlus_Options::get_updraft_option('updraft_googledrive_remotepath'), 'token' => UpdraftPlus_Options::get_updraft_option('updraft_googledrive_token'));
$tmp = UpdraftPlus_Options::get_updraft_option('updraftplus_tmp_access_token');
if (!empty($tmp)) {
$opts['tmp_access_token'] = $tmp;
}
UpdraftPlus_Options::update_updraft_option('updraft_googledrive', $opts);
UpdraftPlus_Options::delete_updraft_option('updraft_googledrive_clientid');
UpdraftPlus_Options::delete_updraft_option('updraft_googledrive_secret');
UpdraftPlus_Options::delete_updraft_option('updraft_googledrive_remotepath');
UpdraftPlus_Options::delete_updraft_option('updraft_googledrive_token');
UpdraftPlus_Options::delete_updraft_option('updraftplus_tmp_access_token');
}
class UpdraftPlus_BackupModule_googledrive
{
private $service;
private $client;
private $ids_from_paths;
public function action_auth()
{
if (isset($_GET['state'])) {
if ('success' == $_GET['state']) {
add_action('all_admin_notices', array($this, 'show_authed_admin_success'));
} elseif ('token' == $_GET['state']) {
$this->gdrive_auth_token();
} elseif ('revoke' == $_GET['state']) {
$this->gdrive_auth_revoke();
示例11: schedule_event
public function schedule_event($event)
{
static $scheduled = array();
if ('updraft_backup' == $event->hook || 'updraft_backup_database' == $event->hook) {
// Reset the option - but make sure it is saved first so that we can used it (since this hook may be called just before our actual cron task)
$this->combine_jobs_around = UpdraftPlus_Options::get_updraft_option('updraft_combine_jobs_around');
UpdraftPlus_Options::delete_updraft_option('updraft_combine_jobs_around');
$scheduled[$event->hook] = true;
// This next fragment is wrong: there's only a 'second call' when saving all settings; otherwise, the WP scheduler might just be updating one event. So, there's some inefficieny as the option is wiped and set uselessly at least once when saving settings.
// We only want to take action on the second call (otherwise, our information is out-of-date already)
// If there is no second call, then that's fine - nothing to do
//if (count($scheduled) < 2) {
// return $event;
//}
$backup_scheduled_for = 'updraft_backup' == $event->hook ? $event->timestamp : wp_next_scheduled('updraft_backup');
$db_scheduled_for = 'updraft_backup_database' == $event->hook ? $event->timestamp : wp_next_scheduled('updraft_backup_database');
$diff = absint($backup_scheduled_for - $db_scheduled_for);
$margin = defined('UPDRAFTPLUS_COMBINE_MARGIN') && is_numeric(UPDRAFTPLUS_COMBINE_MARGIN) ? UPDRAFTPLUS_COMBINE_MARGIN : 600;
if ($backup_scheduled_for && $db_scheduled_for && $diff < $margin) {
// We could change the event parameters; however, this would complicate other code paths (because the WP cron system uses a hash of the parameters as a key, and you must supply the exact parameters to look up events). So, we just set a marker that boot_backup() can pick up on.
UpdraftPlus_Options::update_updraft_option('updraft_combine_jobs_around', min($backup_scheduled_for, $db_scheduled_for));
}
}
return $event;
}
示例12: settings_output
public function settings_output()
{
global $updraftplus;
wp_enqueue_style('jquery-ui', UPDRAFTPLUS_URL . '/includes/jquery-ui-1.8.22.custom.css');
/*
we use request here because the initial restore is triggered by a POSTed form. we then may need to obtain credentials
for the WP_Filesystem. to do this WP outputs a form, but we don't pass our parameters via that. So the values are
passed back in as GET parameters. REQUEST covers both GET and POST so this logic works.
*/
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'updraft_restore' && isset($_REQUEST['backup_timestamp'])) {
$backup_success = $this->restore_backup($_REQUEST['backup_timestamp']);
if (empty($updraftplus->errors) && $backup_success === true) {
// If we restored the database, then that will have out-of-date information which may confuse the user - so automatically re-scan for them.
$this->rebuild_backup_history();
echo '<p><strong>';
$updraftplus->log_e('Restore successful!');
echo '</strong></p>';
$updraftplus->log("Restore successful");
echo '<strong>' . __('Actions', 'updraftplus') . ':</strong> <a href="' . UpdraftPlus_Options::admin_page_url() . '?page=updraftplus&updraft_restore_success=true">' . __('Return to UpdraftPlus Configuration', 'updraftplus') . '</a>';
return;
} elseif (is_wp_error($backup_success)) {
echo '<p>';
$updraftplus->log_e('Restore failed...');
echo '</p>';
$updraftplus->log_wp_error($backup_success);
$updraftplus->log("Restore failed");
$updraftplus->list_errors();
echo '<strong>' . __('Actions', 'updraftplus') . ':</strong> <a href="' . UpdraftPlus_Options::admin_page_url() . '?page=updraftplus">' . __('Return to UpdraftPlus Configuration', 'updraftplus') . '</a>';
return;
} elseif (false === $backup_success) {
# This means, "not yet - but stay on the page because we may be able to do it later, e.g. if the user types in the requested information"
return;
}
}
if (isset($_REQUEST['action']) && 'updraft_delete_old_dirs' == $_REQUEST['action']) {
$nonce = empty($_REQUEST['_wpnonce']) ? "" : $_REQUEST['_wpnonce'];
if (!wp_verify_nonce($nonce, 'updraftplus-credentialtest-nonce')) {
die('Security check');
}
$this->delete_old_dirs_go();
return;
}
if (isset($_GET['error'])) {
$this->show_admin_warning(htmlspecialchars($_GET['error']), 'error');
}
if (isset($_GET['message'])) {
$this->show_admin_warning(htmlspecialchars($_GET['message']));
}
if (isset($_GET['action']) && $_GET['action'] == 'updraft_create_backup_dir' && isset($_GET['nonce']) && wp_verify_nonce($_GET['nonce'], 'create_backup_dir')) {
$created = $this->create_backup_dir();
if (is_wp_error($created)) {
echo '<p>' . __('Backup directory could not be created', 'updraftplus') . '...<br/>';
echo '<ul style="list-style: disc inside;">';
foreach ($created->get_error_messages() as $key => $msg) {
echo '<li>' . htmlspecialchars($msg) . '</li>';
}
echo '</ul></p>';
} elseif ($created !== false) {
echo '<p>' . __('Backup directory successfully created.', 'updraftplus') . '</p><br/>';
}
echo '<b>' . __('Actions', 'updraftplus') . ':</b> <a href="' . UpdraftPlus_Options::admin_page_url() . '?page=updraftplus">' . __('Return to UpdraftPlus Configuration', 'updraftplus') . '</a>';
return;
}
do_action('updraftplus_settings_page_init');
echo '<div id="updraft_backup_started" class="updated fade" style="display:none; max-width: 800px; font-size:140%; line-height: 140%; padding:14px; clear:left;"></div>';
// updraft_file_ids is not deleted
if (isset($_POST['action']) && $_POST['action'] == 'updraft_backup_debug_all') {
$updraftplus->boot_backup(true, true);
} elseif (isset($_POST['action']) && $_POST['action'] == 'updraft_backup_debug_db') {
$updraftplus->boot_backup(false, true, false, true);
// global $updraftplus_backup;
// if (!is_a($updraftplus_backup, 'UpdraftPlus_Backup')) require_once(UPDRAFTPLUS_DIR.'/backup.php');
// $updraftplus_backup->backup_db();
} elseif (isset($_POST['action']) && $_POST['action'] == 'updraft_wipesettings') {
$settings = $this->get_settings_keys();
foreach ($settings as $s) {
UpdraftPlus_Options::delete_updraft_option($s);
}
$site_options = array('updraft_oneshotnonce');
foreach ($site_options as $s) {
delete_site_option($s);
}
$this->show_admin_warning(__("Your settings have been wiped.", 'updraftplus'));
}
?>
<div class="wrap" id="updraft-wrap">
<h1><?php
echo $updraftplus->plugin_title;
?>
</h1>
<?php
_e('By UpdraftPlus.Com', 'updraftplus');
?>
( <a href="http://updraftplus.com">UpdraftPlus.Com</a> | <a href="http://updraftplus.com/news/"><?php
_e('News', 'updraftplus');
?>
</a> | <?php
if (!defined('UPDRAFTPLUS_NOADS_A')) {
?>
//.........这里部分代码省略.........
示例13: show_authed_admin_success
public static function show_authed_admin_success()
{
global $updraftplus_admin;
$updraftplus_tmp_access_token = UpdraftPlus_Options::get_updraft_option('updraftplus_tmp_googledrive_access_token');
if (empty($updraftplus_tmp_access_token)) {
return;
}
$message = '';
try {
if (!class_exists('UpdraftPlus_GDocs')) {
require_once UPDRAFTPLUS_DIR . '/includes/class-gdocs.php';
}
$x = new UpdraftPlus_BackupModule_googledrive();
if (!is_wp_error($e = $x->need_gdocs($updraftplus_tmp_access_token))) {
$quota_total = max($x->gdocs->get_quota_total(), 1);
$quota_used = $x->gdocs->get_quota_used();
if (is_numeric($quota_total) && is_numeric($quota_used)) {
$available_quota = $quota_total - $quota_used;
$used_perc = round($quota_used * 100 / $quota_total, 1);
$message .= sprintf(__('Your %s quota usage: %s %% used, %s available', 'updraftplus'), 'Google Drive', $used_perc, round($available_quota / 1048576, 1) . ' Mb');
}
}
} catch (Exception $e) {
}
$updraftplus_admin->show_admin_warning(__('Success', 'updraftplus') . ': ' . sprintf(__('you have authenticated your %s account.', 'updraftplus'), __('Google Drive', 'updraftplus')) . ' ' . $message);
UpdraftPlus_Options::delete_updraft_option('updraftplus_tmp_googledrive_access_token');
}
示例14: settings_output
function settings_output()
{
global $updraftplus;
wp_enqueue_style('jquery-ui', UPDRAFTPLUS_URL . '/includes/jquery-ui-1.8.22.custom.css');
/*
we use request here because the initial restore is triggered by a POSTed form. we then may need to obtain credentials
for the WP_Filesystem. to do this WP outputs a form, but we don't pass our parameters via that. So the values are
passed back in as GET parameters. REQUEST covers both GET and POST so this logic works.
*/
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'updraft_restore' && isset($_REQUEST['backup_timestamp'])) {
$backup_success = $this->restore_backup($_REQUEST['backup_timestamp']);
if (empty($updraftplus->errors) && $backup_success === true) {
// If we restored the database, then that will have out-of-date information which may confuse the user - so automatically re-scan for them.
$this->rebuild_backup_history();
echo '<p><strong>' . __('Restore successful!', 'updraftplus') . '</strong></p>';
echo '<b>' . __('Actions', 'updraftplus') . ':</b> <a href="options-general.php?page=updraftplus&updraft_restore_success=true">' . __('Return to UpdraftPlus Configuration', 'updraftplus') . '</a>';
return;
} elseif (is_wp_error($backup_success)) {
echo '<p>Restore failed...</p><ul style="list-style: disc inside;">';
foreach ($updraftplus->errors as $err) {
if (is_wp_error($err)) {
foreach ($err->get_error_messages() as $msg) {
echo '<li>' . htmlspecialchars($msg) . '<li>';
}
} elseif (is_string($err)) {
echo "<li>" . htmlspecialchars($err) . "</li>";
} else {
print "<li>" . print_r($err, true) . "</li>";
}
}
echo '</ul><b>Actions:</b> <a href="options-general.php?page=updraftplus">' . __('Return to UpdraftPlus Configuration', 'updraftplus') . '</a>';
return;
} elseif (false === $backup_success) {
# This means, "not yet - but stay on the page because we may be able to do it later, e.g. if the user types in the requested information"
return;
}
//uncomment the below once i figure out how i want the flow of a restoration to work.
//echo '<b>'__('Actions','updraftplus').':</b> <a href="options-general.php?page=updraftplus">Return to UpdraftPlus Configuration</a>';
}
$deleted_old_dirs = false;
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'updraft_delete_old_dirs') {
echo '<h1>UpdraftPlus - ' . __('Remove old directories', 'updraftplus') . '</h1>';
$nonce = empty($_REQUEST['_wpnonce']) ? "" : $_REQUEST['_wpnonce'];
if (!wp_verify_nonce($nonce, 'updraft_delete_old_dirs')) {
die('Security check');
}
if ($this->delete_old_dirs()) {
echo '<p>' . __('Old directories successfully removed.', 'updraftplus') . '</p><br/>';
$deleted_old_dirs = true;
} else {
echo '<p>', __('Old directory removal failed for some reason. You may want to do this manually.', 'updraftplus') . '</p><br/>';
}
echo '<b>' . __('Actions', 'updraftplus') . ':</b> <a href="options-general.php?page=updraftplus">' . __('Return to UpdraftPlus Configuration', 'updraftplus') . '</a>';
return;
}
if (isset($_GET['error'])) {
$this->show_admin_warning(htmlspecialchars($_GET['error']), 'error');
}
if (isset($_GET['message'])) {
$this->show_admin_warning(htmlspecialchars($_GET['message']));
}
if (isset($_GET['action']) && $_GET['action'] == 'updraft_create_backup_dir' && isset($_GET['nonce']) && wp_verify_nonce($_GET['nonce'], 'create_backup_dir')) {
$created = $this->create_backup_dir();
if (is_wp_error($created)) {
echo '<p>' . __('Backup directory could not be created', 'updraftplus') . '...<br/>';
echo '<ul style="list-style: disc inside;">';
foreach ($created->get_error_messages() as $key => $msg) {
echo '<li>' . htmlspecialchars($msg) . '</li>';
}
echo '</ul></p>';
} elseif ($created !== false) {
echo '<p>' . __('Backup directory successfully created.', 'updraftplus') . '</p><br/>';
}
echo '<b>' . __('Actions', 'updraftplus') . ':</b> <a href="options-general.php?page=updraftplus">' . __('Return to UpdraftPlus Configuration', 'updraftplus') . '</a>';
return;
}
echo '<div id="updraft_backup_started" class="updated fade" style="display:none; max-width: 800px; font-size:140%; line-height: 140%; padding:14px; clear:left;"></div>';
// updraft_file_ids is not deleted
if (isset($_POST['action']) && $_POST['action'] == 'updraft_backup_debug_all') {
$updraftplus->boot_backup(true, true);
} elseif (isset($_POST['action']) && $_POST['action'] == 'updraft_backup_debug_db') {
$updraftplus->backup_db();
} elseif (isset($_POST['action']) && $_POST['action'] == 'updraft_wipesettings') {
$settings = array('updraft_interval', 'updraft_interval_database', 'updraft_retain', 'updraft_retain_db', 'updraft_encryptionphrase', 'updraft_service', 'updraft_dropbox_appkey', 'updraft_dropbox_secret', 'updraft_googledrive_clientid', 'updraft_googledrive_secret', 'updraft_googledrive_remotepath', 'updraft_ftp_login', 'updraft_ftp_pass', 'updraft_ftp_remote_path', 'updraft_server_address', 'updraft_dir', 'updraft_email', 'updraft_delete_local', 'updraft_debug_mode', 'updraft_include_plugins', 'updraft_include_themes', 'updraft_include_uploads', 'updraft_include_others', 'updraft_include_wpcore', 'updraft_include_wpcore_exclude', 'updraft_include_more', 'updraft_include_blogs', 'updraft_include_mu-plugins', 'updraft_include_others_exclude', 'updraft_lastmessage', 'updraft_googledrive_clientid', 'updraft_googledrive_token', 'updraft_dropboxtk_request_token', 'updraft_dropboxtk_access_token', 'updraft_dropbox_folder', 'updraft_last_backup', 'updraft_starttime_files', 'updraft_starttime_db', 'updraft_sftp_settings', 'updraft_s3generic_login', 'updraft_s3generic_pass', 'updraft_s3generic_remote_path', 'updraft_s3generic_endpoint', 'updraft_webdav_settings', 'updraft_disable_ping', 'updraft_cloudfiles_user', 'updraft_cloudfiles_apikey', 'updraft_cloudfiles_path', 'updraft_cloudfiles_authurl', 'updraft_ssl_useservercerts', 'updraft_ssl_disableverify', 'updraft_s3_login', 'updraft_s3_pass', 'updraft_s3_remote_path', 'updraft_dreamobjects_login', 'updraft_dreamobjects_pass', 'updraft_dreamobjects_remote_path');
foreach ($settings as $s) {
UpdraftPlus_Options::delete_updraft_option($s);
}
$this->show_admin_warning(__("Your settings have been wiped.", 'updraftplus'));
}
?>
<div class="wrap">
<h1><?php
echo $updraftplus->plugin_title;
?>
</h1>
<?php
_e('By UpdraftPlus.Com', 'updraftplus');
?>
( <a href="http://updraftplus.com">UpdraftPlus.Com</a> | <a href="http://updraftplus.com/news/"><?php
//.........这里部分代码省略.........
示例15: delete
/**
* Delete the request and access tokens currently stored in the database
* @return bool
*/
public function delete()
{
UpdraftPlus_Options::delete_updraft_option($this->option_name_prefix . 'request_token');
UpdraftPlus_Options::delete_updraft_option($this->option_name_prefix . 'access_token');
return true;
}