public static function show_authed_admin_success() { global $updraftplus_admin; $updraftplus_tmp_access_token = get_transient('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); delete_transient('updraftplus_tmp_googledrive_access_token'); }
public function googledrive_checkchange($google) { $opts = UpdraftPlus_Options::get_updraft_option('updraft_googledrive'); if (!is_array($google)) { return $opts; } $old_client_id = empty($opts['clientid']) ? '' : $opts['clientid']; if (!empty($opts['token']) && $old_client_id != $google['clientid']) { require_once UPDRAFTPLUS_DIR . '/methods/googledrive.php'; add_action('http_request_args', array($this, 'modify_http_options')); UpdraftPlus_BackupModule_googledrive::gdrive_auth_revoke(false); remove_action('http_request_args', array($this, 'modify_http_options')); $google['token'] = ''; unset($opts['ownername']); } foreach ($google as $key => $value) { // Trim spaces - I got support requests from users who didn't spot the spaces they introduced when copy/pasting $opts[$key] = 'clientid' == $key || 'secret' == $key ? trim($value) : $value; } if (isset($opts['folder'])) { $opts['folder'] = apply_filters('updraftplus_options_googledrive_foldername', 'UpdraftPlus', $opts['folder']); unset($opts['parentid']); } return $opts; }
function googledrive_clientid_checkchange($client_id) { if (UpdraftPlus_Options::get_updraft_option('updraft_googledrive_token') != '' && UpdraftPlus_Options::get_updraft_option('updraft_googledrive_clientid') != $client_id) { require_once UPDRAFTPLUS_DIR . '/methods/googledrive.php'; add_action('http_api_curl', array($this, 'add_curl_capath')); UpdraftPlus_BackupModule_googledrive::gdrive_auth_revoke(true); remove_action('http_api_curl', array($this, 'add_curl_capath')); } return $client_id; }