From 82622db77e8de7bcf03f7ecd7f5704450b4ed59e Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Wed, 28 Nov 2012 03:51:27 +0000 Subject: [PATCH] In the gallery shortcode, handle mapping of "ids" to include and orderby before the post_gallery filter. see #21816. fixes #22617. git-svn-id: https://develop.svn.wordpress.org/trunk@22891 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/media.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/wp-includes/media.php b/wp-includes/media.php index 3ea83b89fa..fc88a44661 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -669,6 +669,12 @@ function gallery_shortcode($attr) { static $instance = 0; $instance++; + if ( ! empty( $attr['ids'] ) ) { + // 'ids' is explicitly ordered + $attr['orderby'] = 'post__in'; + $attr['include'] = $attr['ids']; + } + // Allow plugins/themes to override the default gallery template. $output = apply_filters('post_gallery', '', $attr); if ( $output != '' ) @@ -690,7 +696,6 @@ function gallery_shortcode($attr) { 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail', - 'ids' => '', 'include' => '', 'exclude' => '' ), $attr)); @@ -699,12 +704,6 @@ function gallery_shortcode($attr) { if ( 'RAND' == $order ) $orderby = 'none'; - if ( !empty( $ids ) ) { - // 'ids' is explicitly ordered - $orderby = 'post__in'; - $include = $ids; - } - if ( !empty($include) ) { $_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );