本文整理汇总了PHP中UpdraftPlus_Options::get_updraft_option方法的典型用法代码示例。如果您正苦于以下问题:PHP UpdraftPlus_Options::get_updraft_option方法的具体用法?PHP UpdraftPlus_Options::get_updraft_option怎么用?PHP UpdraftPlus_Options::get_updraft_option使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UpdraftPlus_Options
的用法示例。
在下文中一共展示了UpdraftPlus_Options::get_updraft_option方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: change_path
public static function change_path($file)
{
$opts = UpdraftPlus_Options::get_updraft_option('updraft_dropbox');
$folder = empty($opts['folder']) ? '' : $opts['folder'];
$dropbox_folder = trailingslashit($folder);
return $dropbox_folder == '/' || $dropbox_folder == './' ? $file : $dropbox_folder . $file;
}
示例2: get_service
public function get_service($opts, $useservercerts = false, $disablesslverify = null)
{
$user = $opts['user'];
$apikey = $opts['apikey'];
$authurl = $opts['authurl'];
$region = !empty($opts['region']) ? $opts['region'] : null;
require_once UPDRAFTPLUS_DIR . '/vendor/autoload.php';
global $updraftplus;
# The new authentication APIs don't match the values we were storing before
$new_authurl = 'https://lon.auth.api.rackspacecloud.com' == $authurl || 'uk' == $authurl ? Rackspace::UK_IDENTITY_ENDPOINT : Rackspace::US_IDENTITY_ENDPOINT;
if (null === $disablesslverify) {
$disablesslverify = UpdraftPlus_Options::get_updraft_option('updraft_ssl_disableverify');
}
if (empty($user) || empty($apikey)) {
throw new Exception(__('Authorisation failed (check your credentials)', 'updraftplus'));
}
$updraftplus->log("Cloud Files authentication URL: " . $new_authurl);
$client = new Rackspace($new_authurl, array('username' => $user, 'apiKey' => $apikey));
$this->client = $client;
if ($disablesslverify) {
$client->setSslVerification(false);
} else {
if ($useservercerts) {
$client->setConfig(array($client::SSL_CERT_AUTHORITY, 'system'));
} else {
$client->setSslVerification(UPDRAFTPLUS_DIR . '/includes/cacert.pem', true, 2);
}
}
return $client->objectStoreService('cloudFiles', $region);
}
示例3: delete
/**
* Delete the request and access tokens currently stored in the database
* @return bool
*/
public function delete()
{
$opts = UpdraftPlus_Options::get_updraft_option($this->option_array);
$opts[$this->option_name_prefix . 'request_token'] = '';
$opts[$this->option_name_prefix . 'access_token'] = '';
UpdraftPlus_Options::update_updraft_option($this->option_array, $opts);
return true;
}
示例4: get
/**
* Get an OAuth token from the database
* If the encryption object is set then decrypt the token before returning
* @param string $type Token type to retrieve
* @return array|bool
*/
public function get($type)
{
if ($type != 'request_token' && $type != 'access_token') {
throw new Dropbox_Exception("Expected a type of either 'request_token' or 'access_token', got '{$type}'");
} else {
if (false !== ($gettoken = UpdraftPlus_Options::get_updraft_option($this->option_name_prefix . $type))) {
$token = $this->decrypt($gettoken);
return $token;
}
return false;
}
}
示例5: get_service
public function get_service($opts, $useservercerts = false, $disablesslverify = null)
{
# 'tenant', 'user', 'password', 'authurl', 'path', (optional) 'region'
extract($opts);
if (null === $disablesslverify) {
$disablesslverify = UpdraftPlus_Options::get_updraft_option('updraft_ssl_disableverify');
}
if (empty($user) || empty($password) || empty($authurl)) {
throw new Exception(__('Authorisation failed (check your credentials)', 'updraftplus'));
}
require_once UPDRAFTPLUS_DIR . '/oc/autoload.php';
global $updraftplus;
$updraftplus->log("OpenStack authentication URL: " . $authurl);
$client = new OpenStack($authurl, array('username' => $user, 'password' => $password, 'tenantName' => $tenant));
$this->client = $client;
if ($disablesslverify) {
$client->setSslVerification(false);
} else {
if ($useservercerts) {
$client->setConfig(array($client::SSL_CERT_AUTHORITY => false));
} else {
$client->setSslVerification(UPDRAFTPLUS_DIR . '/includes/cacert.pem', true, 2);
}
}
$client->authenticate();
if (empty($region)) {
$catalog = $client->getCatalog();
if (!empty($catalog)) {
$items = $catalog->getItems();
if (is_array($items)) {
foreach ($items as $item) {
$name = $item->getName();
$type = $item->getType();
if ('swift' != $name || 'object-store' != $type) {
continue;
}
$eps = $item->getEndpoints();
if (!is_array($eps)) {
continue;
}
foreach ($eps as $ep) {
if (is_object($ep) && !empty($ep->region)) {
$region = $ep->region;
}
}
}
}
}
}
$this->region = $region;
return $client->objectStoreService('swift', $region);
}
示例6: backup
function backup($backup_array)
{
global $updraftplus;
$updraft_dir = $updraftplus->backups_dir_location() . '/';
foreach ($backup_array as $type => $file) {
$fullpath = $updraft_dir . $file;
foreach (explode(',', UpdraftPlus_Options::get_updraft_option('updraft_email')) as $sendmail_addr) {
wp_mail(trim($sendmail_addr), __("WordPress Backup", 'updraftplus') . " " . date('Y-m-d H:i', $updraftplus->backup_time), __("Backup is of:", 'updraftplus') . " " . $type . ". " . __('Be wary; email backups may fail because of file size limitations on mail servers.', 'updraftplus'), null, array($fullpath));
}
$updraftplus->uploaded_file($file);
}
$updraftplus->prune_retained_backups("email", null, null);
}
示例7: backup
public function backup($backup_array)
{
global $updraftplus, $updraftplus_backup;
$updraft_dir = trailingslashit($updraftplus->backups_dir_location());
$email = $updraftplus->just_one_email(UpdraftPlus_Options::get_updraft_option('updraft_email'), true);
if (!is_array($email)) {
$email = array($email);
}
foreach ($backup_array as $type => $file) {
$descrip_type = preg_match('/^(.*)\\d+$/', $type, $matches) ? $matches[1] : $type;
$fullpath = $updraft_dir . $file;
if (file_exists($fullpath) && filesize($fullpath) > UPDRAFTPLUS_WARN_EMAIL_SIZE) {
$size_in_mb_of_big_file = round(filesize($fullpath) / 1048576, 1);
$toobig_hash = md5($file);
$updraftplus->log($file . ': ' . sprintf(__('This backup archive is %s Mb in size - the attempt to send this via email is likely to fail (few email servers allow attachments of this size). If so, you should switch to using a different remote storage method.', 'updraftplus'), $size_in_mb_of_big_file), 'warning', 'toobigforemail_' . $toobig_hash);
}
$any_attempted = false;
$any_sent = false;
foreach ($email as $ind => $addr) {
if (!apply_filters('updraftplus_email_wholebackup', true, $addr, $ind, $type)) {
continue;
}
foreach (explode(',', $addr) as $sendmail_addr) {
$send_short = strlen($sendmail_addr) > 5 ? substr($sendmail_addr, 0, 5) . '...' : $sendmail_addr;
$updraftplus->log("{$file}: email to: {$send_short}");
$any_attempted = true;
$subject = __("WordPress Backup", 'updraftplus') . ': ' . get_bloginfo('name') . ' (UpdraftPlus ' . $updraftplus->version . ') ' . get_date_from_gmt(gmdate('Y-m-d H:i:s', $updraftplus->backup_time), 'Y-m-d H:i');
$sent = wp_mail(trim($sendmail_addr), $subject, sprintf(__("Backup is of: %s.", 'updraftplus'), site_url() . ' (' . $descrip_type . ')'), null, array($fullpath));
if ($sent) {
$any_sent = true;
}
}
}
if ($any_sent) {
if (isset($toobig_hash)) {
$updraftplus->log_removewarning('toobigforemail_' . $toobig_hash);
// Don't leave it still set for the next archive
unset($toobig_hash);
}
$updraftplus->uploaded_file($file);
} elseif ($any_attempted) {
$updraftplus->log('Mails were not sent successfully');
$updraftplus->log(__('The attempt to send the backup via email failed (probably the backup was too large for this method)', 'updraftplus'), 'error');
} else {
$updraftplus->log('No email addresses were configured to send to');
}
}
return null;
}
示例8: get_opts
private function get_opts()
{
$this->opts = UpdraftPlus_Options::get_updraft_option('updraft_adminlocking');
if (!is_array($this->opts)) {
$this->opts = array();
}
if (!isset($this->opts['password'])) {
$this->opts['password'] = '';
}
if (!isset($this->opts['session_length'])) {
$this->opts['session_length'] = 3600;
}
if (!isset($this->opts['support_url'])) {
$this->opts['support_url'] = '';
}
}
示例9: getBackupsData
public function getBackupsData()
{
$backup_list = UpdraftPlus_Options::get_updraft_option('updraft_backup_history');
if (empty($backup_list)) {
return;
}
$backups = array();
foreach ($backup_list as $timestamp => $backups_info) {
$time_mm = strtotime("-{$this->last_months} month");
// If date more than 1 month - skip it
if (date('Y-m-d', $timestamp) < date('Y-m-d', $time_mm)) {
continue;
}
$this->backups_size = 0;
$this->backup_files = array();
$destinations = array();
if (is_array($backups_info)) {
if ($this->viewTypes && is_array($this->viewTypes)) {
foreach ($this->viewTypes as $type) {
$this->_addBackupElement($backups_info, $type);
}
}
if (isset($backups_info['service']) && !empty($backups_info['service'])) {
if (is_array($backups_info['service'])) {
foreach ($backups_info['service'] as $service) {
if ($service == 'none') {
$service = 'local';
}
$destinations[] = $service;
}
} else {
if ($backups_info['service'] == 'none') {
$backups_info['service'] = 'local';
}
$destinations[] = $backups_info['service'];
}
}
if (isset($this->backup_files) && is_array($this->backup_files) && !empty($this->backup_files)) {
$backups[date('Y-m-d', $timestamp)][] = array('timestamp' => $timestamp, 'file' => $this->backup_files, 'dest' => $destinations, 'source' => null, 'size' => $this->backups_size, 'links' => array());
}
}
}
return $backups;
}
示例10: backup
public function backup($backup_array)
{
global $updraftplus, $updraftplus_backup;
$updraft_dir = trailingslashit($updraftplus->backups_dir_location());
$email = $updraftplus->just_one_email(UpdraftPlus_Options::get_updraft_option('updraft_email'), true);
if (!is_array($email)) {
$email = array($email);
}
foreach ($backup_array as $type => $file) {
$descrip_type = preg_match('/^(.*)\\d+$/', $type, $matches) ? $matches[1] : $type;
$fullpath = $updraft_dir . $file;
#if (file_exists($fullpath) && filesize($fullpath) > ...
$any_attempted = false;
$any_sent = false;
foreach ($email as $ind => $addr) {
if (!apply_filters('updraftplus_email_wholebackup', true, $addr, $ind, $type)) {
continue;
}
foreach (explode(',', $addr) as $sendmail_addr) {
$send_short = strlen($sendmail_addr) > 5 ? substr($sendmail_addr, 0, 5) . '...' : $sendmail_addr;
$updraftplus->log("{$file}: email to: {$send_short}");
$any_attempted = true;
$subject = __("WordPress Backup", 'updraftplus') . ': ' . get_bloginfo('name') . ' (UpdraftPlus ' . $updraftplus->version . ') ' . get_date_from_gmt(gmdate('Y-m-d H:i:s', $updraftplus->backup_time), 'Y-m-d H:i');
$sent = wp_mail(trim($sendmail_addr), $subject, sprintf(__("Backup is of: %s.", 'updraftplus'), site_url() . ' (' . $descrip_type . ')'), null, array($fullpath));
if ($sent) {
$any_sent = true;
}
}
}
if ($any_sent) {
$updraftplus->uploaded_file($file);
} elseif ($any_attempted) {
$updraftplus->log('Mails were not sent successfully');
$updraftplus->log(__('The attempt to send the backup via email failed (probably the backup was too large for this method)', 'updraftplus'), 'error');
} else {
$updraftplus->log('No email addresses were configured to send to');
}
}
return null;
}
示例11: 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');
示例12: die
<?php
// 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();
示例13: config_print_engine
public static function config_print_engine($key, $whoweare_short, $whoweare_long, $console_descrip, $console_url, $img_html = '', $include_endpoint_chooser = false)
{
?>
<tr class="updraftplusmethod <?php
echo $key;
?>
">
<td></td>
<td><?php
echo $img_html;
?>
<p><em><?php
printf(__('%s is a great choice, because UpdraftPlus supports chunked uploads - no matter how big your site is, UpdraftPlus can upload it a little at a time, and not get thwarted by timeouts.', 'updraftplus'), $whoweare_long);
?>
</em></p>
<?php
if ('s3generic' == $key) {
_e('Examples of S3-compatible storage providers:') . ' ';
echo '<a href="http://www.cloudian.com/">Cloudian</a>, ';
echo '<a href="http://cloud.google.com/storage">Google Cloud Storage</a>, ';
echo '<a href="https://www.mh.connectria.com/rp/order/cloud_storage_index">Connectria</a>, ';
echo '<a href="http://www.constant.com/cloud/storage/">Constant</a>, ';
echo '<a href="http://www.eucalyptus.com/eucalyptus-cloud/iaas">Eucalyptus</a>, ';
echo '<a href="http://cloud.nifty.com/storage/">Nifty</a>, ';
echo '<a href="http://www.ntt.com/cloudn/data/storage.html">Cloudn</a>';
echo '' . __('... and many more!', 'updraftplus') . '<br>';
}
?>
</td>
</tr>
<tr class="updraftplusmethod <?php
echo $key;
?>
">
<th></th>
<td>
<?php
global $updraftplus_admin;
if (!class_exists('SimpleXMLElement')) {
$updraftplus_admin->show_double_warning('<strong>' . __('Warning', 'updraftplus') . ':</strong> ' . sprintf(__('Your web server\'s PHP installation does not included a required module (%s). Please contact your web hosting provider\'s support.', 'updraftplus'), 'SimpleXMLElement') . ' ' . sprintf(__("UpdraftPlus's %s module <strong>requires</strong> %s. Please do not file any support requests; there is no alternative.", 'updraftplus'), $whoweare_long, 'SimpleXMLElement'), $key);
}
$updraftplus_admin->curl_check($whoweare_long, true, $key);
?>
</td>
</tr>
<tr class="updraftplusmethod <?php
echo $key;
?>
">
<th></th>
<td>
<p><?php
if ($console_url) {
echo sprintf(__('Get your access key and secret key <a href="%s">from your %s console</a>, then pick a (globally unique - all %s users) bucket name (letters and numbers) (and optionally a path) to use for storage. This bucket will be created for you if it does not already exist.', 'updraftplus'), $console_url, $console_descrip, $whoweare_long);
}
?>
<a href="http://updraftplus.com/faqs/i-get-ssl-certificate-errors-when-backing-up-andor-restoring/"><?php
_e('If you see errors about SSL certificates, then please go here for help.', 'updraftplus');
?>
</a></p>
</td></tr>
<?php
if ($include_endpoint_chooser) {
?>
<tr class="updraftplusmethod <?php
echo $key;
?>
">
<th><?php
echo sprintf(__('%s end-point', 'updraftplus'), $whoweare_short);
?>
:</th>
<td><input type="text" style="width: 292px" id="updraft_<?php
echo $key;
?>
_endpoint" name="updraft_<?php
echo $key;
?>
_endpoint" value="<?php
echo htmlspecialchars(UpdraftPlus_Options::get_updraft_option('updraft_' . $key . '_endpoint'));
?>
" /></td>
</tr>
<?php
} else {
?>
<input type="hidden" id="updraft_<?php
echo $key;
?>
_endpoint" name="updraft_<?php
echo $key;
?>
_endpoint" value="">
<?php
}
?>
<tr class="updraftplusmethod <?php
echo $key;
?>
//.........这里部分代码省略.........
示例14: bootstrap
public function bootstrap($access_token = false)
{
global $updraftplus;
if (!empty($this->service) && is_object($this->service) && is_a($this->service, 'Google_Service_Drive')) {
return $this->service;
}
$opts = $this->get_opts();
if (empty($access_token)) {
if (empty($opts['token']) || empty($opts['clientid']) || empty($opts['secret'])) {
$updraftplus->log('Google Drive: this account is not authorised');
$updraftplus->log('Google Drive: ' . __('Account is not authorized.', 'updraftplus'), 'error', 'googledrivenotauthed');
return new WP_Error('not_authorized', __('Account is not authorized.', 'updraftplus'));
}
}
// $included_paths = explode(PATH_SEPARATOR, get_include_path());
// if (!in_array(UPDRAFTPLUS_DIR.'/includes', $included_paths)) {
// set_include_path(UPDRAFTPLUS_DIR.'/includes'.PATH_SEPARATOR.get_include_path());
// }
$spl = spl_autoload_functions();
if (is_array($spl)) {
// Workaround for Google Drive CDN plugin's autoloader
if (in_array('wpbgdc_autoloader', $spl)) {
spl_autoload_unregister('wpbgdc_autoloader');
}
// http://www.wpdownloadmanager.com/download/google-drive-explorer/ - but also others, since this is the default function name used by the Google SDK
if (in_array('google_api_php_client_autoload', $spl)) {
spl_autoload_unregister('google_api_php_client_autoload');
}
}
/*
if (!class_exists('Google_Config')) require_once 'Google/Config.php';
if (!class_exists('Google_Client')) require_once 'Google/Client.php';
if (!class_exists('Google_Service_Drive')) require_once 'Google/Service/Drive.php';
if (!class_exists('Google_Http_Request')) require_once 'Google/Http/Request.php';
*/
if ((!class_exists('Google_Config') || !class_exists('Google_Client') || !class_exists('Google_Service_Drive') || !class_exists('Google_Http_Request')) && !function_exists('google_api_php_client_autoload_updraftplus')) {
require_once UPDRAFTPLUS_DIR . '/includes/Google/autoload.php';
}
$config = new Google_Config();
$config->setClassConfig('Google_IO_Abstract', 'request_timeout_seconds', 60);
# In our testing, $service->about->get() fails if gzip is not disabled when using the stream wrapper
if (!function_exists('curl_version') || !function_exists('curl_exec') || defined('UPDRAFTPLUS_GOOGLEDRIVE_DISABLEGZIP') && UPDRAFTPLUS_GOOGLEDRIVE_DISABLEGZIP) {
$config->setClassConfig('Google_Http_Request', 'disable_gzip', true);
}
$client = new Google_Client($config);
$client->setClientId($opts['clientid']);
$client->setClientSecret($opts['secret']);
// $client->setUseObjects(true);
if (empty($access_token)) {
$access_token = $this->access_token($opts['token'], $opts['clientid'], $opts['secret']);
}
// Do we have an access token?
if (empty($access_token) || is_wp_error($access_token)) {
$updraftplus->log('ERROR: Have not yet obtained an access token from Google (has the user authorised?)');
$updraftplus->log(__('Have not yet obtained an access token from Google - you need to authorise or re-authorise your connection to Google Drive.', 'updraftplus'), 'error');
return $access_token;
}
$client->setAccessToken(json_encode(array('access_token' => $access_token, 'refresh_token' => $opts['token'])));
$io = $client->getIo();
$setopts = array();
if (is_a($io, 'Google_IO_Curl')) {
$setopts[CURLOPT_SSL_VERIFYPEER] = UpdraftPlus_Options::get_updraft_option('updraft_ssl_disableverify') ? false : true;
if (!UpdraftPlus_Options::get_updraft_option('updraft_ssl_useservercerts')) {
$setopts[CURLOPT_CAINFO] = UPDRAFTPLUS_DIR . '/includes/cacert.pem';
}
// Raise the timeout from the default of 15
$setopts[CURLOPT_TIMEOUT] = 60;
$setopts[CURLOPT_CONNECTTIMEOUT] = 15;
if (defined('UPDRAFTPLUS_IPV4_ONLY') && UPDRAFTPLUS_IPV4_ONLY) {
$setopts[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4;
}
} elseif (is_a($io, 'Google_IO_Stream')) {
$setopts['timeout'] = 60;
# We had to modify the SDK to support this
# https://wiki.php.net/rfc/tls-peer-verification - before PHP 5.6, there is no default CA file
if (!UpdraftPlus_Options::get_updraft_option('updraft_ssl_useservercerts') || version_compare(PHP_VERSION, '5.6.0', '<')) {
$setopts['cafile'] = UPDRAFTPLUS_DIR . '/includes/cacert.pem';
}
if (UpdraftPlus_Options::get_updraft_option('updraft_ssl_disableverify')) {
$setopts['disable_verify_peer'] = true;
}
}
$io->setOptions($setopts);
$service = new Google_Service_Drive($client);
$this->client = $client;
$this->service = $service;
try {
# Get the folder name, if not previously known (this is for the legacy situation where an id, not a name, was stored)
if (!empty($opts['parentid']) && (!is_array($opts['parentid']) || empty($opts['parentid']['name']))) {
$rootid = $this->root_id();
$title = '';
$parentid = is_array($opts['parentid']) ? $opts['parentid']['id'] : $opts['parentid'];
while (!empty($parentid) && $parentid != $rootid) {
$resource = $service->files->get($parentid);
$title = $title ? $resource->getTitle() . '/' . $title : $resource->getTitle();
$parents = $resource->getParents();
if (is_array($parents) && count($parents) > 0) {
$parent = array_shift($parents);
$parentid = is_a($parent, 'Google_Service_Drive_ParentReference') ? $parent->getId() : false;
} else {
//.........这里部分代码省略.........
示例15: save_settings
public function save_settings($settings)
{
global $updraftplus;
// Make sure that settings filters are registered
UpdraftPlus_Options::admin_init();
$return_array = array('saved' => true, 'changed' => array());
$add_to_post_keys = array('updraft_interval', 'updraft_interval_database', 'updraft_starttime_files', 'updraft_starttime_db', 'updraft_startday_files', 'updraft_startday_db');
//If database and files are on same schedule, override the db day/time settings
if (isset($settings['updraft_interval_database']) && isset($settings['updraft_interval_database']) && $settings['updraft_interval_database'] == $settings['updraft_interval'] && isset($settings['updraft_starttime_files'])) {
$settings['updraft_starttime_db'] = $settings['updraft_starttime_files'];
$settings['updraft_startday_db'] = $settings['updraft_startday_files'];
}
foreach ($add_to_post_keys as $key) {
// For add-ons that look at $_POST to find saved settings, add the relevant keys to $_POST so that they find them there
if (isset($settings[$key])) {
$_POST[$key] = $settings[$key];
}
}
// Wipe the extra retention rules, as they are not saved correctly if the last one is deleted
UpdraftPlus_Options::update_updraft_option('updraft_retain_extrarules', array());
UpdraftPlus_Options::update_updraft_option('updraft_email', array());
UpdraftPlus_Options::update_updraft_option('updraft_report_warningsonly', array());
UpdraftPlus_Options::update_updraft_option('updraft_report_wholebackup', array());
UpdraftPlus_Options::update_updraft_option('updraft_extradbs', array());
UpdraftPlus_Options::update_updraft_option('updraft_include_more_path', array());
$relevant_keys = $updraftplus->get_settings_keys();
if (method_exists('UpdraftPlus_Options', 'mass_options_update')) {
$settings = UpdraftPlus_Options::mass_options_update($settings);
$mass_updated = true;
}
foreach ($settings as $key => $value) {
// $exclude_keys = array('option_page', 'action', '_wpnonce', '_wp_http_referer');
// if (!in_array($key, $exclude_keys)) {
if (in_array($key, $relevant_keys)) {
if ($key == "updraft_service" && is_array($value)) {
foreach ($value as $subkey => $subvalue) {
if ($subvalue == '0') {
unset($value[$subkey]);
}
}
}
$updated = empty($mass_updated) ? UpdraftPlus_Options::update_updraft_option($key, $value) : true;
// Add information on what has changed to array to loop through to update links etc.
if ($updated) {
$return_array['changed'][$key] = $value;
} elseif (empty($mass_updated) && $key == 'updraft_interval') {
//To schedule a database when the interval is not changed.
$updraftplus->schedule_backup($value);
} elseif (empty($mass_updated) && $key == 'updraft_interval_database') {
$updraftplus->schedule_backup_database($value);
}
} else {
// When last active, it was catching: option_page, action, _wpnonce, _wp_http_referer, updraft_s3_endpoint, updraft_dreamobjects_endpoint. The latter two are empty; probably don't need to be in the page at all.
//error_log("Non-UD key when saving from POSTed data: ".$key);
}
}
// Checking for various possible messages
$updraft_dir = $updraftplus->backups_dir_location(false);
$really_is_writable = $updraftplus->really_is_writable($updraft_dir);
$dir_info = $this->really_writable_message($really_is_writable, $updraft_dir);
$button_title = esc_attr(__('This button is disabled because your backup directory is not writable (see the settings).', 'updraftplus'));
$return_array['backup_now_message'] = $this->backup_now_remote_message();
$return_array['backup_dir'] = array('writable' => $really_is_writable, 'message' => $dir_info, 'button_title' => $button_title);
//Because of the single AJAX call, we need to remove the existing UD messages from the 'all_admin_notices' action
remove_all_actions('all_admin_notices');
//Moving from 2 to 1 ajax call
ob_start();
$service = UpdraftPlus_Options::get_updraft_option('updraft_service');
$this->setup_all_admin_notices_global($service);
$this->setup_all_admin_notices_udonly($service);
do_action('all_admin_notices');
if (!$really_is_writable) {
//Check if writable
$this->show_admin_warning_unwritable();
}
if ($return_array['saved'] == true) {
//
$this->show_admin_warning(__('Your settings have been saved.', 'updraftplus'), 'updated fade');
}
$messages_output = ob_get_contents();
ob_clean();
// Backup schedule output
$this->next_scheduled_backups_output();
$scheduled_output = ob_get_clean();
$return_array['messages'] = $messages_output;
$return_array['scheduled'] = $scheduled_output;
return $return_array;
}