예제 #1
0
파일: post.php 프로젝트: roelven/wp-cli
 /**
  * Delete a post
  *
  * @param array $args
  * @param array $assoc_args
  */
 public function delete($args, $assoc_args)
 {
     $post_id = WP_CLI::get_numeric_arg($args, 0, "Post ID");
     if (wp_delete_post($post_id, isset($assoc_args['force']))) {
         WP_CLI::success("Deleted post {$post_id}.");
     } else {
         WP_CLI::error("Failed deleting post {$post_id}.");
     }
 }
 /**
  * Update meta field for a user
  *
  * @param array $args
  * @param array $assoc_args
  **/
 public function update($args, $assoc_args)
 {
     $object_id = WP_CLI::get_numeric_arg($args, 0, "{$this->meta_type} ID");
     $meta_key = self::get_arg_or_error($args, 1, "meta_key");
     $meta_value = self::get_arg_or_error($args, 2, "meta_value");
     $success = update_metadata($this->meta_type, $object_id, $meta_key, $meta_value);
     if ($success) {
         WP_CLI::success("Updated custom field.");
     } else {
         WP_CLI::error("Failed to update custom field.");
     }
 }
예제 #3
0
파일: user.php 프로젝트: roelven/wp-cli
 /**
  * Update a user
  *
  * @param array $args
  * @param array $assoc_args
  **/
 public function update($args, $assoc_args)
 {
     $user_id = WP_CLI::get_numeric_arg($args, 0, "User ID");
     if (empty($assoc_args)) {
         WP_CLI::error("Need some fields to update.");
     }
     $params = array_merge(array('ID' => $user_id), $assoc_args);
     $updated_id = wp_update_user($params);
     if (is_wp_error($updated_id)) {
         WP_CLI::error($updated_id);
     } else {
         WP_CLI::success("Updated user {$updated_id}.");
     }
 }
예제 #4
0
 /**
  * Get status of a comment
  *
  * Example: wp comment status 15
  *
  * @param array $args}
  * @param array $assoc_args
  */
 public function status($args, $assoc_args)
 {
     $comment_id = WP_CLI::get_numeric_arg($args, 0, "Comment ID");
     $status = wp_get_comment_status($comment_id);
     if (false === $status) {
         WP_CLI::error("Could not check status of comment {$comment}");
     } else {
         WP_CLI::line($status);
     }
 }