Ticket #15098: featured_image_xmlrpc.patch
| File featured_image_xmlrpc.patch, 2.7 KB (added by cfinke, 23 months ago) |
|---|
-
wp-includes/class-wp-xmlrpc-server.php
1596 1596 'caption' => $attachment->post_excerpt, 1597 1597 'description' => $attachment->post_content, 1598 1598 'metadata' => wp_get_attachment_metadata($attachment->ID), 1599 'id' => $attachment->ID, 1599 1600 ); 1600 1601 1601 1602 return $attachment_struct; … … 2157 2158 * - wp_page_parent_id 2158 2159 * - wp_page_order 2159 2160 * - wp_author_id 2161 * - wp_featured_image 2160 2162 * - post_status | page_status - can be 'draft', 'private', 'publish', or 'pending' 2161 2163 * - mt_allow_comments - can be 'open' or 'closed' 2162 2164 * - mt_allow_pings - can be 'open' or 'closed' … … 2415 2417 if ( isset($content_struct['custom_fields']) ) 2416 2418 $this->set_custom_fields($post_ID, $content_struct['custom_fields']); 2417 2419 2420 if ( isset($content_struct['wp_featured_image']) && $content_struct['wp_featured_image'] ) 2421 update_post_meta($post_ID, "_thumbnail_id", $content_struct['wp_featured_image']); 2422 2418 2423 // Handle enclosures 2419 2424 $thisEnclosure = isset($content_struct['enclosure']) ? $content_struct['enclosure'] : null; 2420 2425 $this->add_enclosure_if_new($post_ID, $thisEnclosure); … … 2728 2733 unstick_post( $post_ID ); 2729 2734 } 2730 2735 2736 if ( isset($content_struct['wp_featured_image']) && $content_struct['wp_featured_image'] ) { 2737 update_post_meta($post_ID, "_thumbnail_id", $content_struct['wp_featured_image']); 2738 } 2739 else { 2740 delete_post_meta($post_ID, "_thumbnail_id", ""); 2741 } 2742 2731 2743 if ( isset($content_struct['custom_fields']) ) 2732 2744 $this->set_custom_fields($post_ID, $content_struct['custom_fields']); 2733 2745 … … 2860 2872 2861 2873 if ( !empty($enclosure) ) $resp['enclosure'] = $enclosure; 2862 2874 2875 foreach ( $resp['custom_fields'] as $custom_field ) { 2876 if ( $custom_field["key"] == '_thumbnail_id' ) { 2877 if ( $imageurl = wp_get_attachment_url($custom_field['value']) ) { 2878 $resp['wp_featured_image'] = array( 'id' => $custom_field['value'], 'url' => $imageurl ); 2879 } 2880 } 2881 } 2882 2863 2883 return $resp; 2864 2884 } else { 2865 2885 return new IXR_Error(404, __('Sorry, no such post.')); … … 2967 2987 'wp_post_format' => $post_format 2968 2988 ); 2969 2989 2990 $entry_index = count($struct) - 1; 2991 2992 foreach ( $struct[$entry_index]['custom_fields'] as $custom_field ) { 2993 if ( $custom_field['key'] == '_thumbnail_id' ) { 2994 if ( $imageurl = wp_get_attachment_url($custom_field['value']) ) { 2995 $struct[$entry_index]['wp_featured_image'] = array( 'id' => $custom_field['value'], 'url' => $imageurl ); 2996 } 2997 } 2998 } 2970 2999 } 2971 3000 2972 3001 $recent_posts = array();
