本文整理汇总了PHP中Jetpack::delete_option方法的典型用法代码示例。如果您正苦于以下问题:PHP Jetpack::delete_option方法的具体用法?PHP Jetpack::delete_option怎么用?PHP Jetpack::delete_option使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jetpack
的用法示例。
在下文中一共展示了Jetpack::delete_option方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: verify_action
/**
* @return WP_Error|string secret_2 on success, WP_Error( error_code => error_code, error_message => error description, error_data => status code ) on failure
*
* Possible error_codes:
*
* verify_secret_1_missing
* verify_secret_1_malformed
* verify_secrets_missing: No longer have verification secrets stored
* verify_secrets_mismatch: stored secret_1 does not match secret_1 sent by Jetpack.WordPress.com
*/
function verify_action($params)
{
$action = $params[0];
$verify_secret = $params[1];
if (empty($verify_secret)) {
return $this->error(new Jetpack_Error('verify_secret_1_missing', sprintf('The required "%s" parameter is missing.', 'secret_1'), 400));
} else {
if (!is_string($verify_secret)) {
return $this->error(new Jetpack_Error('verify_secret_1_malformed', sprintf('The required "%s" parameter is malformed.', 'secret_1'), 400));
}
}
$secrets = Jetpack::get_option($action);
if (!$secrets || is_wp_error($secrets)) {
Jetpack::delete_option($action);
return $this->error(new Jetpack_Error('verify_secrets_missing', 'Verification took too long', 400));
}
@(list($secret_1, $secret_2, $secret_eol) = explode(':', $secrets));
if (empty($secret_1) || empty($secret_2) || empty($secret_eol) || $secret_eol < time()) {
Jetpack::delete_option($action);
return $this->error(new Jetpack_Error('verify_secrets_missing', 'Verification took too long', 400));
}
if ($verify_secret !== $secret_1) {
Jetpack::delete_option($action);
return $this->error(new Jetpack_Error('verify_secrets_mismatch', 'Secret mismatch', 400));
}
Jetpack::delete_option($action);
return $secret_2;
}
示例2: authorize
function authorize()
{
$data = stripslashes_deep($_GET);
$args = array();
do {
$jetpack = Jetpack::init();
$role = $jetpack->translate_current_user_to_role();
if (!$role) {
Jetpack::state('error', 'no_role');
break;
}
$cap = $jetpack->translate_role_to_cap($role);
if (!$cap) {
Jetpack::state('error', 'no_cap');
break;
}
check_admin_referer("jetpack-authorize_{$role}");
if (!empty($data['error'])) {
Jetpack::state('error', $data['error']);
break;
}
if (empty($data['state'])) {
Jetpack::state('error', 'no_state');
break;
}
if (!ctype_digit($data['state'])) {
Jetpack::state('error', 'invalid_state');
break;
}
$current_user_id = get_current_user_id();
if ($current_user_id != $data['state']) {
Jetpack::state('error', 'wrong_state');
break;
}
if (empty($data['code'])) {
Jetpack::state('error', 'no_code');
break;
}
$token = $this->get_token($data);
if (is_wp_error($token)) {
if ($error = $token->get_error_code()) {
Jetpack::state('error', $error);
} else {
Jetpack::state('error', 'invalid_token');
}
Jetpack::state('error_description', $token->get_error_message());
break;
}
if (!$token) {
Jetpack::state('error', 'no_token');
break;
}
Jetpack::update_option('user_token', sprintf('%s.%d', $token, $current_user_id), true);
Jetpack::state('message', 'authorized');
if ($active_modules = Jetpack::get_option('active_modules')) {
Jetpack::delete_option('active_modules');
Jetpack::activate_default_modules(999, 1, $active_modules);
} else {
Jetpack::activate_default_modules();
}
// Start nonce cleaner
wp_clear_scheduled_hook('jetpack_clean_nonces');
wp_schedule_event(time(), 'hourly', 'jetpack_clean_nonces');
} while (false);
wp_safe_redirect(Jetpack::admin_url());
exit;
}
示例3: authorize
function authorize()
{
$data = stripslashes_deep($_GET);
$args = array();
$redirect = isset($data['redirect']) ? esc_url_raw((string) $data['redirect']) : '';
do {
$jetpack = Jetpack::init();
$role = $jetpack->translate_current_user_to_role();
if (!$role) {
Jetpack::state('error', 'no_role');
break;
}
$cap = $jetpack->translate_role_to_cap($role);
if (!$cap) {
Jetpack::state('error', 'no_cap');
break;
}
check_admin_referer("jetpack-authorize_{$role}_{$redirect}");
if (!empty($data['error'])) {
Jetpack::state('error', $data['error']);
break;
}
if (empty($data['state'])) {
Jetpack::state('error', 'no_state');
break;
}
if (!ctype_digit($data['state'])) {
Jetpack::state('error', 'invalid_state');
break;
}
$current_user_id = get_current_user_id();
if ($current_user_id != $data['state']) {
Jetpack::state('error', 'wrong_state');
break;
}
if (empty($data['code'])) {
Jetpack::state('error', 'no_code');
break;
}
$token = $this->get_token($data);
if (is_wp_error($token)) {
if ($error = $token->get_error_code()) {
Jetpack::state('error', $error);
} else {
Jetpack::state('error', 'invalid_token');
}
Jetpack::state('error_description', $token->get_error_message());
break;
}
if (!$token) {
Jetpack::state('error', 'no_token');
break;
}
$is_master_user = !Jetpack::is_active();
Jetpack::update_user_token($current_user_id, sprintf('%s.%d', $token, $current_user_id), $is_master_user);
if ($is_master_user) {
Jetpack::state('message', 'authorized');
} else {
Jetpack::state('message', 'linked');
// Don't activate anything since we are just connecting a user.
break;
}
if ($active_modules = Jetpack::get_option('active_modules')) {
Jetpack::delete_option('active_modules');
Jetpack::activate_default_modules(999, 1, $active_modules);
} else {
Jetpack::activate_default_modules();
}
$jetpack->sync->register('noop');
// Spawn a sync to make sure the Jetpack Servers know what modules are active.
// Start nonce cleaner
wp_clear_scheduled_hook('jetpack_clean_nonces');
wp_schedule_event(time(), 'hourly', 'jetpack_clean_nonces');
} while (false);
if (wp_validate_redirect($redirect)) {
wp_safe_redirect($redirect);
} else {
wp_safe_redirect(Jetpack::admin_url());
}
exit;
}
示例4: disconnect
/**
* Disconnects from the Jetpack servers.
* Forgets all connection details and tells the Jetpack servers to do the same.
* @static
*/
public static function disconnect($update_activated_state = true)
{
wp_clear_scheduled_hook('jetpack_clean_nonces');
Jetpack::clean_nonces(true);
Jetpack::load_xml_rpc_client();
$xml = new Jetpack_IXR_Client();
$xml->query('jetpack.deregister');
Jetpack::delete_option(array('register', 'blog_token', 'user_token', 'user_tokens', 'master_user', 'time_diff', 'fallback_no_verify_ssl_certs'));
if ($update_activated_state) {
Jetpack::update_option('activated', 4);
}
}