[wp-trac] [WordPress Trac] #23873: Gallery shortcode orderby does not support multiple column sorting

WordPress Trac noreply at wordpress.org
Wed Sep 24 22:27:21 UTC 2014


#23873: Gallery shortcode orderby does not support multiple column sorting
--------------------------+--------------------
 Reporter:  dglingren     |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  4.1
Component:  Gallery       |     Version:  3.5.1
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |     Focuses:
--------------------------+--------------------

Comment (by tyxla):

 After testing for a while I discovered that this check is not necessary
 anymore.

 The gallery shortcode will use `get_children()`, which uses `get_posts()`,
 which already does the necessary checks to filter out any incorrect
 orderby statements. In case anything unexpected is used in the orderby
 attribute, `get_posts()` will order by the `post_date` column.

 So the following check can be removed:


 {{{
 // We're trusting author input, so let's at least make sure it looks like
 a valid orderby statement
 if ( isset( $attr['orderby'] ) ) {
         $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
         if ( ! $attr['orderby'] ) {
                 unset( $attr['orderby'] );
         }
 }

 }}}

 This way multi-column sorting can be used in the shortcode call, and even
 the new powerful orderby options can be used in the `post_gallery` and
 `shortcode_atts_gallery` filters.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/23873#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list