Ticket #18429: featured_image.patch
File featured_image.patch, 4.0 KB (added by , 13 years ago) |
---|
-
wp-includes/class-wp-xmlrpc-server.php
577 577 'sticky' => ( $post['post_type'] === 'post' && is_sticky( $post['ID'] ) ), 578 578 ); 579 579 580 // 581 $post_fields['featured_image'] = get_post_meta( $post['ID'], '_thumbnail_id', true ); 582 $post_fields['featured_image_url'] = wp_get_attachment_url( $post_fields['featured_image'] ); 583 580 584 // Consider future posts as published 581 585 if ( $post_fields['post_status'] === 'future' ) 582 586 $post_fields['post_status'] = 'publish'; … … 644 648 * - comment_status - can be 'open' | 'closed' 645 649 * - ping_status - can be 'open' | 'closed' 646 650 * - sticky 651 * - featured_image - ID of a media item to use as the featured image 647 652 * - custom_fields - array, with each element containing 'key' and 'value' 648 653 * - terms - array, with taxonomy names as keys and arrays of term IDs as values 649 654 * - terms_names - array, with taxonomy names as keys and arrays of term names as values … … 777 782 stick_post( $post_ID ); 778 783 } 779 784 785 if ( isset ( $post_data['featured_image'] ) ) { 786 // empty value deletes, non-empty value adds/updates 787 if ( empty( $post_data['featured_image'] ) ) { 788 delete_post_thumbnail( $post_ID ); 789 } 790 else { 791 if ( set_post_thumbnail( $post_ID, $post_data['featured_image'] ) === false ) 792 return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); 793 } 794 unset( $content_struct['featured_image'] ); 795 } 796 780 797 if ( isset ( $post_data['custom_fields'] ) && post_type_supports( $post_data['post_type'], 'custom-fields' ) ) { 781 798 $this->set_custom_fields( $post_ID, $post_data['custom_fields'] ); 782 799 } … … 3329 3346 * - mt_allow_pings - can be 'open' or 'closed' 3330 3347 * - date_created_gmt 3331 3348 * - dateCreated 3349 * - wp_featured_image 3332 3350 * 3333 3351 * @since 1.5.0 3334 3352 * … … 3575 3593 if ( isset($content_struct['custom_fields']) ) 3576 3594 $this->set_custom_fields($post_ID, $content_struct['custom_fields']); 3577 3595 3596 if ( isset ( $post_data['wp_featured_image'] ) ) { 3597 if ( set_post_thumbnail( $post_ID, $post_data['wp_featured_image'] ) === false ) 3598 return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); 3599 3600 unset( $content_struct['wp_featured_image'] ); 3601 } 3602 3578 3603 // Handle enclosures 3579 3604 $thisEnclosure = isset($content_struct['enclosure']) ? $content_struct['enclosure'] : null; 3580 3605 $this->add_enclosure_if_new($post_ID, $thisEnclosure); … … 3875 3900 if ( isset($content_struct['custom_fields']) ) 3876 3901 $this->set_custom_fields($post_ID, $content_struct['custom_fields']); 3877 3902 3903 if ( isset ( $post_data['wp_featured_image'] ) ) { 3904 // empty value deletes, non-empty value adds/updates 3905 if ( empty( $post_data['wp_featured_image'] ) ) { 3906 delete_post_thumbnail( $post_ID ); 3907 } 3908 else { 3909 if ( set_post_thumbnail( $post_ID, $post_data['wp_featured_image'] ) === false ) 3910 return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); 3911 } 3912 unset( $content_struct['wp_featured_image'] ); 3913 } 3914 3878 3915 // Handle enclosures 3879 3916 $thisEnclosure = isset($content_struct['enclosure']) ? $content_struct['enclosure'] : null; 3880 3917 $this->add_enclosure_if_new($post_ID, $thisEnclosure); … … 4011 4048 4012 4049 if ( !empty($enclosure) ) $resp['enclosure'] = $enclosure; 4013 4050 4051 $resp['wp_featured_image'] = get_post_meta( $postdata['ID'], '_thumbnail_id', true ); 4052 $resp['wp_featured_image_url'] = wp_get_attachment_url( $resp['wp_featured_image'] ); 4053 4014 4054 return $resp; 4015 4055 } else { 4016 4056 return new IXR_Error(404, __('Sorry, no such post.')); … … 4125 4165 'date_modified_gmt' => new IXR_Date( $post_modified_gmt ) 4126 4166 ); 4127 4167 4168 $entry_index = count( $struct ) - 1; 4169 $struct[ $entry_index ][ 'wp_featured_image' ] = get_post_meta( $entry['ID'], '_thumbnail_id', true ); 4170 $struct[ $entry_index ][ 'wp_featured_image_url' ] = wp_get_attachment_url( $struct[ $entry_index ][ 'wp_featured_image' ] ); 4128 4171 } 4129 4172 4130 4173 $recent_posts = array();