wp_xmlrpc_server::mt_publishPost() WordPress Method
The wp_xmlrpc_server::mt_publishPost() method is used to publish a post on a WordPress blog. This method can be used by any XML-RPC client that supports the WordPress API.
wp_xmlrpc_server::mt_publishPost( array $args ) #
Sets a post’s publish status to ‘publish’.
Parameters
- $args
(array)(Required)Method arguments. Note: arguments must be ordered as documented.
- 'post_ID'
(int) - 'username'
(string) - 'password'
(string)
- 'post_ID'
Return
(int|IXR_Error)
Source
File: wp-includes/class-wp-xmlrpc-server.php
public function mt_publishPost( $args ) { $this->escape( $args ); $post_ID = (int) $args[0]; $username = $args[1]; $password = $args[2]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ do_action( 'xmlrpc_call', 'mt.publishPost', $args, $this ); $postdata = get_post( $post_ID, ARRAY_A ); if ( ! $postdata ) { return new IXR_Error( 404, __( 'Invalid post ID.' ) ); } if ( ! current_user_can( 'publish_posts' ) || ! current_user_can( 'edit_post', $post_ID ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) ); } $postdata['post_status'] = 'publish'; // Retain old categories. $postdata['post_category'] = wp_get_post_categories( $post_ID ); $this->escape( $postdata ); return wp_update_post( $postdata ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
1.5.0 | Introduced. |