Ticket #21816: 21816.patch
File 21816.patch, 1.9 KB (added by , 12 years ago) |
---|
-
wp-includes/media.php
801 801 'captiontag' => 'dd', 802 802 'columns' => 3, 803 803 'size' => 'thumbnail', 804 'ids' => '', 804 805 'include' => '', 805 806 'exclude' => '' 806 807 ), $attr)); … … 809 810 if ( 'RAND' == $order ) 810 811 $orderby = 'none'; 811 812 812 if ( !empty($include) ) { 813 $include = preg_replace( '/[^0-9,]+/', '', $include ); 813 if ( !empty( $ids ) ) { 814 // 'ids' is explicitly ordered 815 $orderby = 'none'; 816 $include = $ids; 817 } 818 819 if ( !empty( $include ) ) { 820 $include = wp_parse_id_list( $include ); 814 821 $_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) ); 815 822 816 823 $attachments = array(); 817 824 foreach ( $_attachments as $key => $val ) { 818 $attachments[ $val->ID] = $_attachments[$key];825 $attachments[ $val->ID ] = $_attachments[ $key ]; 819 826 } 820 } elseif ( !empty($exclude) ) { 821 $exclude = preg_replace( '/[^0-9,]+/', '', $exclude ); 827 828 if ( !empty( $ids ) ) { 829 $attachments_sorted = array(); 830 foreach ( $include as $id ) { 831 if ( array_key_exists( $id, $attachments ) ) 832 $attachments_sorted[ $id ] = $attachments[ $id ]; 833 } 834 $attachments = $attachments_sorted; 835 } 836 } elseif ( !empty( $exclude ) ) { 837 $exclude = wp_parse_id_list( $exclude ); 822 838 $attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) ); 823 839 } else { 824 840 $attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );