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


PHP Jetpack::unlink_user方法代码示例

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


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

示例1: disconnect

 /**
  * Disconnect Jetpack Blogs or Users
  *
  * ## OPTIONS
  *
  * blog: Disconnect the entire blog.
  *
  * user <user_identifier>: Disconnect a specific user from WordPress.com.
  *
  * Please note, the primary account that the blog is connected
  * to WordPress.com with cannot be disconnected without
  * disconnecting the entire blog.
  *
  * ## EXAMPLES
  *
  * wp jetpack disconnect blog
  * wp jetpack disconnect user 13
  * wp jetpack disconnect user username
  * wp jetpack disconnect user email@domain.com
  *
  * @synopsis <blog|user> [<user_identifier>]
  */
 public function disconnect($args, $assoc_args)
 {
     if (!Jetpack::is_active()) {
         WP_CLI::error(__('You cannot disconnect, without having first connected.', 'jetpack'));
     }
     $action = isset($args[0]) ? $args[0] : 'prompt';
     if (!in_array($action, array('blog', 'user', 'prompt'))) {
         WP_CLI::error(sprintf(__('%s is not a valid command.', 'jetpack'), $action));
     }
     if (in_array($action, array('user'))) {
         if (isset($args[1])) {
             $user_id = $args[1];
             if (ctype_digit($user_id)) {
                 $field = 'id';
                 $user_id = (int) $user_id;
             } elseif (is_email($user_id)) {
                 $field = 'email';
                 $user_id = sanitize_user($user_id, true);
             } else {
                 $field = 'login';
                 $user_id = sanitize_user($user_id, true);
             }
             if (!($user = get_user_by($field, $user_id))) {
                 WP_CLI::error(__('Please specify a valid user.', 'jetpack'));
             }
         } else {
             WP_CLI::error(__('Please specify a user by either ID, username, or email.', 'jetpack'));
         }
     }
     switch ($action) {
         case 'blog':
             Jetpack::log('disconnect');
             Jetpack::disconnect();
             WP_CLI::success(__('Jetpack has been successfully disconnected.', 'jetpack'));
             break;
         case 'user':
             if (Jetpack::unlink_user($user->ID)) {
                 Jetpack::log('unlink', $user->ID);
                 WP_CLI::success(sprintf(__('%s has been successfully disconnected.', 'jetpack'), $action));
             } else {
                 WP_CLI::error(sprintf(__('%s could not be disconnected.  Are you sure they\'re connected currently?', 'jetpack'), "{$user->login} <{$user->email}>"));
             }
             break;
         case 'prompt':
             WP_CLI::error(__('Please specify if you would like to disconnect a blog or user.', 'jetpack'));
             break;
     }
 }
开发者ID:kanei,项目名称:vantuch.cz,代码行数:70,代码来源:class.jetpack-cli.php

示例2: unlink_user

 /**
  * Unlink a user from WordPress.com
  *
  * This will fail if called by the Master User.
  */
 function unlink_user()
 {
     Jetpack::log('unlink');
     return Jetpack::unlink_user();
 }
开发者ID:jordankoschei,项目名称:jordankoschei-dot-com,代码行数:10,代码来源:class.jetpack-xmlrpc-server.php

示例3: unlink_user

 /**
  * Unlinks current user from the WordPress.com Servers.
  *
  * @since 4.3.0
  * @uses  Jetpack::unlink_user
  *
  * @return bool|WP_Error True if user successfully unlinked.
  */
 public static function unlink_user($data)
 {
     $param = $data->get_json_params();
     if (!isset($param['linked']) || $param['linked'] !== false) {
         return new WP_Error('invalid_param', esc_html__('Invalid Parameter', 'jetpack'), array('status' => 404));
     }
     if (Jetpack::unlink_user()) {
         return rest_ensure_response(array('code' => 'success'));
     }
     return new WP_Error('unlink_user_failed', esc_html__('Was not able to unlink the user.  Please try again.', 'jetpack'), array('status' => 400));
 }
开发者ID:iamtakashi,项目名称:jetpack,代码行数:19,代码来源:class.core-rest-api-endpoints.php

示例4: unlink_user

 /**
  * Unlinks a user from the WordPress.com Servers.
  * Default $data['id'] will default to current_user_id if no value is given.
  *
  * Example: '/unlink?id=1234'
  *
  * @since 4.1.0
  * @uses  Jetpack::unlink_user
  *
  * @param WP_REST_Request $data {
  *     Array of parameters received by request.
  *
  *     @type int $id ID of user to unlink.
  * }
  *
  * @return bool|WP_Error True if user successfully unlinked.
  */
 public static function unlink_user($data)
 {
     if (isset($data['id']) && Jetpack::unlink_user($data['id'])) {
         return rest_ensure_response(array('code' => 'success'));
     }
     return new WP_Error('unlink_user_failed', esc_html__('Was not able to unlink the user.  Please try again.', 'jetpack'), array('status' => 400));
 }
开发者ID:elliott-stocks,项目名称:jetpack,代码行数:24,代码来源:class.core-rest-api-endpoints.php


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