wp_xmlrpc_server::mw_getPost() – Retrieve post.
You appear to be a bot. Output may be restricted
Description
Retrieve post.
Usage
$array|IXR_Error = wp_xmlrpc_server::mw_getPost( $args );
Parameters
- $args
- ( array ) required – { Method arguments. Note: arguments must be ordered as documented.
- $0
- ( int ) required – Post ID.
- $1
- ( string ) required – Username.
- $2
- ( string ) required – Password. }
Returns
array|IXR_Error
Source
File name: wordpress/wp-includes/class-wp-xmlrpc-server.php
Lines:
1 to 100 of 126
public function mw_getPost( $args ) { $this->wp_xmlrpc_server::escape( $args ); $post_ID = (int) $args[0]; $username = $args[1]; $password = $args[2]; $user = $this->wp_xmlrpc_server::login( $username, $password ); if ( ! $user ) { return $this->error; } $postdata = get_post( $post_ID, ARRAY_A ); if ( ! $postdata ) { 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.' ) ); } /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ do_action( 'xmlrpc_call', 'metaWeblog.getPost', $args, $this ); if ( '' !== $postdata['post_date'] ) { $post_date = $this->wp_xmlrpc_server::_convert_date( $postdata['post_date'] ); $post_date_gmt = $this->wp_xmlrpc_server::_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); $post_modified = $this->wp_xmlrpc_server::_convert_date( $postdata['post_modified'] ); $post_modified_gmt = $this->wp_xmlrpc_server::_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); $categories = array(); $catids = wp_get_post_categories( $post_ID ); foreach ( $catids as $catid ) { $categories[] = get_cat_name( $catid ); } $tagnames = array(); $tags = wp_get_post_tags( $post_ID ); if ( ! empty( $tags ) ) { foreach ( $tags as $tag ) { $tagnames[] = $tag->name; } $tagnames = implode( ', ', $tagnames ); } else { $tagnames = ''; } $post = get_extended( $postdata['post_content'] ); $link = get_permalink( $postdata['ID'] ); // Get the author info. $author = get_userdata( $postdata['post_author'] ); $allow_comments = ( 'open' === $postdata['comment_status'] ) ? 1 : 0; $allow_pings = ( 'open' === $postdata['ping_status'] ) ? 1 : 0; // Consider future posts as published. if ( 'future' === $postdata['post_status'] ) { $postdata['post_status'] = 'publish'; } // Get post format. $post_format = get_post_format( $post_ID ); if ( empty( $post_format ) ) { $post_format = 'standard'; } $sticky = false; if ( is_sticky( $post_ID ) ) { $sticky = true; } $enclosure = array(); foreach ( (array) get_post_custom( $post_ID ) as $key => $val ) { if ( 'enclosure' === $key ) { foreach ( (array) $val as $enc ) { $encdata = explode( "\n", $enc ); $enclosure['url'] = trim( htmlspecialchars( $encdata[0] ) ); $enclosure['length'] = (int) trim( $encdata[1] ); $enclosure['type'] = trim( $encdata[2] ); break 2; } } } $resp = array( 'dateCreated' => $post_date, 'userid' => $postdata['post_author'], 'postid' => $postdata['ID'], 'description' => $post['main'], 'title' => $postdata['post_title'], 'link' => $link, 'permaLink' => $link, // Commented out because no other tool seems to use this. // 'content' => $entry['post_content'], 'categories' => $categories, 'mt_excerpt' => $postdata['post_excerpt'], 'mt_text_more' => $post['extended'], 'wp_more_text' => $post['more_text'], 'mt_allow_comments' => $allow_comments,