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


PHP Jetpack::load_xml_rpc_client方法代码示例

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


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

示例1: register_endpoints

    /**
     * Declare the Jetpack REST API endpoints.
     *
     * @since 4.3.0
     */
    public static function register_endpoints()
    {
        // Load API endpoint base classes
        require_once JETPACK__PLUGIN_DIR . '_inc/lib/core-api/class.jetpack-core-api-xmlrpc-consumer-endpoint.php';
        // Load API endpoints
        require_once JETPACK__PLUGIN_DIR . '_inc/lib/core-api/class.jetpack-core-api-module-endpoints.php';
        self::$user_permissions_error_msg = esc_html__('You do not have the correct user permissions to perform this action.
			Please contact your site admin if you think this is a mistake.', 'jetpack');
        self::$stats_roles = array('administrator', 'editor', 'author', 'contributor', 'subscriber');
        // Get current connection status of Jetpack
        register_rest_route('jetpack/v4', '/connection', array('methods' => WP_REST_Server::READABLE, 'callback' => __CLASS__ . '::jetpack_connection_status'));
        // Fetches a fresh connect URL
        register_rest_route('jetpack/v4', '/connection/url', array('methods' => WP_REST_Server::READABLE, 'callback' => __CLASS__ . '::build_connect_url', 'permission_callback' => __CLASS__ . '::connect_url_permission_callback'));
        // Get current user connection data
        register_rest_route('jetpack/v4', '/connection/data', array('methods' => WP_REST_Server::READABLE, 'callback' => __CLASS__ . '::get_user_connection_data', 'permission_callback' => __CLASS__ . '::get_user_connection_data_permission_callback'));
        // Disconnect site from WordPress.com servers
        register_rest_route('jetpack/v4', '/connection', array('methods' => WP_REST_Server::EDITABLE, 'callback' => __CLASS__ . '::disconnect_site', 'permission_callback' => __CLASS__ . '::disconnect_site_permission_callback'));
        // Disconnect/unlink user from WordPress.com servers
        register_rest_route('jetpack/v4', '/connection/user', array('methods' => WP_REST_Server::EDITABLE, 'callback' => __CLASS__ . '::unlink_user', 'permission_callback' => __CLASS__ . '::unlink_user_permission_callback'));
        // Get current site data
        register_rest_route('jetpack/v4', '/site', array('methods' => WP_REST_Server::READABLE, 'callback' => __CLASS__ . '::get_site_data', 'permission_callback' => __CLASS__ . '::view_admin_page_permission_check'));
        // Confirm that a site in identity crisis should be in staging mode
        register_rest_route('jetpack/v4', '/identity-crisis/confirm-safe-mode', array('methods' => WP_REST_Server::EDITABLE, 'callback' => __CLASS__ . '::confirm_safe_mode', 'permission_callback' => __CLASS__ . '::identity_crisis_mitigation_permission_check'));
        // IDC resolve: create an entirely new shadow site for this URL.
        register_rest_route('jetpack/v4', '/identity-crisis/start-fresh', array('methods' => WP_REST_Server::EDITABLE, 'callback' => __CLASS__ . '::start_fresh_connection', 'permission_callback' => __CLASS__ . '::identity_crisis_mitigation_permission_check'));
        // Handles the request to migrate stats and subscribers during an identity crisis.
        register_rest_route('jetpack/v4', 'identity-crisis/migrate', array('methods' => WP_REST_Server::EDITABLE, 'callback' => __CLASS__ . '::migrate_stats_and_subscribers', 'permissison_callback' => __CLASS__ . '::identity_crisis_mitigation_permission_check'));
        // Return all modules
        self::route('module/all', 'Jetpack_Core_API_Module_List_Endpoint', WP_REST_Server::READABLE);
        // Activate many modules
        self::route('/module/all/active', 'Jetpack_Core_API_Module_List_Endpoint', WP_REST_Server::EDITABLE, NULL, array('modules' => array('default' => '', 'type' => 'array', 'required' => true, 'validate_callback' => __CLASS__ . '::validate_module_list'), 'active' => array('default' => true, 'type' => 'boolean', 'required' => false, 'validate_callback' => __CLASS__ . '::validate_boolean')));
        Jetpack::load_xml_rpc_client();
        // Return a single module and update it when needed
        self::route('/module/(?P<slug>[a-z\\-]+)', 'Jetpack_Core_API_Data', WP_REST_Server::READABLE, new Jetpack_IXR_Client(array('user_id' => get_current_user_id())));
        // Activate and deactivate a module
        self::route('/module/(?P<slug>[a-z\\-]+)/active', 'Jetpack_Core_API_Module_Toggle_Endpoint', WP_REST_Server::EDITABLE, new Jetpack_IXR_Client(), array('active' => array('default' => true, 'type' => 'boolean', 'required' => true, 'validate_callback' => __CLASS__ . '::validate_boolean')));
        // Update a module
        self::route('/module/(?P<slug>[a-z\\-]+)', 'Jetpack_Core_API_Data', WP_REST_Server::EDITABLE, new Jetpack_IXR_Client(array('user_id' => get_current_user_id())), self::get_updateable_parameters());
        // Get data for a specific module, i.e. Protect block count, WPCOM stats,
        // Akismet spam count, etc.
        self::route('/module/(?P<slug>[a-z\\-]+)/data', 'Jetpack_Core_API_Module_Data_Endpoint', WP_REST_Server::READABLE, NULL, array('range' => array('default' => 'day', 'type' => 'string', 'required' => false, 'validate_callback' => __CLASS__ . '::validate_string')));
        // Update any Jetpack module option or setting
        self::route('/settings', 'Jetpack_Core_API_Data', WP_REST_Server::EDITABLE, new Jetpack_IXR_Client(array('user_id' => get_current_user_id())), self::get_updateable_parameters('any'));
        // Update a module
        self::route('/settings/(?P<slug>[a-z\\-]+)', 'Jetpack_Core_API_Data', WP_REST_Server::EDITABLE, new Jetpack_IXR_Client(array('user_id' => get_current_user_id())), self::get_updateable_parameters());
        // Return miscellaneous settings
        register_rest_route('jetpack/v4', '/settings', array('methods' => WP_REST_Server::READABLE, 'callback' => __CLASS__ . '::get_settings', 'permission_callback' => __CLASS__ . '::view_admin_page_permission_check'));
        // Reset all Jetpack options
        register_rest_route('jetpack/v4', '/options/(?P<options>[a-z\\-]+)', array('methods' => WP_REST_Server::EDITABLE, 'callback' => __CLASS__ . '::reset_jetpack_options', 'permission_callback' => __CLASS__ . '::manage_modules_permission_check'));
        // Jumpstart
        register_rest_route('jetpack/v4', '/jumpstart', array('methods' => WP_REST_Server::EDITABLE, 'callback' => __CLASS__ . '::jumpstart_toggle', 'permission_callback' => __CLASS__ . '::manage_modules_permission_check', 'args' => array('active' => array('required' => true, 'validate_callback' => __CLASS__ . '::validate_boolean'))));
        // Updates: get number of plugin updates available
        register_rest_route('jetpack/v4', '/updates/plugins', array('methods' => WP_REST_Server::READABLE, 'callback' => __CLASS__ . '::get_plugin_update_count', 'permission_callback' => __CLASS__ . '::view_admin_page_permission_check'));
        // Dismiss Jetpack Notices
        register_rest_route('jetpack/v4', '/notice/(?P<notice>[a-z\\-_]+)', array('methods' => WP_REST_Server::EDITABLE, 'callback' => __CLASS__ . '::dismiss_notice', 'permission_callback' => __CLASS__ . '::view_admin_page_permission_check'));
        // Plugins: get list of all plugins.
        register_rest_route('jetpack/v4', '/plugins', array('methods' => WP_REST_Server::READABLE, 'callback' => __CLASS__ . '::get_plugins', 'permission_callback' => __CLASS__ . '::activate_plugins_permission_check'));
        // Plugins: check if the plugin is active.
        register_rest_route('jetpack/v4', '/plugin/(?P<plugin>[a-z\\/\\.\\-_]+)', array('methods' => WP_REST_Server::READABLE, 'callback' => __CLASS__ . '::get_plugin', 'permission_callback' => __CLASS__ . '::activate_plugins_permission_check'));
    }
开发者ID:automattic,项目名称:jetpack,代码行数:65,代码来源:class.core-rest-api-endpoints.php

示例2: wpcom_switch_blog_owner

 function wpcom_switch_blog_owner($new_master)
 {
     $request = array('new_blog_owner' => $new_master);
     // Tell wpcom about the change
     Jetpack::load_xml_rpc_client();
     $xml = new Jetpack_IXR_Client(array('user_id' => get_current_user_id()));
     $xml->query('jetpack.switchBlogOwner', $request);
 }
开发者ID:StefanBonilla,项目名称:CoupSoup,代码行数:8,代码来源:class.jetpack-my-jetpack-page.php

示例3: send_data

 static function send_data($data)
 {
     Jetpack::load_xml_rpc_client();
     // add an extra parameter to the URL so we can tell it's a sync action
     $url = add_query_arg('sync', '1', Jetpack::xmlrpc_api_url());
     $rpc = new Jetpack_IXR_Client(array('url' => $url, 'user_id' => get_current_user_id(), 'timeout' => 30));
     $result = $rpc->query('jetpack.syncActions', $data);
     if (!$result) {
         return $rpc->get_jetpack_error();
     }
     return $rpc->getResponse();
 }
开发者ID:elliott-stocks,项目名称:jetpack,代码行数:12,代码来源:class.jetpack-sync-actions.php

示例4: test_Jetpack_Core_API_XMLRPC_Consumer_Endpoint_privacy_check

 /**
  * @author zinigor
  * @covers Jetpack_Core_XMLRPC_Consumer_Endpoint
  * @requires PHP 5.2
  * @dataProvider true_false_provider
  */
 public function test_Jetpack_Core_API_XMLRPC_Consumer_Endpoint_privacy_check($query_success, $result)
 {
     Jetpack::load_xml_rpc_client();
     $xmlrpc_mock = $this->getMockBuilder('Jetpack_IXR_Client')->setMethods(array('query', 'getResponse'))->getMock();
     $endpoint = new WP_Test_Dummy_Xmlrpc_Consumer_Endpoint($xmlrpc_mock);
     $xmlrpc_mock->expects($this->once())->method('query')->with('jetpack.isSitePubliclyAccessible', home_url())->willReturn($query_success);
     if ($query_success) {
         $xmlrpc_mock->expects($this->once())->method('getResponse')->willReturn($result);
     } else {
         $xmlrpc_mock->expects($this->never())->method('getResponse');
     }
     $this->assertEquals($result, $endpoint->process(null));
 }
开发者ID:iamtakashi,项目名称:jetpack,代码行数:19,代码来源:test_class.jetpack-core-api-xmlrpc-consumer-endpoint.php

示例5: is_frame_nonce_valid

 /**
  * Verify that frame nonce exists, and if so, validate the nonce by calling WP.com.
  *
  * @since 4.4.0
  *
  * @return bool
  */
 public function is_frame_nonce_valid()
 {
     if (empty($_GET['frame-nonce'])) {
         return false;
     }
     Jetpack::load_xml_rpc_client();
     $xml = new Jetpack_IXR_Client();
     $xml->query('jetpack.verifyFrameNonce', sanitize_key($_GET['frame-nonce']));
     if ($xml->isError()) {
         return false;
     }
     return (bool) $xml->getResponse();
 }
开发者ID:kanei,项目名称:vantuch.cz,代码行数:20,代码来源:class.frame-nonce-preview.php

示例6: send_data

 static function send_data($data, $codec_name, $sent_timestamp, $queue_id)
 {
     Jetpack::load_xml_rpc_client();
     $query_args = array('sync' => '1', 'codec' => $codec_name, 'timestamp' => $sent_timestamp, 'queue' => $queue_id);
     if (Jetpack::sync_idc_optin()) {
         $query_args['home'] = get_home_url();
         // Send home url option to check for Identity Crisis server-side
         $query_args['siteurl'] = get_site_url();
         // Send home url option to check for Identity Crisis server-side
     }
     $url = add_query_arg($query_args, Jetpack::xmlrpc_api_url());
     $rpc = new Jetpack_IXR_Client(array('url' => $url, 'user_id' => JETPACK_MASTER_USER, 'timeout' => 30));
     $result = $rpc->query('jetpack.syncActions', $data);
     if (!$result) {
         return $rpc->get_jetpack_error();
     }
     return $rpc->getResponse();
 }
开发者ID:pacificano,项目名称:pacificano,代码行数:18,代码来源:class.jetpack-sync-actions.php

示例7: 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;
 }
开发者ID:elliott-stocks,项目名称:jetpack,代码行数:18,代码来源:class.jetpack-sync-reindex.php

示例8: log_items

 /**
  * Iterates through expected items ( plugins or themes ) and compares them to actual results.
  *
  * @param $items 'plugin' or 'theme'
  */
 function log_items($items)
 {
     $num_items_updated = 0;
     $num_items_failed = 0;
     $item_results = $this->get_successful_updates($items);
     $items_failed = array();
     foreach ($this->autoupdate_expected[$items] as $item) {
         if (in_array($item, $item_results)) {
             $num_items_updated++;
             $this->log[$items][$item] = true;
         } else {
             $num_items_failed++;
             $this->log[$items][$item] = new WP_Error("{$items}-fail", $this->get_error_message($item, $type = $items));
             $items_failed[] = $item;
         }
     }
     if ($num_items_updated) {
         $this->jetpack->stat("autoupdates/{$items}-success", $num_items_updated);
     }
     if ($num_items_failed) {
         // bump stats
         $this->jetpack->stat("autoupdates/{$items}-fail", $num_items_failed);
         Jetpack::load_xml_rpc_client();
         $xml = new Jetpack_IXR_Client(array('user_id' => get_current_user_id()));
         $request = array('plugins' => $items_failed, 'blog_id' => Jetpack_Options::get_option('id'));
         $xml->query('jetpack.debug_autoupdate', $request);
     }
 }
开发者ID:walkthenight,项目名称:walkthenight-wordpress,代码行数:33,代码来源:class.jetpack-autoupdate.php

示例9: 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::update_option('publicize_connections', $response);
     }
     $this->globalization();
 }
开发者ID:kevinreilly,项目名称:mendelements.com,代码行数:15,代码来源:publicize-jetpack.php

示例10: send_data

 static function send_data($data, $codec_name, $sent_timestamp, $queue_id)
 {
     Jetpack::load_xml_rpc_client();
     $url = add_query_arg(array('sync' => '1', 'codec' => $codec_name, 'timestamp' => $sent_timestamp, 'queue' => $queue_id), Jetpack::xmlrpc_api_url());
     $rpc = new Jetpack_IXR_Client(array('url' => $url, 'user_id' => JETPACK_MASTER_USER, 'timeout' => 30));
     $result = $rpc->query('jetpack.syncActions', $data);
     if (!$result) {
         return $rpc->get_jetpack_error();
     }
     return $rpc->getResponse();
 }
开发者ID:kanei,项目名称:vantuch.cz,代码行数:11,代码来源:class.jetpack-sync-actions.php

示例11: monitor_get_last_downtime

 public function monitor_get_last_downtime()
 {
     //		if ( $last_down = get_transient( 'monitor_last_downtime' ) ) {
     //			return $last_down;
     //		}
     Jetpack::load_xml_rpc_client();
     $xml = new Jetpack_IXR_Client(array('user_id' => get_current_user_id()));
     $xml->query('jetpack.monitor.getLastDowntime');
     if ($xml->isError()) {
         return new WP_Error('monitor-downtime', $xml->getErrorMessage());
     }
     set_transient('monitor_last_downtime', $xml->getResponse(), 10 * MINUTE_IN_SECONDS);
     return $xml->getResponse();
 }
开发者ID:kanei,项目名称:vantuch.cz,代码行数:14,代码来源:monitor.php

示例12: monitor_get_last_downtime

 public function monitor_get_last_downtime()
 {
     Jetpack::load_xml_rpc_client();
     $xml = new Jetpack_IXR_Client(array('user_id' => get_current_user_id()));
     $xml->query('jetpack.monitor.getLastDowntime');
     if ($xml->isError()) {
         return new WP_Error('monitor-downtime', $xml->getErrorMessage());
     }
     return $xml->getResponse();
 }
开发者ID:pcuervo,项目名称:wp-carnival,代码行数:10,代码来源:monitor.php

示例13: handle_login

 /**
  * The function that actually handles the login!
  */
 function handle_login()
 {
     $wpcom_nonce = sanitize_key($_GET['sso_nonce']);
     $wpcom_user_id = (int) $_GET['user_id'];
     $result = sanitize_key($_GET['result']);
     Jetpack::load_xml_rpc_client();
     $xml = new Jetpack_IXR_Client(array('user_id' => get_current_user_id()));
     $xml->query('jetpack.sso.validateResult', $wpcom_nonce, $wpcom_user_id);
     if ($xml->isError()) {
         wp_die(sprintf('%s: %s', $xml->getErrorCode(), $xml->getErrorMessage()));
     }
     $user_data = $xml->getResponse();
     if (empty($user_data)) {
         wp_die(__('Error, invalid response data.', 'jetpack'));
     }
     $user_data = (object) $user_data;
     $user = null;
     /**
      * Fires before Jetpack's SSO modifies the log in form.
      *
      * @module sso
      *
      * @since 2.6.0
      *
      * @param object $user_data User login information.
      */
     do_action('jetpack_sso_pre_handle_login', $user_data);
     /**
      * Is it required to have 2-step authentication enabled on WordPress.com to use SSO?
      *
      * @module sso
      *
      * @since 2.8.0
      *
      * @param bool get_option( 'jetpack_sso_require_two_step' ) Does SSO require 2-step authentication?
      */
     $require_two_step = apply_filters('jetpack_sso_require_two_step', get_option('jetpack_sso_require_two_step'));
     if ($require_two_step && 0 == (int) $user_data->two_step_enabled) {
         $this->user_data = $user_data;
         /** This filter is documented in core/src/wp-includes/pluggable.php */
         do_action('wp_login_failed', $user_data->login);
         add_action('login_message', array($this, 'error_msg_enable_two_step'));
         return;
     }
     if (isset($_GET['state']) && 0 < strpos($_GET['state'], '|')) {
         list($state, $nonce) = explode('|', $_GET['state']);
         if (wp_verify_nonce($nonce, $state)) {
             if ('sso-link-user' == $state) {
                 $user = wp_get_current_user();
                 update_user_meta($user->ID, 'wpcom_user_id', $user_data->ID);
                 add_filter('login_redirect', array(__CLASS__, 'profile_page_url'));
             }
         } else {
             wp_nonce_ays();
         }
     }
     if (empty($user)) {
         $user = $this->get_user_by_wpcom_id($user_data->ID);
     }
     // If we don't have one by wpcom_user_id, try by the email?
     if (empty($user) && self::match_by_email()) {
         $user = get_user_by('email', $user_data->email);
         if ($user) {
             update_user_meta($user->ID, 'wpcom_user_id', $user_data->ID);
         }
     }
     // If we've still got nothing, create the user.
     if (empty($user) && (get_option('users_can_register') || self::new_user_override())) {
         // If not matching by email we still need to verify the email does not exist
         // or this blows up
         /**
          * If match_by_email is true, we know the email doesn't exist, as it would have
          * been found in the first pass.  If get_user_by( 'email' ) doesn't find the
          * user, then we know that email is unused, so it's safe to add.
          */
         if (self::match_by_email() || !get_user_by('email', $user_data->email)) {
             $username = $user_data->login;
             if (username_exists($username)) {
                 $username = $user_data->login . '_' . $user_data->ID;
             }
             $tries = 0;
             while (username_exists($username)) {
                 $username = $user_data->login . '_' . $user_data->ID . '_' . mt_rand();
                 if ($tries++ >= 5) {
                     wp_die(__("Error: Couldn't create suitable username.", 'jetpack'));
                 }
             }
             $password = wp_generate_password(20);
             $user_id = wp_create_user($username, $password, $user_data->email);
             $user = get_userdata($user_id);
             $user->display_name = $user_data->display_name;
             $user->first_name = $user_data->first_name;
             $user->last_name = $user_data->last_name;
             $user->url = $user_data->url;
             $user->description = $user_data->description;
             wp_update_user($user);
             update_user_meta($user->ID, 'wpcom_user_id', $user_data->ID);
//.........这里部分代码省略.........
开发者ID:laurelfulford,项目名称:jetpack,代码行数:101,代码来源:sso.php

示例14: get_jetpack_user

 private static function get_jetpack_user()
 {
     if (!class_exists('Jetpack')) {
         return false;
     }
     Jetpack::load_xml_rpc_client();
     $xml = new Jetpack_IXR_ClientMulticall(array('user_id' => get_current_user_id()));
     $xml->addCall('wpcom.getUserID');
     $xml->addCall('akismet.getAPIKey');
     $xml->query();
     Akismet::log(compact('xml'));
     if (!$xml->isError()) {
         $responses = $xml->getResponse();
         if (count($responses) > 1) {
             $api_key = array_shift($responses[0]);
             $user_id = (int) array_shift($responses[1]);
             return compact('api_key', 'user_id');
         }
     }
     return false;
 }
开发者ID:valiror,项目名称:sharingdais_demo1,代码行数:21,代码来源:class.akismet-admin.php

示例15: bump_stats

 public function bump_stats()
 {
     $instance = Jetpack::init();
     $log = array();
     // Bump numbers
     if (!empty($this->success['plugin'])) {
         $instance->stat('autoupdates/plugin-success', count($this->success['plugin']));
         $log['plugins_success'] = $this->success['plugin'];
     }
     if (!empty($this->failed['plugin'])) {
         $instance->stat('autoupdates/plugin-fail', count($this->failed['plugin']));
         $log['plugins_failed'] = $this->failed['plugin'];
     }
     if (!empty($this->success['theme'])) {
         $instance->stat('autoupdates/theme-success', count($this->success['theme']));
         $log['themes_success'] = $this->success['theme'];
     }
     if (!empty($this->failed['theme'])) {
         $instance->stat('autoupdates/theme-fail', count($this->failed['theme']));
         $log['themes_failed'] = $this->failed['theme'];
     }
     $instance->do_stats('server_side');
     // Send a more detailed log to logstash
     if (!empty($log)) {
         Jetpack::load_xml_rpc_client();
         $xml = new Jetpack_IXR_Client(array('user_id' => get_current_user_id()));
         $log['blog_id'] = Jetpack_Options::get_option('id');
         $xml->query('jetpack.debug_autoupdate', $log);
     }
 }
开发者ID:jfbelisle,项目名称:magexpress,代码行数:30,代码来源:class.jetpack-autoupdate.php


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