Ticket #15192: 15192.diff
File 15192.diff, 2.9 KB (added by , 13 years ago) |
---|
-
wp-includes/post.php
5211 5211 endif; 5212 5212 } 5213 5213 5214 /** 5215 * Attach a thumbnail to a post. 5216 * 5217 * @since 3.1 5218 * 5219 * @param int int|object $post The post for which to assign a thumbnail. 5220 * @param int $thumbnail_id. The thumbnail to assign ID. 5221 * @return bool Whether post has an image attached. 5222 */ 5223 function set_post_thumbnail( $post, $thumbnail_id ) { 5224 $post = get_post($post); 5225 if ( empty($post) ) 5226 return new WP_Error('invalid_post', __('Invalid post')); 5227 5228 if ( !wp_attachment_is_image($thumbnail_id) ) 5229 return new WP_Error('invalid_attachment', __('The attachment is not an image')); 5230 5231 return update_post_meta($post->ID, '_thumbnail_id', $thumbnail_id); 5232 } 5233 5214 5234 ?> -
wp-admin/admin-ajax.php
744 744 require_once ABSPATH . 'wp-admin/includes/nav-menu.php'; 745 745 746 746 /** 747 * For performance reasons, we omit some object properties from the checklist. 747 * For performance reasons, we omit some object properties from the checklist. 748 748 * The following is a hacky way to restore them when adding non-custom items. 749 749 */ 750 750 $menu_items_data = (array) $_POST['menu-item']; 751 $menu_item_data = array_shift( $menu_items_data ); 752 if ( 753 ! empty( $menu_item_data['menu-item-type'] ) && 751 $menu_item_data = array_shift( $menu_items_data ); 752 if ( 753 ! empty( $menu_item_data['menu-item-type'] ) && 754 754 'custom' != $menu_item_data['menu-item-type'] && 755 755 ! empty( $menu_item_data['menu-item-object-id'] ) 756 756 ) { … … 760 760 break; 761 761 762 762 case 'taxonomy' : 763 $_object = get_term( $menu_item_data['menu-item-object-id'], $menu_item_data['menu-item-object'] ); 763 $_object = get_term( $menu_item_data['menu-item-object-id'], $menu_item_data['menu-item-object'] ); 764 764 break; 765 765 } 766 766 767 $_menu_items = array_map( 'wp_setup_nav_menu_item', array( $_object ) ); 767 $_menu_items = array_map( 'wp_setup_nav_menu_item', array( $_object ) ); 768 768 $_menu_item = array_shift( $_menu_items ); 769 769 770 770 /** Restore the missing menu item properties **/ … … 1097 1097 require_once ABSPATH . WPINC . '/js/tinymce/wp-mce-link-includes.php'; 1098 1098 1099 1099 wp_link_ajax( $_POST ); 1100 1100 1101 1101 exit; 1102 1102 break; 1103 1103 case 'menu-locations-save': … … 1452 1452 die( _wp_post_thumbnail_html() ); 1453 1453 } 1454 1454 1455 if ( $thumbnail_id && get_post( $thumbnail_id ) ) { 1456 $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'thumbnail' ); 1457 if ( !empty( $thumbnail_html ) ) { 1458 update_post_meta( $post_ID, '_thumbnail_id', $thumbnail_id ); 1455 if ( $thumbnail_id ) { 1456 $set_post_thumbnail = set_post_thumbnail( $post_ID, $thumbnail_id ); 1457 if ( $set_post_thumbnail && !is_wp_error( $set_post_thumbnail ) ) 1459 1458 die( _wp_post_thumbnail_html( $thumbnail_id ) ); 1460 }1461 1459 } 1462 1460 die( '0' ); 1463 1461 break;