[wp-trac] Re: [WordPress Trac] #6476: 2.5 Gallery shortcode orderby not working

WordPress Trac wp-trac at lists.automattic.com
Tue Apr 1 23:48:04 GMT 2008


#6476: 2.5 Gallery shortcode orderby not working
---------------------------+------------------------------------------------
 Reporter:  GeoffHarrison  |        Owner:  anonymous
     Type:  defect         |       Status:  reopened 
 Priority:  normal         |    Milestone:  2.5.1    
Component:  General        |      Version:  2.5      
 Severity:  normal         |   Resolution:           
 Keywords:  has-patch      |  
---------------------------+------------------------------------------------
Comment (by tellyworth):

 allery-orderby-sanitized-r7585 improves on Mark's patch.  Requirements
 were:

 1. orderby should allow discrete values, not arbitrary column names

 2. SQL is not a user interface

 3. the same syntax and sanitizing should be reusable and consistent
 elsewhere (it could be useful for widgets or other shortcodes)

 It supports syntax like this:

 {{{
 [gallery orderby="id"]
 [gallery orderby="menu_order, id"]
 [gallery orderby="-menu_order, +name"]
 [gallery orderby="random"]
 }}}

 '+' means ASC (the default), '-' means DESC. Accepted values are:

 {{{
                 'id' => 'ID',
                 'menu_order' => 'menu_order',
                 'name' => 'post_name',
                 'date' => 'post_date',
                 'title' => 'post_title',
                 'caption' => 'post_excerpt',
                 'random' => 'rand()',
 }}}

 That last one is just for Mark.

 Unit tests are in TestSanitizeOrderby:

 http://svn.automattic.com/wordpress-tests/wp-
 testcase/test_includes_formatting.php

 The sanitize_orderby() function can be reused elsewhere to provide the
 same syntax.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/6476#comment:15>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list