[wp-trac] [WordPress Trac] #20733: Theme customizer doesn't order sections based on order added

WordPress Trac wp-trac at lists.automattic.com
Tue May 22 23:36:49 UTC 2012


#20733: Theme customizer doesn't order sections based on order added
--------------------------+-----------------------------
 Reporter:  andyadams     |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Appearance    |    Version:  3.4
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 When adding sections to the theme customizer, sections with the same
 priority are given seemingly random order. From the
 [http://core.trac.wordpress.org/ticket/19910 original customizer ticket]:

 > Settings and sections both contain priority parameters (you can specify
 these in the constructor or alter them afterwards) which serve as the
 primary means of sorting sections before they're rendered. The order
 settings/sections are added serves as a secondary sorting mechanism
 (tiebreaker) when multiple items share the same priority.

 I was under the impression that if the priority was the same, the sections
 would appear in the order they were added. However, if you add sections A,
 B, and C (in that order) it seems to display them in order B, C, A.

 To replicate, add this code to your theme:

 {{{
 add_action( 'customize_register', 'theme_customize_register' );

 function theme_customize_register( $wp_customize ) {
         // Register Section A
         $wp_customize->add_section( 'theme_section_a', array(
                 'title'    => 'Section A',
                 'priority' => 35,
         ) );
         $wp_customize->add_setting( 'theme_option_a', array(
                 'type'              => 'option',
         ) );
         $wp_customize->add_control( 'theme_option_a', array(
                 'section'    => 'theme_section_a',
                 'type'       => 'text',
         ) );

         // Register Section B
         $wp_customize->add_section( 'theme_section_b', array(
                 'title'    => 'Section B',
                 'priority' => 35,
         ) );
         $wp_customize->add_setting( 'theme_option_b', array(
                 'type'              => 'option',
         ) );
         $wp_customize->add_control( 'theme_option_b', array(
                 'section'    => 'theme_section_b',
                 'type'       => 'text',
         ) );

         // Register Section C
         $wp_customize->add_section( 'theme_section_c', array(
                 'title'    => 'Section C',
                 'priority' => 35,
         ) );
         $wp_customize->add_setting( 'theme_option_c', array(
                 'type'              => 'option',
         ) );
         $wp_customize->add_control( 'theme_option_c', array(
                 'section'    => 'theme_section_c',
                 'type'       => 'text',
         ) );
 }
 }}}

 '''Expected result:''' Sections show up in order A, B, C

 '''Actual result:''' Sections show up in order B, C, A

 Sorry if I'm doing something stupid, or if this isn't the intended
 functionality. I'm running trunk without any plugins.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/20733>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list