[wp-trac] [WordPress Trac] #39843: Allow a control to be displayed in multiple sections

WordPress Trac noreply at wordpress.org
Sat Feb 11 18:12:28 UTC 2017


#39843: Allow a control to be displayed in multiple sections
-------------------------+----------------------
 Reporter:  nikeo        |       Owner:
     Type:  enhancement  |      Status:  closed
 Priority:  normal       |   Milestone:
Component:  Customize    |     Version:  4.7.2
 Severity:  normal       |  Resolution:  wontfix
 Keywords:               |     Focuses:
-------------------------+----------------------
Changes (by westonruter):

 * status:  new => closed
 * resolution:   => wontfix
 * milestone:  Awaiting Review =>


Comment:

 @nikeo thanks for the suggestion, but core supports adding a controls for
 the same setting to multiple sections already. You just have to add the
 control to each section you desire. I don't think that there is a need for
 a control to support multiple sections at once, since it is almost just as
 easy to just add multiple controls with the same configurations aside from
 the `section`. Trying to add support for a multi-section control would
 have very little gain for the headaches involved in the API change.

 For example, given the current Site Title control:

 {{{#!php
 <?php
 $wp_customize->add_control( 'blogname', array(
         'label'      => __( 'Site Title' ),
         'section'    => 'title_tagline',
 ) );
 }}}

 To add an additional control that also manipulates the `blogname` setting
 but appears in the `colors` section in addition to the `title_tagline`
 section, all that is required is:

 {{{#!php
 <?php
 $wp_customize->add_control( 'blogname_in_colors_section', array(
         'label'      => __( 'Site Title' ),
         'section'    => 'colors',
         'settings'   => 'blogname',
 ) );
 }}}

 In other words, since the control ID is no longer one-to-one with the
 control's setting ID, then you just have to give a unique control ID and
 explicitly specify the settings

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


More information about the wp-trac mailing list