Changeset 28414 for trunk/src/wp-includes/media.php
- Timestamp:
- 05/15/2014 03:40:46 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/media.php
r28377 r28414 912 912 if ( ! empty( $attr['ids'] ) ) { 913 913 // 'ids' is explicitly ordered, unless you specify otherwise. 914 if ( empty( $attr['orderby'] ) ) 914 if ( empty( $attr['orderby'] ) ) { 915 915 $attr['orderby'] = 'post__in'; 916 } 916 917 $attr['include'] = $attr['ids']; 917 918 } … … 931 932 */ 932 933 $output = apply_filters( 'post_gallery', '', $attr ); 933 if ( $output != '' ) 934 if ( $output != '' ) { 934 935 return $output; 936 } 935 937 936 938 // We're trusting author input, so let's at least make sure it looks like a valid orderby statement 937 939 if ( isset( $attr['orderby'] ) ) { 938 940 $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] ); 939 if ( ! $attr['orderby'] )941 if ( ! $attr['orderby'] ) { 940 942 unset( $attr['orderby'] ); 943 } 941 944 } 942 945 943 946 $html5 = current_theme_supports( 'html5', 'gallery' ); 944 extract(shortcode_atts(array(947 $atts = shortcode_atts( array( 945 948 'order' => 'ASC', 946 949 'orderby' => 'menu_order ID', … … 954 957 'exclude' => '', 955 958 'link' => '' 956 ), $attr, 'gallery')); 957 958 $id = intval($id); 959 if ( 'RAND' == $order ) 960 $orderby = 'none'; 961 962 if ( !empty($include) ) { 963 $_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) ); 959 ), $attr, 'gallery' ); 960 961 $id = intval( $atts['id'] ); 962 if ( 'RAND' == $atts['order'] ) { 963 $atts['orderby'] = 'none'; 964 } 965 966 if ( ! empty( $atts['include'] ) ) { 967 $_attachments = get_posts( array( 'include' => $atts['include'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) ); 964 968 965 969 $attachments = array(); … … 967 971 $attachments[$val->ID] = $_attachments[$key]; 968 972 } 969 } elseif ( ! empty($exclude) ) {970 $attachments = get_children( array( 'post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );973 } elseif ( ! empty( $atts['exclude'] ) ) { 974 $attachments = get_children( array( 'post_parent' => $id, 'exclude' => $atts['exclude'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) ); 971 975 } else { 972 $attachments = get_children( array( 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );973 } 974 975 if ( empty( $attachments) )976 $attachments = get_children( array( 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) ); 977 } 978 979 if ( empty( $attachments ) ) { 976 980 return ''; 981 } 977 982 978 983 if ( is_feed() ) { 979 984 $output = "\n"; 980 foreach ( $attachments as $att_id => $attachment ) 981 $output .= wp_get_attachment_link($att_id, $size, true) . "\n"; 985 foreach ( $attachments as $att_id => $attachment ) { 986 $output .= wp_get_attachment_link( $att_id, $atts['size'], true ) . "\n"; 987 } 982 988 return $output; 983 989 } 984 990 985 $itemtag = tag_escape( $itemtag);986 $captiontag = tag_escape( $captiontag);987 $icontag = tag_escape( $icontag);991 $itemtag = tag_escape( $atts['itemtag'] ); 992 $captiontag = tag_escape( $atts['captiontag'] ); 993 $icontag = tag_escape( $atts['icontag'] ); 988 994 $valid_tags = wp_kses_allowed_html( 'post' ); 989 if ( ! isset( $valid_tags[ $itemtag ] ) ) 995 if ( ! isset( $valid_tags[ $itemtag ] ) ) { 990 996 $itemtag = 'dl'; 991 if ( ! isset( $valid_tags[ $captiontag ] ) ) 997 } 998 if ( ! isset( $valid_tags[ $captiontag ] ) ) { 992 999 $captiontag = 'dd'; 993 if ( ! isset( $valid_tags[ $icontag ] ) ) 1000 } 1001 if ( ! isset( $valid_tags[ $icontag ] ) ) { 994 1002 $icontag = 'dt'; 995 996 $columns = intval($columns); 1003 } 1004 1005 $columns = intval( $atts['columns'] ); 997 1006 $itemwidth = $columns > 0 ? floor(100/$columns) : 100; 998 1007 $float = is_rtl() ? 'right' : 'left'; … … 1033 1042 } 1034 1043 1035 $size_class = sanitize_html_class( $ size);1044 $size_class = sanitize_html_class( $atts['size'] ); 1036 1045 $gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>"; 1037 1046 … … 1048 1057 $i = 0; 1049 1058 foreach ( $attachments as $id => $attachment ) { 1050 if ( ! empty( $ link ) && 'file' === $link )1051 $image_output = wp_get_attachment_link( $id, $ size, false, false );1052 elseif ( ! empty( $link ) && 'none' === $link )1053 $image_output = wp_get_attachment_image( $id, $ size, false );1054 else1055 $image_output = wp_get_attachment_link( $id, $ size, true, false );1056 1059 if ( ! empty( $atts['link'] ) && 'file' === $atts['link'] ) { 1060 $image_output = wp_get_attachment_link( $id, $atts['size'], false, false ); 1061 } elseif ( ! empty( $atts['link'] ) && 'none' === $atts['link'] ) { 1062 $image_output = wp_get_attachment_image( $id, $atts['size'], false ); 1063 } else { 1064 $image_output = wp_get_attachment_link( $id, $atts['size'], true, false ); 1065 } 1057 1066 $image_meta = wp_get_attachment_metadata( $id ); 1058 1067 1059 1068 $orientation = ''; 1060 if ( isset( $image_meta['height'], $image_meta['width'] ) ) 1069 if ( isset( $image_meta['height'], $image_meta['width'] ) ) { 1061 1070 $orientation = ( $image_meta['height'] > $image_meta['width'] ) ? 'portrait' : 'landscape'; 1062 1071 } 1063 1072 $output .= "<{$itemtag} class='gallery-item'>"; 1064 1073 $output .= "
Note: See TracChangeset
for help on using the changeset viewer.