当前位置: 首页>>代码示例>>PHP>>正文


PHP Jetpack_Options::update_option方法代码示例

本文整理汇总了PHP中Jetpack_Options::update_option方法的典型用法代码示例。如果您正苦于以下问题:PHP Jetpack_Options::update_option方法的具体用法?PHP Jetpack_Options::update_option怎么用?PHP Jetpack_Options::update_option使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Jetpack_Options的用法示例。


在下文中一共展示了Jetpack_Options::update_option方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: user_role_change

 /**
  * Synchronize connected user role changes
  */
 static function user_role_change($user_id)
 {
     if (Jetpack::is_active() && Jetpack::is_user_connected($user_id)) {
         $current_user_id = get_current_user_id();
         wp_set_current_user($user_id);
         $role = Jetpack::translate_current_user_to_role();
         $signed_role = Jetpack::sign_role($role);
         wp_set_current_user($current_user_id);
         $master_token = Jetpack_Data::get_access_token(JETPACK_MASTER_USER);
         $master_user_id = absint($master_token->external_user_id);
         if (!$master_user_id) {
             return;
         }
         // this shouldn't happen
         Jetpack::xmlrpc_async_call('jetpack.updateRole', $user_id, $signed_role);
         //@todo retry on failure
         //try to choose a new master if we're demoting the current one
         if ($user_id == $master_user_id && 'administrator' != $role) {
             $query = new WP_User_Query(array('fields' => array('id'), 'role' => 'administrator', 'orderby' => 'id', 'exclude' => array($master_user_id)));
             $new_master = false;
             foreach ($query->results as $result) {
                 $uid = absint($result->id);
                 if ($uid && Jetpack::is_user_connected($uid)) {
                     $new_master = $uid;
                     break;
                 }
             }
             if ($new_master) {
                 Jetpack_Options::update_option('master_user', $new_master);
             }
             // else disconnect..?
         }
     }
 }
开发者ID:elliott-stocks,项目名称:jetpack,代码行数:37,代码来源:class.jetpack-sync-users.php

示例2: cron_exec

 /**
  * Method that gets executed on the wp-cron call
  *
  * @since 2.3.3
  * @global string $wp_version
  */
 public function cron_exec()
 {
     $jetpack = Jetpack::init();
     /*
      * This should run daily.  Figuring in for variances in
      * WP_CRON, don't let it run more than every 23 hours at most.
      *
      * i.e. if it ran less than 23 hours ago, fail out.
      */
     $last = (int) Jetpack_Options::get_option('last_heartbeat');
     if ($last && $last + DAY_IN_SECONDS - HOUR_IN_SECONDS > time()) {
         return;
     }
     /*
      * Check for an identity crisis
      *
      * If one exists:
      * - Bump stat for ID crisis
      * - Email site admin about potential ID crisis
      */
     // Coming Soon!
     foreach (self::generate_stats_array('v2-') as $key => $value) {
         $jetpack->stat($key, $value);
     }
     Jetpack_Options::update_option('last_heartbeat', time());
     $jetpack->do_stats('server_side');
 }
开发者ID:aim-web-projects,项目名称:kobe-chuoh,代码行数:33,代码来源:class.jetpack-heartbeat.php

示例3: default_action

 public function default_action()
 {
     $args = $this->input();
     if (isset($args['autoupdate']) && is_bool($args['autoupdate'])) {
         Jetpack_Options::update_option('autoupdate_core', $args['autoupdate']);
     }
     return true;
 }
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:8,代码来源:class.jetpack-json-api-core-modify-endpoint.php

示例4: jetpack_json_api_configuration_load

function jetpack_json_api_configuration_load()
{
    if (isset($_POST['action']) && $_POST['action'] == 'save_options' && wp_verify_nonce($_POST['_wpnonce'], 'json-api')) {
        Jetpack_Options::update_option('json_api_full_management', isset($_POST['json_api_full_management']));
        Jetpack::state('message', 'module_configured');
        wp_safe_redirect(Jetpack::module_configuration_url('json-api'));
        exit;
    }
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:9,代码来源:json-api.php

示例5: get_random_connection_banner_value

 /**
  * Gets the value for which connection banner to show, and initializes if not set.
  *
  * @since 4.4.0
  *
  * @return int
  */
 static function get_random_connection_banner_value()
 {
     $random_connection_banner = Jetpack_Options::get_option('connection_banner_ab');
     if (!$random_connection_banner) {
         $random_connection_banner = mt_rand(1, 2);
         Jetpack_Options::update_option('connection_banner_ab', $random_connection_banner);
     }
     return $random_connection_banner;
 }
开发者ID:automattic,项目名称:jetpack,代码行数:16,代码来源:class.jetpack-connection-banner.php

示例6: 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);
 }
开发者ID:automattic,项目名称:jetpack,代码行数:11,代码来源:test_class.jetpack-options.php

示例7: test_sync_deactivate_module_event

 function test_sync_deactivate_module_event()
 {
     Jetpack_Options::update_option('active_modules', array('stuff'));
     Jetpack::deactivate_module('stuff');
     $this->client->do_sync();
     $events = $this->server_event_storage->get_all_events('jetpack_deactivate_module');
     $event = $events[0];
     $this->assertEquals('jetpack_deactivate_module', $event->action);
     $this->assertEquals('stuff', $event->args[0]);
     $this->assertEquals(1, count($events));
 }
开发者ID:elliott-stocks,项目名称:jetpack,代码行数:11,代码来源:test_class.jetpack-sync-modules.php

示例8: test_clear_all_idc_options_clears_expected

 function test_clear_all_idc_options_clears_expected()
 {
     $options = array('sync_error_idc', 'safe_mode_confirmed', 'migrate_for_idc');
     foreach ($options as $option) {
         Jetpack_Options::update_option($option, true);
         $this->assertTrue(Jetpack_Options::get_option($option));
     }
     Jetpack_IDC::clear_all_idc_options();
     foreach ($options as $option) {
         $this->assertFalse(Jetpack_Options::get_option($option));
     }
 }
开发者ID:automattic,项目名称:jetpack,代码行数:12,代码来源:test_class.jetpack-idc.php

示例9: setUp

 public function setUp()
 {
     global $wp_version;
     parent::setUp();
     if (version_compare($wp_version, '4.4', '>=')) {
         add_filter('get_site_icon_url', array($this, '_get_site_icon'), 99, 3);
         update_option('site_icon', '5');
     } else {
         // wp 4.3 or less
         Jetpack_Options::update_option('site_icon_url', 'http://foo.com/icon.gif');
     }
     $this->client->do_sync();
 }
开发者ID:elliott-stocks,项目名称:jetpack,代码行数:13,代码来源:test_class.jetpack-sync-site-icon-url.php

示例10: reindex_trigger

 static function reindex_trigger()
 {
     $response = array('status' => 'ERROR');
     // Force a privacy check
     Jetpack::check_privacy(JETPACK__PLUGIN_FILE);
     Jetpack::load_xml_rpc_client();
     $client = new Jetpack_IXR_Client(array('user_id' => JETPACK_MASTER_USER));
     $client->query('jetpack.reindexTrigger');
     if (!$client->isError()) {
         $response = $client->getResponse();
         Jetpack_Options::update_option('sync_bulk_reindexing', true);
     }
     return $response;
 }
开发者ID:elliott-stocks,项目名称:jetpack,代码行数:14,代码来源:class.jetpack-sync-reindex.php

示例11: test_autoupdate_enabled_and_disabled_is_synced

 public function test_autoupdate_enabled_and_disabled_is_synced()
 {
     // enable autoupdates
     $autoupdate_plugins = Jetpack_Options::get_option('autoupdate_plugins', array());
     $autoupdate_plugins = array_unique(array_merge($autoupdate_plugins, array('hello')));
     Jetpack_Options::update_option('autoupdate_plugins', $autoupdate_plugins);
     $this->sender->do_sync();
     $set_autoupdate_plugin = $this->server_replica_storage->get_option('jetpack_autoupdate_plugins', array());
     $this->assertEquals(Jetpack_Options::get_option('autoupdate_plugins', array()), $set_autoupdate_plugin);
     $this->assertTrue(in_array('hello', $set_autoupdate_plugin));
     // disable autoupdates
     $autoupdate_plugins = Jetpack_Options::get_option('autoupdate_plugins', array());
     $autoupdate_plugins = array_diff($autoupdate_plugins, array('hello'));
     Jetpack_Options::update_option('autoupdate_plugins', $autoupdate_plugins);
     $this->sender->do_sync();
     $set_autoupdate_plugin = $this->server_replica_storage->get_option('jetpack_autoupdate_plugins');
     $this->assertEquals(Jetpack_Options::get_option('autoupdate_plugins', array()), $set_autoupdate_plugin);
     $this->assertFalse(in_array('hello', $set_autoupdate_plugin));
 }
开发者ID:iamtakashi,项目名称:jetpack,代码行数:19,代码来源:test_class.jetpack-sync-plugins.php

示例12: maybe_demote_master_user

 static function maybe_demote_master_user($user_id)
 {
     $master_user_id = Jetpack_Options::get_option('master_user');
     $role = self::get_role($user_id);
     if ($user_id == $master_user_id && 'administrator' != $role) {
         $query = new WP_User_Query(array('fields' => array('id'), 'role' => 'administrator', 'orderby' => 'id', 'exclude' => array($master_user_id)));
         $new_master = false;
         foreach ($query->results as $result) {
             $found_user_id = absint($result->id);
             if ($found_user_id && Jetpack::is_user_connected($found_user_id)) {
                 $new_master = $found_user_id;
                 break;
             }
         }
         if ($new_master) {
             Jetpack_Options::update_option('master_user', $new_master);
         }
         // else disconnect..?
     }
 }
开发者ID:kanei,项目名称:vantuch.cz,代码行数:20,代码来源:class.jetpack-sync-users.php

示例13: jetpack_my_jetpack_change_user

 function jetpack_my_jetpack_change_user()
 {
     if (!isset($_POST['_my_jetpack_nonce']) || !wp_verify_nonce($_POST['_my_jetpack_nonce'], 'jetpack_change_primary_user')) {
         wp_die(__('Failed permissions, please try again.', 'jetpack'));
         exit;
     }
     if (isset($_POST['jetpack-new-master'])) {
         $old_master_user = Jetpack_Options::get_option('master_user');
         $new_master_user = $_POST['jetpack-new-master'];
         $user_token = Jetpack_Data::get_access_token($new_master_user);
         $is_user_connected = $user_token && !is_wp_error($user_token);
         if (current_user_can('manage_options') && $is_user_connected) {
             Jetpack::log('switch_master_user', array('old_master' => $old_master_user, 'new_master' => $new_master_user));
             Jetpack_Options::update_option('master_user', $new_master_user);
             Jetpack::state('message', 'switch_master');
             //My Jetpack primary user successfully changed, send to MC Stats
             Jetpack::init()->stat('admin', 'change-primary-successful');
             Jetpack::init()->do_stats('server_side');
             // Change the blog owner dotcom side
             $this->wpcom_switch_blog_owner($new_master_user);
         }
     }
 }
开发者ID:StefanBonilla,项目名称:CoupSoup,代码行数:23,代码来源:class.jetpack-my-jetpack-page.php

示例14: do_subsiteregister

 /**
  * Registers a subsite with the Jetpack servers
  *
  * @since 2.9
  * @todo  Break apart into easier to manage chunks that can be unit tested
  * @see   Jetpack_Network::jetpack_sites_list();
  */
 public function do_subsiteregister($site_id = null)
 {
     if (!current_user_can('jetpack_disconnect')) {
         return;
     }
     $jp = Jetpack::init();
     // Figure out what site we are working on
     $site_id = is_null($site_id) ? $_GET['site_id'] : $site_id;
     // Build secrets to sent to wpcom for verification
     $secrets = $jp->generate_secrets();
     // Remote query timeout limit
     $timeout = $jp->get_remote_query_timeout_limit();
     // The blog id on WordPress.com of the primary network site
     $network_wpcom_blog_id = Jetpack_Options::get_option('id');
     /*
      * Here we need to switch to the subsite
      * For the registration process we really only hijack how it
      * works for an individual site and pass in some extra data here
      */
     switch_to_blog($site_id);
     // Save the secrets in the subsite so when the wpcom server does a pingback it
     // will be able to validate the connection
     Jetpack_Options::update_option('register', $secrets[0] . ':' . $secrets[1] . ':' . $secrets[2]);
     // Gra info for gmt offset
     $gmt_offset = get_option('gmt_offset');
     if (!$gmt_offset) {
         $gmt_offset = 0;
     }
     /*
      * Get the stats_option option from the db.
      * It looks like the server strips this out so maybe it is not necessary?
      * Does it match the Jetpack site with the old stats plugin id?
      *
      * @todo Find out if sending the stats_id is necessary
      */
     $stat_options = get_option('stats_options');
     $stat_id = $stat_options = isset($stats_options['blog_id']) ? $stats_options['blog_id'] : null;
     $args = array('method' => 'POST', 'body' => array('network_url' => $this->get_url('network_admin_page'), 'network_wpcom_blog_id' => $network_wpcom_blog_id, 'siteurl' => site_url(), 'home' => home_url(), 'gmt_offset' => $gmt_offset, 'timezone_string' => (string) get_option('timezone_string'), 'site_name' => (string) get_option('blogname'), 'secret_1' => $secrets[0], 'secret_2' => $secrets[1], 'site_lang' => get_locale(), 'timeout' => $timeout, 'stats_id' => $stat_id, 'user_id' => get_current_user_id()), 'headers' => array('Accept' => 'application/json'), 'timeout' => $timeout);
     // Attempt to retrieve shadow blog details
     $response = Jetpack_Client::_wp_remote_request(Jetpack::fix_url_for_bad_hosts(Jetpack::api_url('subsiteregister')), $args, true);
     /*
      * $response should either be invalid or contain:
      * - jetpack_id	=> id
      * - jetpack_secret => blog_token
      * - jetpack_public
      *
      * Store the wpcom site details
      */
     $valid_response = $jp->validate_remote_register_response($response);
     if (is_wp_error($valid_response) || !$valid_response) {
         restore_current_blog();
         return $valid_response;
     }
     // Grab the response values to work with
     $code = wp_remote_retrieve_response_code($response);
     $entity = wp_remote_retrieve_body($response);
     if ($entity) {
         $json = json_decode($entity);
     } else {
         $json = false;
     }
     if (empty($json->jetpack_secret) || !is_string($json->jetpack_secret)) {
         restore_current_blog();
         return new Jetpack_Error('jetpack_secret', '', $code);
     }
     if (isset($json->jetpack_public)) {
         $jetpack_public = (int) $json->jetpack_public;
     } else {
         $jetpack_public = false;
     }
     Jetpack_Options::update_options(array('id' => (int) $json->jetpack_id, 'blog_token' => (string) $json->jetpack_secret, 'public' => $jetpack_public));
     /*
      * Update the subsiteregister method on wpcom so that it also sends back the
      * token in this same request
      */
     $is_master_user = !Jetpack::is_active();
     Jetpack::update_user_token(get_current_user_id(), sprintf('%s.%d', $json->token->secret, get_current_user_id()), $is_master_user);
     Jetpack::activate_default_modules();
     restore_current_blog();
 }
开发者ID:tinggao,项目名称:woofWarrior,代码行数:87,代码来源:class.jetpack-network.php

示例15: options_save_tumblr

 function options_save_tumblr()
 {
     // Nonce check
     check_admin_referer('save_tumblr_blog_' . $_REQUEST['connection']);
     $id = $_POST['connection'];
     $options = array('tumblr_base_hostname' => $_POST['selected_id']);
     Jetpack::load_xml_rpc_client();
     $xml = new Jetpack_IXR_Client();
     $xml->query('jetpack.setPublicizeOptions', $id, $options);
     if (!$xml->isError()) {
         $response = $xml->getResponse();
         Jetpack_Options::update_option('publicize_connections', $response);
     }
     $this->globalization();
 }
开发者ID:kanei,项目名称:vantuch.cz,代码行数:15,代码来源:publicize-jetpack.php


注:本文中的Jetpack_Options::update_option方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。