本文整理匯總了PHP中BackWPup_Option::delete方法的典型用法代碼示例。如果您正苦於以下問題:PHP BackWPup_Option::delete方法的具體用法?PHP BackWPup_Option::delete怎麽用?PHP BackWPup_Option::delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類BackWPup_Option
的用法示例。
在下文中一共展示了BackWPup_Option::delete方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: save_post_form
/**
* Save Form data
*/
public static function save_post_form($tab, $jobid)
{
if (!current_user_can('backwpup_jobs_edit')) {
return __('Sorry, you don\'t have permissions to do that.', 'backwpup');
}
$destinations = BackWPup::get_registered_destinations();
$job_types = BackWPup::get_job_types();
switch ($tab) {
case 'job':
BackWPup_Option::update($jobid, 'jobid', $jobid);
if (isset($_POST['type']) && is_array($_POST['type'])) {
foreach ((array) $_POST['type'] as $typeid) {
if (empty($job_types[$typeid])) {
unset($_POST['type'][$typeid]);
}
}
if (is_array($_POST['type'])) {
sort($_POST['type']);
}
} else {
$_POST['type'] = array();
}
//test if job type makes backup
/* @var BackWPup_JobTypes $job_type */
$makes_file = FALSE;
foreach ($job_types as $type_id => $job_type) {
if (in_array($type_id, $_POST['type'])) {
if ($job_type->creates_file()) {
$makes_file = TRUE;
break;
}
}
}
if (!$makes_file) {
$_POST['destinations'] = array();
}
BackWPup_Option::update($jobid, 'type', $_POST['type']);
if (isset($_POST['destinations']) && is_array($_POST['destinations'])) {
foreach ((array) $_POST['destinations'] as $key => $destid) {
if (empty($destinations[$destid])) {
//remove all destinations that not exists
unset($_POST['destinations'][$key]);
}
if (class_exists('BackWPup_Pro', FALSE) && $_POST['backuptype'] == 'sync') {
//if sync remove all not sync destinations
if (!$destinations[$destid]['can_sync']) {
unset($_POST['destinations'][$key]);
}
}
}
if (is_array($_POST['destinations'])) {
sort($_POST['destinations']);
}
} else {
$_POST['destinations'] = array();
}
BackWPup_Option::update($jobid, 'destinations', $_POST['destinations']);
$name = esc_html(trim($_POST['name']));
if (empty($name) || $_POST['name'] == __('New Job', 'backwpup')) {
$name = sprintf(__('Job with ID %d', 'backwpup'), $jobid);
}
BackWPup_Option::update($jobid, 'name', $name);
$emails = explode(',', $_POST['mailaddresslog']);
foreach ($emails as $key => $email) {
$emails[$key] = sanitize_email(trim($email));
if (!is_email($emails[$key])) {
unset($emails[$key]);
}
}
$mailaddresslog = implode(', ', $emails);
BackWPup_Option::update($jobid, 'mailaddresslog', $mailaddresslog);
$_POST['mailaddresssenderlog'] = trim($_POST['mailaddresssenderlog']);
if (empty($_POST['mailaddresssenderlog'])) {
BackWPup_Option::delete($jobid, 'mailaddresssenderlog');
} else {
BackWPup_Option::update($jobid, 'mailaddresssenderlog', $_POST['mailaddresssenderlog']);
}
BackWPup_Option::update($jobid, 'mailerroronly', isset($_POST['mailerroronly']) && $_POST['mailerroronly'] == 1 ? TRUE : FALSE);
if (class_exists('BackWPup_Pro', FALSE)) {
BackWPup_Option::update($jobid, 'backuptype', esc_html($_POST['backuptype']));
} else {
BackWPup_Option::update($jobid, 'backuptype', 'archive');
}
BackWPup_Option::update($jobid, 'archiveformat', esc_html($_POST['archiveformat']));
BackWPup_Option::update($jobid, 'archivename', BackWPup_Job::sanitize_file_name($_POST['archivename']));
break;
case 'cron':
if ($_POST['activetype'] == '' || $_POST['activetype'] == 'wpcron' || $_POST['activetype'] == 'easycron' || $_POST['activetype'] == 'link') {
BackWPup_Option::update($jobid, 'activetype', $_POST['activetype']);
}
BackWPup_Option::update($jobid, 'cronselect', $_POST['cronselect'] == 'advanced' ? 'advanced' : 'basic');
if (isset($_POST['cronselect']) && $_POST['cronselect'] == 'advanced') {
//save advanced
if (empty($_POST['cronminutes']) || $_POST['cronminutes'][0] == '*') {
if (!empty($_POST['cronminutes'][1])) {
$_POST['cronminutes'] = array('*/' . $_POST['cronminutes'][1]);
} else {
//.........這裏部分代碼省略.........
示例2: edit_form_post_save
/**
* @param $jobid
*/
public function edit_form_post_save($jobid)
{
if (!empty($_POST['sugaremail']) && !empty($_POST['sugarpass']) && $_POST['authbutton'] === __('Authenticate with Sugarsync!', 'backwpup')) {
try {
$sugarsync = new BackWPup_Destination_SugarSync_API();
$refresh_token = $sugarsync->get_Refresh_Token(sanitize_email($_POST['sugaremail']), $_POST['sugarpass']);
if (!empty($refresh_token)) {
BackWPup_Option::update($jobid, 'sugarrefreshtoken', $refresh_token);
}
} catch (Exception $e) {
BackWPup_Admin::message('SUGARSYNC: ' . $e->getMessage(), TRUE);
}
}
if (isset($_POST['authbutton']) && $_POST['authbutton'] === __('Delete Sugarsync authentication!', 'backwpup')) {
BackWPup_Option::delete($jobid, 'sugarrefreshtoken');
}
if (isset($_POST['authbutton']) && $_POST['authbutton'] === __('Create Sugarsync account', 'backwpup')) {
try {
$sugarsync = new BackWPup_Destination_SugarSync_API();
$sugarsync->create_account(sanitize_email($_POST['sugaremail']), $_POST['sugarpass']);
} catch (Exception $e) {
BackWPup_Admin::message('SUGARSYNC: ' . $e->getMessage(), TRUE);
}
}
$_POST['sugardir'] = trailingslashit(str_replace('//', '/', str_replace('\\', '/', trim(sanitize_text_field($_POST['sugardir'])))));
if (substr($_POST['sugardir'], 0, 1) == '/') {
$_POST['sugardir'] = substr($_POST['sugardir'], 1);
}
if ($_POST['sugardir'] == '/') {
$_POST['sugardir'] = '';
}
BackWPup_Option::update($jobid, 'sugardir', $_POST['sugardir']);
BackWPup_Option::update($jobid, 'sugarroot', isset($_POST['sugarroot']) ? sanitize_text_field($_POST['sugarroot']) : '');
BackWPup_Option::update($jobid, 'sugarmaxbackups', isset($_POST['sugarmaxbackups']) ? absint($_POST['sugarmaxbackups']) : 0);
}
示例3: job_run_archive
/**
* @param $job_object
*
* @return bool
*/
public function job_run_archive(BackWPup_Job $job_object)
{
$job_object->substeps_todo = 2 + $job_object->backup_filesize;
if ($job_object->steps_data[$job_object->step_working]['SAVE_STEP_TRY'] != $job_object->steps_data[$job_object->step_working]['STEP_TRY']) {
$job_object->log(sprintf(__('%d. Try to send backup file to Dropbox …', 'backwpup'), $job_object->steps_data[$job_object->step_working]['STEP_TRY']));
}
try {
$dropbox = new BackWPup_Destination_Dropbox_API($job_object->job['dropboxroot']);
// cahnge oauth1 to oauth2 token
if (!empty($job_object->job['dropboxsecret']) && empty($job_object->job['dropboxtoken']['access_token'])) {
$dropbox->setOAuthTokens(array('access_token' => $job_object->job['dropboxtoken'], 'oauth_token_secret' => BackWPup_Encryption::decrypt($job_object->job['dropboxsecret'])));
$job_object->job['dropboxtoken'] = $dropbox->token_from_oauth1();
BackWPup_Option::update($job_object->job['jobid'], 'dropboxtoken', $job_object->job['dropboxtoken']);
BackWPup_Option::delete($job_object->job['jobid'], 'dropboxsecret');
}
// set the tokens
$dropbox->setOAuthTokens($job_object->job['dropboxtoken']);
//get account info
if ($job_object->steps_data[$job_object->step_working]['SAVE_STEP_TRY'] != $job_object->steps_data[$job_object->step_working]['STEP_TRY']) {
$info = $dropbox->accountInfo();
if (!empty($info['uid'])) {
if ($job_object->is_debug()) {
$user = $info['display_name'] . ' (' . $info['email'] . ')';
} else {
$user = $info['display_name'];
}
$job_object->log(sprintf(__('Authenticated with Dropbox of user: %s', 'backwpup'), $user));
//Quota
if ($job_object->is_debug()) {
$dropboxfreespase = $info['quota_info']['quota'] - $info['quota_info']['shared'] - $info['quota_info']['normal'];
$job_object->log(sprintf(__('%s available on your Dropbox', 'backwpup'), size_format($dropboxfreespase, 2)));
}
} else {
$job_object->log(__('Not Authenticated with Dropbox!', 'backwpup'), E_USER_ERROR);
return false;
}
$job_object->log(__('Uploading to Dropbox …', 'backwpup'));
}
// put the file
self::$backwpup_job_object =& $job_object;
if ($job_object->substeps_done < $job_object->backup_filesize) {
//only if upload not complete
$response = $dropbox->upload($job_object->backup_folder . $job_object->backup_file, $job_object->job['dropboxdir'] . $job_object->backup_file);
if ($response['bytes'] == $job_object->backup_filesize) {
if (!empty($job_object->job['jobid'])) {
BackWPup_Option::update($job_object->job['jobid'], 'lastbackupdownloadurl', network_admin_url('admin.php') . '?page=backwpupbackups&action=downloaddropbox&file=' . ltrim($response['path'], '/') . '&jobid=' . $job_object->job['jobid']);
}
$job_object->substeps_done = 1 + $job_object->backup_filesize;
$job_object->log(sprintf(__('Backup transferred to %s', 'backwpup'), 'https://content.dropboxapi.com/1/files/' . $job_object->job['dropboxroot'] . $response['path']), E_USER_NOTICE);
} else {
if ($response['bytes'] != $job_object->backup_filesize) {
$job_object->log(__('Uploaded file size and local file size don\'t match.', 'backwpup'), E_USER_ERROR);
} else {
$job_object->log(sprintf(__('Error transfering backup to %s.', 'backwpup') . ' ' . $response['error'], __('Dropbox', 'backwpup')), E_USER_ERROR);
}
return false;
}
}
$backupfilelist = array();
$filecounter = 0;
$files = array();
$metadata = $dropbox->metadata($job_object->job['dropboxdir']);
if (is_array($metadata)) {
foreach ($metadata['contents'] as $data) {
if ($data['is_dir'] != true) {
$file = basename($data['path']);
if ($job_object->is_backup_archive($file)) {
$backupfilelist[strtotime($data['modified'])] = $file;
}
$files[$filecounter]['folder'] = "https://content.dropboxapi.com/1/files/" . $job_object->job['dropboxroot'] . dirname($data['path']) . "/";
$files[$filecounter]['file'] = $data['path'];
$files[$filecounter]['filename'] = basename($data['path']);
$files[$filecounter]['downloadurl'] = network_admin_url('admin.php?page=backwpupbackups&action=downloaddropbox&file=' . $data['path'] . '&jobid=' . $job_object->job['jobid']);
$files[$filecounter]['filesize'] = $data['bytes'];
$files[$filecounter]['time'] = strtotime($data['modified']) + get_option('gmt_offset') * 3600;
$filecounter++;
}
}
}
if ($job_object->job['dropboxmaxbackups'] > 0 && is_object($dropbox)) {
//Delete old backups
if (count($backupfilelist) > $job_object->job['dropboxmaxbackups']) {
ksort($backupfilelist);
$numdeltefiles = 0;
while ($file = array_shift($backupfilelist)) {
if (count($backupfilelist) < $job_object->job['dropboxmaxbackups']) {
break;
}
$response = $dropbox->fileopsDelete($job_object->job['dropboxdir'] . $file);
//delete files on Cloud
if ($response['is_deleted'] == 'true') {
foreach ($files as $key => $filedata) {
if ($filedata['file'] == '/' . $job_object->job['dropboxdir'] . $file) {
unset($files[$key]);
}
//.........這裏部分代碼省略.........
示例4: status
public static function status($backwpup_jobid)
{
if (empty($backwpup_jobid)) {
$id = get_site_option('backwpup_cfg_easycronjobid');
} else {
$id = BackWPup_Option::get($backwpup_jobid, 'easycronjobid');
}
if (empty($id)) {
return array();
}
$cron_job = get_site_transient('backwpup_easycron_' . $id);
if (!empty($cron_job)) {
return $cron_job;
}
$message = self::query_api('detail', array('id' => $id));
if ($message['status'] == 'success' && !empty($message['cron_job'])) {
set_site_transient('backwpup_easycron_' . $id, $message['cron_job'], 3600 - 30);
return $message['cron_job'];
} else {
if ($message['error']['code'] == 25) {
if (empty($backwpup_jobid)) {
delete_site_option('backwpup_cfg_easycronjobid');
} else {
BackWPup_Option::delete($backwpup_jobid, 'easycronjobid');
}
}
}
return array();
}