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


PHP Jetpack::xmlrpc_async_call方法代码示例

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


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

 /**
  * Set up all the data and queue it for the outgoing XML-RPC request
  */
 function sync()
 {
     if (!$this->sync) {
         return false;
     }
     $sync_data = $this->get_common_sync_data();
     $wp_importing = defined('WP_IMPORTING') && WP_IMPORTING;
     foreach ($this->sync as $sync_operation_type => $sync_operations) {
         switch ($sync_operation_type) {
             case 'post':
                 if ($wp_importing) {
                     break;
                 }
                 $global_post = isset($GLOBALS['post']) ? $GLOBALS['post'] : null;
                 $GLOBALS['post'] = null;
                 foreach ($sync_operations as $post_id => $settings) {
                     $sync_data['post'][$post_id] = $this->get_post($post_id);
                     if (isset($this->post_transitions[$post_id])) {
                         $sync_data['post'][$post_id]['transitions'] = $this->post_transitions[$post_id];
                     } else {
                         $sync_data['post'][$post_id]['transitions'] = array(false, false);
                     }
                     $sync_data['post'][$post_id]['on_behalf_of'] = $settings['on_behalf_of'];
                 }
                 $GLOBALS['post'] = $global_post;
                 unset($global_post);
                 break;
             case 'comment':
                 if ($wp_importing) {
                     break;
                 }
                 $global_comment = isset($GLOBALS['comment']) ? $GLOBALS['comment'] : null;
                 unset($GLOBALS['comment']);
                 foreach ($sync_operations as $comment_id => $settings) {
                     $sync_data['comment'][$comment_id] = $this->get_comment($comment_id);
                     if (isset($this->comment_transitions[$comment_id])) {
                         $sync_data['comment'][$comment_id]['transitions'] = $this->comment_transitions[$comment_id];
                     } else {
                         $sync_data['comment'][$comment_id]['transitions'] = array(false, false);
                     }
                     $sync_data['comment'][$comment_id]['on_behalf_of'] = $settings['on_behalf_of'];
                 }
                 $GLOBALS['comment'] = $global_comment;
                 unset($global_comment);
                 break;
             case 'option':
                 foreach ($sync_operations as $option => $settings) {
                     $sync_data['option'][$option] = array('value' => get_option($option));
                 }
                 break;
             case 'delete_post':
             case 'delete_comment':
                 foreach ($sync_operations as $object_id => $settings) {
                     $sync_data[$sync_operation_type][$object_id] = array('on_behalf_of' => $settings['on_behalf_of']);
                 }
                 break;
             case 'delete_option':
                 foreach ($sync_operations as $object_id => $settings) {
                     $sync_data[$sync_operation_type][$object_id] = true;
                 }
                 break;
         }
     }
     Jetpack::xmlrpc_async_call('jetpack.syncContent', $sync_data);
 }
开发者ID:briancompton,项目名称:knightsplaza,代码行数:68,代码来源:class.jetpack-sync.php

示例3: sync

 /**
  * Set up all the data and queue it for the outgoing XML-RPC request
  */
 function sync()
 {
     global $wpdb;
     $jetpack = Jetpack::init();
     $sync_data = array('firehose' => apply_filters('jetpack_firehose_toggle', false));
     if (count($this->sync)) {
         foreach ($this->sync as $obj => $data) {
             switch ($obj) {
                 case 'post':
                     $global_post = isset($GLOBALS['post']) ? $GLOBALS['post'] : null;
                     $GLOBALS['post'] = null;
                     foreach ($data as $post => $columns) {
                         $sync_data['post'][$post] = $jetpack->get_post($post, $columns);
                         if (isset($this->post_transitions[$post])) {
                             $sync_data['post'][$post]['transitions'] = $this->post_transitions[$post];
                         } else {
                             $sync_data['post'][$post]['transitions'] = array(false, false);
                         }
                     }
                     $GLOBALS['post'] = $global_post;
                     unset($global_post);
                     break;
                 case 'delete_post':
                     foreach ($data as $post => $true) {
                         $sync_data['delete_post'][$post] = true;
                     }
                     break;
                 case 'comment':
                     $global_comment = isset($GLOBALS['comment']) ? $GLOBALS['comment'] : null;
                     unset($GLOBALS['comment']);
                     foreach ($data as $comment => $columns) {
                         $sync_data['comment'][$comment] = $jetpack->get_comment($comment, $columns);
                     }
                     $GLOBALS['comment'] = $global_comment;
                     unset($global_comment);
                     break;
                 case 'delete_comment':
                     foreach ($data as $comment => $true) {
                         $sync_data['delete_comment'][$comment] = true;
                     }
                     break;
             }
         }
         Jetpack::xmlrpc_async_call('jetpack.syncContent', $sync_data);
     }
 }
开发者ID:Bencheci,项目名称:blueRavenStudiosProject,代码行数:49,代码来源:jetpack.php

示例4: stats_update_blog

function stats_update_blog()
{
    Jetpack::xmlrpc_async_call('jetpack.updateBlog', stats_get_blog());
}
开发者ID:iamtakashi,项目名称:jetpack,代码行数:4,代码来源:stats.php

示例5: subscribe

 /**
  * Jetpack_Subscriptions::subscribe()
  *
  * Send a synchronous XML-RPC subscribe to blog posts or subscribe to post comments request.
  *
  * @param string $email
  * @param array  $post_ids (optional) defaults to 0 for blog posts only: array of post IDs to subscribe to blog's posts
  * @param bool   $async    (optional) Should the subscription be performed asynchronously?  Defaults to true.
  *
  * @return true|Jetpack_Error true on success
  *	invalid_email   : not a valid email address
  *	invalid_post_id : not a valid post ID
  *	unknown_post_id : unknown post
  *	not_subscribed  : strange error.  Jetpack servers at WordPress.com could subscribe the email.
  *	disabled        : Site owner has disabled subscriptions.
  *	active          : Already subscribed.
  *	unknown         : strange error.  Jetpack servers at WordPress.com returned something malformed.
  *	unknown_status  : strange error.  Jetpack servers at WordPress.com returned something I didn't understand.
  */
 function subscribe($email, $post_ids = 0, $async = true, $extra_data = array())
 {
     if (!is_email($email)) {
         return new Jetpack_Error('invalid_email');
     }
     if (!$async) {
         Jetpack::load_xml_rpc_client();
         $xml = new Jetpack_IXR_ClientMulticall();
     }
     foreach ((array) $post_ids as $post_id) {
         $post_id = (int) $post_id;
         if ($post_id < 0) {
             return new Jetpack_Error('invalid_post_id');
         } else {
             if ($post_id && !($post = get_post($post_id))) {
                 return new Jetpack_Error('unknown_post_id');
             }
         }
         if ($async) {
             Jetpack::xmlrpc_async_call('jetpack.subscribeToSite', $email, $post_id, serialize($extra_data));
         } else {
             $xml->addCall('jetpack.subscribeToSite', $email, $post_id, serialize($extra_data));
         }
     }
     if ($async) {
         return;
     }
     // Call
     $xml->query();
     if ($xml->isError()) {
         return $xml->get_jetpack_error();
     }
     $responses = $xml->getResponse();
     $r = array();
     foreach ((array) $responses as $response) {
         if (isset($response['faultCode']) || isset($response['faultString'])) {
             $r[] = $xml->get_jetpack_error($response['faultCode'], $response['faultString']);
             continue;
         }
         if (!is_array($response[0]) || empty($response[0]['status'])) {
             $r[] = new Jetpack_Error('unknown');
             continue;
         }
         switch ($response[0]['status']) {
             case 'error':
                 $r[] = new Jetpack_Error('not_subscribed');
                 continue 2;
             case 'disabled':
                 $r[] = new Jetpack_Error('disabled');
                 continue 2;
             case 'active':
                 $r[] = new Jetpack_Error('active');
                 continue 2;
             case 'pending':
                 $r[] = true;
                 continue 2;
             default:
                 $r[] = new Jetpack_Error('unknown_status', (string) $response[0]['status']);
                 continue 2;
         }
     }
     return $r;
 }
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:82,代码来源:subscriptions.php

示例6: update_role_on_com

 static function update_role_on_com($user_id)
 {
     $signed_role = self::get_signed_role($user_id);
     Jetpack::xmlrpc_async_call('jetpack.updateRole', $user_id, $signed_role);
 }
开发者ID:kanei,项目名称:vantuch.cz,代码行数:5,代码来源:class.jetpack-sync-users.php

示例7: stats_update_post

function stats_update_post($post)
{
    $post = get_post($post);
    if (!in_array($post->post_type, array('post', 'page', 'attachment'))) {
        return;
    }
    if (in_array($post->post_status, array('auto-draft'))) {
        return;
    }
    Jetpack::xmlrpc_async_call('jetpack.updatePost', stats_get_post($post));
}
开发者ID:sajidsan,项目名称:sajidsan.github.io,代码行数:11,代码来源:stats.php

示例8: sync

 /**
  * Set up all the data and queue it for the outgoing XML-RPC request
  */
 function sync()
 {
     global $wpdb;
     $jetpack = Jetpack::init();
     $available_modules = Jetpack::get_available_modules();
     $active_modules = Jetpack::get_active_modules();
     $modules = array();
     foreach ($available_modules as $available_module) {
         $modules[$available_module] = in_array($available_module, $active_modules);
     }
     $modules['vaultpress'] = class_exists('VaultPress') || function_exists('vaultpress_contact_service');
     $sync_data = compact('modules');
     if (count($this->sync)) {
         foreach ($this->sync as $obj => $data) {
             switch ($obj) {
                 case 'post':
                     $global_post = isset($GLOBALS['post']) ? $GLOBALS['post'] : null;
                     $GLOBALS['post'] = null;
                     foreach ($data as $post => $columns) {
                         $sync_data['post'][$post] = $jetpack->get_post($post, $columns);
                         if (isset($this->post_transitions[$post])) {
                             $sync_data['post'][$post]['transitions'] = $this->post_transitions[$post];
                         } else {
                             $sync_data['post'][$post]['transitions'] = array(false, false);
                         }
                     }
                     $GLOBALS['post'] = $global_post;
                     unset($global_post);
                     break;
                 case 'delete_post':
                     foreach ($data as $post => $true) {
                         $sync_data['delete_post'][$post] = true;
                     }
                     break;
                 case 'comment':
                     $global_comment = isset($GLOBALS['comment']) ? $GLOBALS['comment'] : null;
                     unset($GLOBALS['comment']);
                     foreach ($data as $comment => $columns) {
                         $sync_data['comment'][$comment] = $jetpack->get_comment($comment, $columns);
                     }
                     $GLOBALS['comment'] = $global_comment;
                     unset($global_comment);
                     break;
                 case 'delete_comment':
                     foreach ($data as $comment => $true) {
                         $sync_data['delete_comment'][$comment] = true;
                     }
                     break;
                 case 'tag':
                     foreach ($data as $taxonomy => $columns) {
                         $sync_data['tag'][$taxonomy] = $jetpack->get_taxonomy($taxonomy, $columns, 'post_tag');
                     }
                     break;
                 case 'delete_tag':
                     foreach ($data as $taxonomy => $columns) {
                         $sync_data['delete_tag'][$taxonomy] = $columns;
                     }
                     break;
                 case 'category':
                     foreach ($data as $taxonomy => $columns) {
                         $sync_data['category'][$taxonomy] = $jetpack->get_taxonomy($taxonomy, $columns, 'category');
                     }
                     break;
                 case 'delete_category':
                     foreach ($data as $taxonomy => $columns) {
                         $sync_data['delete_category'][$taxonomy] = $columns;
                     }
                     break;
             }
         }
         Jetpack::xmlrpc_async_call('jetpack.syncContent', $sync_data);
     }
 }
开发者ID:jfitzsimmons,项目名称:hoseb.com,代码行数:76,代码来源:jetpack.php


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