Ticket #15405: post-format-rpc.diff
| File post-format-rpc.diff, 4.6 KB (added by josephscott, 3 years ago) |
|---|
-
class-wp-xmlrpc-server.php
63 63 'wp.getCommentStatusList' => 'this:wp_getCommentStatusList', 64 64 'wp.getMediaItem' => 'this:wp_getMediaItem', 65 65 'wp.getMediaLibrary' => 'this:wp_getMediaLibrary', 66 'wp.getPostFormats' => 'this:wp_getPostFormats', 66 67 67 68 // Blogger API 68 69 'blogger.getUsersBlogs' => 'this:blogger_getUsersBlogs', … … 1601 1602 1602 1603 return $attachments_struct; 1603 1604 } 1605 1606 /** 1607 * Retrives a list of post formats used by the site 1608 * 1609 * @since 3.1 1610 * 1611 * @param array $args Method parameters. Contains: 1612 * - blog_id 1613 * - username 1614 * - password 1615 * @return array 1616 */ 1617 function wp_getPostFormats( $args ) { 1618 $this->escape( $args ); 1604 1619 1620 $blog_id = (int) $args[0]; 1621 $username = $args[1]; 1622 $password = $args[2]; 1623 1624 if ( !$user = $this->login( $username, $password ) ) 1625 return $this->error; 1626 1627 do_action( 'xmlrpc_call', 'wp.getPostFormats' ); 1628 return get_post_format_strings(); 1629 } 1630 1605 1631 /* Blogger API functions. 1606 1632 * specs on http://plant.blogger.com/api and http://groups.yahoo.com/group/bloggerDev/ 1607 1633 */ … … 2083 2109 if ( !current_user_can( $cap ) ) 2084 2110 return new IXR_Error( 401, $error_message ); 2085 2111 2112 // Check for a valid post format if one was given 2113 if ( isset( $content_struct['wp_post_format'] ) ) { 2114 $content_struct['wp_post_format'] = sanitize_key( $content_struct['wp_post_format'] ); 2115 if ( !array_key_exists( $content_struct['wp_post_format'], get_post_format_strings() ) ) { 2116 return new IXR_Error( 404, __( 'Invalid post format' ) ); 2117 } 2118 } 2119 2086 2120 // Let WordPress generate the post_name (slug) unless 2087 2121 // one has been provided. 2088 2122 $post_name = ""; … … 2266 2300 $this->add_enclosure_if_new($post_ID, $content_struct['enclosure']); 2267 2301 2268 2302 $this->attach_uploads( $post_ID, $post_content ); 2303 2304 // Handle post formats if assigned, value is validated earlier 2305 // in this function 2306 if ( isset( $content_struct['wp_post_format'] ) ) 2307 wp_set_post_terms( $post_ID, array( 'post-format-' . $content_struct['wp_post_format'] ), 'post_format' ); 2269 2308 2270 2309 logIO('O', "Posted ! ID: $post_ID"); 2271 2310 … … 2358 2397 if ( !current_user_can( $cap ) ) 2359 2398 return new IXR_Error( 401, $error_message ); 2360 2399 2400 // Check for a valid post format if one was given 2401 if ( isset( $content_struct['wp_post_format'] ) ) { 2402 $content_struct['wp_post_format'] = sanitize_key( $content_struct['wp_post_format'] ); 2403 if ( !array_key_exists( $content_struct['wp_post_format'], get_post_format_strings() ) ) { 2404 return new IXR_Error( 404, __( 'Invalid post format' ) ); 2405 } 2406 } 2407 2361 2408 $postdata = wp_get_single_post($post_ID, ARRAY_A); 2362 2409 2363 2410 // If there is no post data for the give post id, stop … … 2552 2599 $this->add_enclosure_if_new($post_ID, $content_struct['enclosure']); 2553 2600 2554 2601 $this->attach_uploads( $ID, $post_content ); 2602 2603 // Handle post formats if assigned, validation is handled 2604 // earlier in this function 2605 if ( isset( $content_struct['wp_post_format'] ) ) 2606 wp_set_post_terms( $post_ID, array( 'post-format-' . $content_struct['wp_post_format'] ), 'post_format' ); 2555 2607 2556 2608 logIO('O',"(MW) Edited ! ID: $post_ID"); 2557 2609 … … 2619 2671 // Consider future posts as published 2620 2672 if ( $postdata['post_status'] === 'future' ) 2621 2673 $postdata['post_status'] = 'publish'; 2674 2675 // Get post format 2676 $post_format = get_post_format( $post_ID ); 2677 if ( empty( $post_format ) ) 2678 $post_format = 'default'; 2622 2679 2623 2680 $sticky = false; 2624 2681 if ( is_sticky( $post_ID ) ) … … 2660 2717 'date_created_gmt' => new IXR_Date($post_date_gmt), 2661 2718 'post_status' => $postdata['post_status'], 2662 2719 'custom_fields' => $this->get_custom_fields($post_ID), 2720 'wp_post_format' => $post_format, 2663 2721 'sticky' => $sticky 2664 2722 ); 2665 2723 … … 2740 2798 // Consider future posts as published 2741 2799 if ( $entry['post_status'] === 'future' ) 2742 2800 $entry['post_status'] = 'publish'; 2801 2802 // Get post format 2803 $post_format = get_post_format( $entry['ID'] ); 2804 if ( empty( $post_format ) ) 2805 $post_format = 'default'; 2743 2806 2744 2807 $struct[] = array( 2745 2808 'dateCreated' => new IXR_Date($post_date), … … 2763 2826 'wp_author_display_name' => $author->display_name, 2764 2827 'date_created_gmt' => new IXR_Date($post_date_gmt), 2765 2828 'post_status' => $entry['post_status'], 2766 'custom_fields' => $this->get_custom_fields($entry['ID']) 2829 'custom_fields' => $this->get_custom_fields($entry['ID']), 2830 'wp_post_format' => $post_format 2767 2831 ); 2768 2832 2769 2833 }
