$post =
get_post( $post_id, ARRAY_A
);
if ( empty( $post['ID'
] ) ) { return new IXR_Error( 404,
__( 'Invalid post ID.'
) );
} if ( !
current_user_can( 'edit_post',
$post_id ) ) { return new IXR_Error( 401,
__( 'Sorry, you are not allowed to edit this post.'
) );
} return $this->
_prepare_post( $post,
$fields );
} /**
* Retrieves posts.
*
* @since 3.4.0
*
* @see wp_get_recent_posts()
* @see wp_getPost() for more on `$fields`
* @see get_posts() for more on `$filter` values
*
* @param array $args {
* Method arguments. Note: arguments must be ordered as documented.
*
* @type int $0 Blog ID (unused).
* @type string $1 Username.
* @type string $2 Password.
* @type array $3 Optional. Modifies the query used to retrieve posts. Accepts 'post_type',
* 'post_status', 'number', 'offset', 'orderby', 's', and 'order'.
* Default empty array.
* @type array $4 Optional. The subset of post type fields to return in the response array.
* }
* @return array|IXR_Error Array containing a collection of posts.
*/