Expose post format details in XML-RPC:
- New method: wp.getPostFormats - New field in methods dealing with posts: wp_post_format props ericmann, fixes #15405 git-svn-id: http://svn.automattic.com/wordpress/trunk@16484 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
90a0e069e9
commit
43ff5a69a8
|
@ -63,6 +63,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
'wp.getCommentStatusList' => 'this:wp_getCommentStatusList',
|
||||
'wp.getMediaItem' => 'this:wp_getMediaItem',
|
||||
'wp.getMediaLibrary' => 'this:wp_getMediaLibrary',
|
||||
'wp.getPostFormats' => 'this:wp_getPostFormats',
|
||||
|
||||
// Blogger API
|
||||
'blogger.getUsersBlogs' => 'this:blogger_getUsersBlogs',
|
||||
|
@ -1602,6 +1603,31 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
return $attachments_struct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrives a list of post formats used by the site
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @param array $args Method parameters. Contains:
|
||||
* - blog_id
|
||||
* - username
|
||||
* - password
|
||||
* @return array
|
||||
*/
|
||||
function wp_getPostFormats( $args ) {
|
||||
$this->escape( $args );
|
||||
|
||||
$blog_id = (int) $args[0];
|
||||
$username = $args[1];
|
||||
$password = $args[2];
|
||||
|
||||
if ( !$user = $this->login( $username, $password ) )
|
||||
return $this->error;
|
||||
|
||||
do_action( 'xmlrpc_call', 'wp.getPostFormats' );
|
||||
return get_post_format_strings();
|
||||
}
|
||||
|
||||
/* Blogger API functions.
|
||||
* specs on http://plant.blogger.com/api and http://groups.yahoo.com/group/bloggerDev/
|
||||
*/
|
||||
|
@ -2083,6 +2109,14 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
if ( !current_user_can( $cap ) )
|
||||
return new IXR_Error( 401, $error_message );
|
||||
|
||||
// Check for a valid post format if one was given
|
||||
if ( isset( $content_struct['wp_post_format'] ) ) {
|
||||
$content_struct['wp_post_format'] = sanitize_key( $content_struct['wp_post_format'] );
|
||||
if ( !array_key_exists( $content_struct['wp_post_format'], get_post_format_strings() ) ) {
|
||||
return new IXR_Error( 404, __( 'Invalid post format' ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Let WordPress generate the post_name (slug) unless
|
||||
// one has been provided.
|
||||
$post_name = "";
|
||||
|
@ -2267,6 +2301,11 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
|
||||
$this->attach_uploads( $post_ID, $post_content );
|
||||
|
||||
// Handle post formats if assigned, value is validated earlier
|
||||
// in this function
|
||||
if ( isset( $content_struct['wp_post_format'] ) )
|
||||
wp_set_post_terms( $post_ID, array( 'post-format-' . $content_struct['wp_post_format'] ), 'post_format' );
|
||||
|
||||
logIO('O', "Posted ! ID: $post_ID");
|
||||
|
||||
return strval($post_ID);
|
||||
|
@ -2358,6 +2397,14 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
if ( !current_user_can( $cap ) )
|
||||
return new IXR_Error( 401, $error_message );
|
||||
|
||||
// Check for a valid post format if one was given
|
||||
if ( isset( $content_struct['wp_post_format'] ) ) {
|
||||
$content_struct['wp_post_format'] = sanitize_key( $content_struct['wp_post_format'] );
|
||||
if ( !array_key_exists( $content_struct['wp_post_format'], get_post_format_strings() ) ) {
|
||||
return new IXR_Error( 404, __( 'Invalid post format' ) );
|
||||
}
|
||||
}
|
||||
|
||||
$postdata = wp_get_single_post($post_ID, ARRAY_A);
|
||||
|
||||
// If there is no post data for the give post id, stop
|
||||
|
@ -2553,6 +2600,11 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
|
||||
$this->attach_uploads( $ID, $post_content );
|
||||
|
||||
// Handle post formats if assigned, validation is handled
|
||||
// earlier in this function
|
||||
if ( isset( $content_struct['wp_post_format'] ) )
|
||||
wp_set_post_terms( $post_ID, array( 'post-format-' . $content_struct['wp_post_format'] ), 'post_format' );
|
||||
|
||||
logIO('O',"(MW) Edited ! ID: $post_ID");
|
||||
|
||||
return true;
|
||||
|
@ -2620,6 +2672,11 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
if ( $postdata['post_status'] === 'future' )
|
||||
$postdata['post_status'] = 'publish';
|
||||
|
||||
// Get post format
|
||||
$post_format = get_post_format( $post_ID );
|
||||
if ( empty( $post_format ) )
|
||||
$post_format = 'default';
|
||||
|
||||
$sticky = false;
|
||||
if ( is_sticky( $post_ID ) )
|
||||
$sticky = true;
|
||||
|
@ -2660,6 +2717,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
'date_created_gmt' => new IXR_Date($post_date_gmt),
|
||||
'post_status' => $postdata['post_status'],
|
||||
'custom_fields' => $this->get_custom_fields($post_ID),
|
||||
'wp_post_format' => $post_format,
|
||||
'sticky' => $sticky
|
||||
);
|
||||
|
||||
|
@ -2741,6 +2799,11 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
if ( $entry['post_status'] === 'future' )
|
||||
$entry['post_status'] = 'publish';
|
||||
|
||||
// Get post format
|
||||
$post_format = get_post_format( $entry['ID'] );
|
||||
if ( empty( $post_format ) )
|
||||
$post_format = 'default';
|
||||
|
||||
$struct[] = array(
|
||||
'dateCreated' => new IXR_Date($post_date),
|
||||
'userid' => $entry['post_author'],
|
||||
|
@ -2763,7 +2826,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
'wp_author_display_name' => $author->display_name,
|
||||
'date_created_gmt' => new IXR_Date($post_date_gmt),
|
||||
'post_status' => $entry['post_status'],
|
||||
'custom_fields' => $this->get_custom_fields($entry['ID'])
|
||||
'custom_fields' => $this->get_custom_fields($entry['ID']),
|
||||
'wp_post_format' => $post_format
|
||||
);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue