本文整理汇总了PHP中Jetpack_Options::delete_option方法的典型用法代码示例。如果您正苦于以下问题:PHP Jetpack_Options::delete_option方法的具体用法?PHP Jetpack_Options::delete_option怎么用?PHP Jetpack_Options::delete_option使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jetpack_Options
的用法示例。
在下文中一共展示了Jetpack_Options::delete_option方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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_Options::get_option($action);
if (!$secrets || is_wp_error($secrets)) {
Jetpack_Options::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_Options::delete_option($action);
return $this->error(new Jetpack_Error('verify_secrets_missing', 'Verification took too long', 400));
}
if ($verify_secret !== $secret_1) {
Jetpack_Options::delete_option($action);
return $this->error(new Jetpack_Error('verify_secrets_mismatch', 'Secret mismatch', 400));
}
Jetpack_Options::delete_option($action);
return $secret_2;
}
示例2: test_does_not_fire_jetpack_publicize_post_on_save_as_published
public function test_does_not_fire_jetpack_publicize_post_on_save_as_published()
{
$this->post->post_status = 'publish';
Jetpack_Options::delete_option(array('publicize_connections'));
wp_insert_post($this->post->to_array());
$this->assertPublicized(false, $this->post);
}
示例3: test_delete_non_compact_option_returns_true_when_successfully_deleted
function test_delete_non_compact_option_returns_true_when_successfully_deleted()
{
Jetpack_Options::update_option('migrate_for_idc', true);
// Make sure the option is set
$this->assertTrue(Jetpack_Options::get_option('migrate_for_idc'));
$deleted = Jetpack_Options::delete_option('migrate_for_idc');
// Was the option successfully deleted?
$this->assertFalse(Jetpack_Options::get_option('migrate_for_idc'));
// Did Jetpack_Options::delete_option() properly return true?
$this->assertTrue($deleted);
}
示例4: test_site_icon_update_to_null_is_synced_using_jetpack_function
public function test_site_icon_update_to_null_is_synced_using_jetpack_function()
{
global $wp_version;
// verify that we started with an icon.
$this->assertEquals('http://foo.com/icon.gif', $this->server_replica_storage->get_option('jetpack_site_icon_url'));
if (version_compare($wp_version, '4.4', '>=')) {
remove_filter('get_site_icon_url', array($this, '_get_site_icon'), 99, 3);
update_option('site_icon', 0);
} else {
// wp 4.3 or less
Jetpack_Options::delete_option('site_icon_url');
}
$this->client->do_sync();
$this->assertEmpty($this->server_replica_storage->get_option('jetpack_site_icon_url'));
$this->assertEquals(Jetpack_Options::get_option('site_icon_url'), $this->server_replica_storage->get_option('jetpack_site_icon_url'));
}
示例5: reindex_status
public function reindex_status()
{
$response = array('status' => 'ERROR');
// Assume reindexing is done if it was not triggered in the first place
if (false === Jetpack_Options::get_option('sync_bulk_reindexing')) {
return array('status' => 'DONE');
}
Jetpack::load_xml_rpc_client();
$client = new Jetpack_IXR_Client(array('user_id' => JETPACK_MASTER_USER));
$client->query('jetpack.reindexStatus');
if (!$client->isError()) {
$response = $client->getResponse();
if ('DONE' == $response['status']) {
Jetpack_Options::delete_option('sync_bulk_reindexing');
}
}
return $response;
}
示例6: test_sync_error_idc_validation_returns_true_when_option_matches_expected
function test_sync_error_idc_validation_returns_true_when_option_matches_expected()
{
add_filter('jetpack_sync_idc_optin', '__return_true');
Jetpack_Options::update_option('sync_error_idc', Jetpack::get_sync_error_idc_option());
$this->assertTrue(Jetpack::validate_sync_error_idc_option());
Jetpack_Options::delete_option('sync_error_idc');
remove_filter('jetpack_sync_idc_optin', '__return_true');
}
示例7: options
/**
* Manage Jetpack Options
*
* ## OPTIONS
*
* list : List all jetpack options and their values
* delete : Delete an option
* - can only delete options that are white listed.
* update : update an option
* - can only update option strings
* get : get the value of an option
*
* ## EXAMPLES
*
* wp jetpack options list
* wp jetpack options get <option_name>
* wp jetpack options delete <option_name>
* wp jetpack options update <option_name> [<option_value>]
*
* @synopsis <list|get|delete|update> [<option_name>] [<option_value>]
*/
public function options($args, $assoc_args)
{
$action = isset($args[0]) ? $args[0] : 'list';
$safe_to_modify = Jetpack::get_jetpack_options_for_reset();
// Jumpstart is special
array_push($safe_to_modify, 'jumpstart');
// Is the option flagged as unsafe?
$flagged = !in_array($args[1], $safe_to_modify);
if (!in_array($action, array('list', 'get', 'delete', 'update'))) {
WP_CLI::error(sprintf(__('%s is not a valid command.', 'jetpack'), $action));
}
if (isset($args[0])) {
if ('get' == $args[0] && isset($args[1])) {
$action = 'get';
} else {
if ('delete' == $args[0] && isset($args[1])) {
$action = 'delete';
} else {
if ('update' == $args[0] && isset($args[1])) {
$action = 'update';
} else {
$action = 'list';
}
}
}
}
// Bail if the option isn't found
$option = isset($args[1]) ? Jetpack_Options::get_option($args[1]) : false;
if (isset($args[1]) && !$option && 'update' !== $args[0]) {
WP_CLI::error(__('Option not found or is empty. Use "list" to list option names', 'jetpack'));
}
// Let's print_r the option if it's an array
// Used in the 'get' and 'list' actions
$option = is_array($option) ? print_r($option) : $option;
switch ($action) {
case 'get':
WP_CLI::success("\t" . $option);
break;
case 'delete':
jetpack_cli_are_you_sure($flagged);
Jetpack_Options::delete_option($args[1]);
WP_CLI::success(sprintf(__('Deleted option: %s', 'jetpack'), $args[1]));
break;
case 'update':
jetpack_cli_are_you_sure($flagged);
// Updating arrays would get pretty tricky...
$value = Jetpack_Options::get_option($args[1]);
if ($value && is_array($value)) {
WP_CLI::error(__('Sorry, no updating arrays at this time', 'jetpack'));
}
Jetpack_Options::update_option($args[1], $args[2]);
WP_CLI::success(sprintf(_x('Updated option: %s to "%s"', 'Updating an option from "this" to "that".', 'jetpack'), $args[1], $args[2]));
break;
case 'list':
$options_compact = Jetpack_Options::get_option_names();
$options_non_compact = Jetpack_Options::get_option_names('non_compact');
$options_private = Jetpack_Options::get_option_names('private');
$options = array_merge($options_compact, $options_non_compact, $options_private);
// Table headers
WP_CLI::line("\t" . str_pad(__('Option', 'jetpack'), 30) . __('Value', 'jetpack'));
// List out the options and their values
// Tell them if the value is empty or not
// Tell them if it's an array
foreach ($options as $option) {
$value = Jetpack_Options::get_option($option);
if (!$value) {
WP_CLI::line("\t" . str_pad($option, 30) . 'Empty');
continue;
}
if (!is_array($value)) {
WP_CLI::line("\t" . str_pad($option, 30) . $value);
} else {
if (is_array($value)) {
WP_CLI::line("\t" . str_pad($option, 30) . 'Array - Use "get <option>" to read option array.');
}
}
}
$option_text = '{' . _x('option', 'a variable command that a user can write, provided in the printed instructions', 'jetpack') . '}';
$value_text = '{' . _x('value', 'the value that they want to update the option to', 'jetpack') . '}';
//.........这里部分代码省略.........
示例8: jetpack_module_deactivated
/**
* Runs when the VideoPress module is deactivated.
*/
function jetpack_module_deactivated()
{
Jetpack_Options::delete_option($this->option_name);
}
示例9: reset_jetpack_options
/**
* Reset Jetpack options
*
* @since 4.3.0
*
* @param WP_REST_Request $data {
* Array of parameters received by request.
*
* @type string $options Available options to reset are options|modules
* }
*
* @return bool|WP_Error True if options were reset. Otherwise, a WP_Error instance with the corresponding error.
*/
public static function reset_jetpack_options($data)
{
$param = $data->get_json_params();
if (!isset($param['reset']) || $param['reset'] !== true) {
return new WP_Error('invalid_param', esc_html__('Invalid Parameter', 'jetpack'), array('status' => 404));
}
if (isset($data['options'])) {
$data = $data['options'];
switch ($data) {
case 'options':
$options_to_reset = Jetpack::get_jetpack_options_for_reset();
// Reset the Jetpack options
foreach ($options_to_reset['jp_options'] as $option_to_reset) {
Jetpack_Options::delete_option($option_to_reset);
}
foreach ($options_to_reset['wp_options'] as $option_to_reset) {
delete_option($option_to_reset);
}
// Reset to default modules
$default_modules = Jetpack::get_default_modules();
Jetpack::update_active_modules($default_modules);
// Jumpstart option is special
Jetpack_Options::update_option('jumpstart', 'new_connection');
return rest_ensure_response(array('code' => 'success', 'message' => esc_html__('Jetpack options reset.', 'jetpack')));
break;
case 'modules':
$default_modules = Jetpack::get_default_modules();
Jetpack::update_active_modules($default_modules);
return rest_ensure_response(array('code' => 'success', 'message' => esc_html__('Modules reset to default.', 'jetpack')));
break;
default:
return new WP_Error('invalid_param', esc_html__('Invalid Parameter', 'jetpack'), array('status' => 404));
}
}
return new WP_Error('required_param', esc_html__('Missing parameter "type".', 'jetpack'), array('status' => 404));
}
示例10: 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_Options::get_option('active_modules')) {
Jetpack_Options::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;
}
示例11: _returns_true_when_option_matches_expected
function _returns_true_when_option_matches_expected()
{
Jetpack_Options::update_option('sync_error_idc', Jetpack::get_sync_error_idc_option());
$this->assertTrue(Jetpack::validate_sync_error_idc_option());
Jetpack_Options::delete_option('sync_error_idc');
}
示例12: 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_Options::delete_option(array('register', 'blog_token', 'user_token', 'user_tokens', 'master_user', 'time_diff', 'fallback_no_verify_ssl_certs'));
if ($update_activated_state) {
Jetpack_Options::update_option('activated', 4);
}
if ($jetpack_unique_connection = Jetpack_Options::get_option('unique_connection')) {
// Check then record unique disconnection if site has never been disconnected previously
if (-1 == $jetpack_unique_connection['disconnected']) {
$jetpack_unique_connection['disconnected'] = 1;
} else {
if (0 == $jetpack_unique_connection['disconnected']) {
//track unique disconnect
$jetpack = Jetpack::init();
$jetpack->stat('connections', 'unique-disconnect');
$jetpack->do_stats('server_side');
}
// increment number of times disconnected
$jetpack_unique_connection['disconnected'] += 1;
}
Jetpack_Options::update_option('unique_connection', $jetpack_unique_connection);
}
// Delete all the sync related data. Since it could be taking up space.
require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-sender.php';
Jetpack_Sync_Sender::get_instance()->uninstall();
// Disable the Heartbeat cron
Jetpack_Heartbeat::init()->deactivate();
}
示例13: clear_all_idc_options
/**
* Clears all IDC specific options. This method is used on disconnect and reconnect.
*/
static function clear_all_idc_options()
{
Jetpack_Options::delete_option(array('sync_error_idc', 'safe_mode_confirmed', 'migrate_for_idc'));
}
示例14: jetpack_sync_core_icon
function jetpack_sync_core_icon()
{
if (function_exists('get_site_icon_url')) {
$url = get_site_icon_url();
} else {
return;
}
require_once JETPACK__PLUGIN_DIR . 'modules/site-icon/site-icon-functions.php';
// If there's a core icon, maybe update the option. If not, fall back to Jetpack's.
if (!empty($url) && $url !== jetpack_site_icon_url()) {
// This is the option that is synced with dotcom
Jetpack_Options::update_option('site_icon_url', $url);
} else {
if (empty($url)) {
Jetpack_Options::delete_option('site_icon_url');
}
}
}
示例15: jetpack_custom_css_undo_data_migration_cli
function jetpack_custom_css_undo_data_migration_cli()
{
Jetpack_Options::delete_option('custom_css_4.7_migration');
WP_CLI::success(__('Option deleted, re-migrate via `wp jetpack custom-css migrate`.', 'jetpack'));
}