[wp-trac] [WordPress Trac] #30235: Improve ability to filter active state for widget area Customizer sections

WordPress Trac noreply at wordpress.org
Mon Nov 3 08:21:16 UTC 2014


#30235: Improve ability to filter active state for widget area Customizer sections
--------------------------+-------------------------
 Reporter:  westonruter   |       Owner:  ocean90
     Type:  defect (bug)  |      Status:  reviewing
 Priority:  normal        |   Milestone:  4.1
Component:  Customize     |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:  javascript
--------------------------+-------------------------
Changes (by westonruter):

 * keywords:  needs-patch => has-patch
 * owner:   => ocean90
 * status:  new => reviewing


Comment:

 In [attachment:30235.diff] (`c91db4dd`):

  * Mark panels, sections, controls as active if preview explicitly
 indicates.
  * Introduce `WP_Customize_Sidebar_Section` PHP class, and
 `SidebarSection` JS class
  * Move logic for determining whether a sidebar section is active from the
 `SidebarControl` to `SidebarSection`.

 Filtering the `active` state of a Sidebar section can be handled with a
 filter like this (improved version from above, as note the `sidebar_id`
 param):

 {{{#!php
 <?php
 /**
  * Prevent the second widget area (sidebar) from being displayed in the
 Customizer.
  *
  * @param bool $active
  * @param WP_Customize_Section $section
  *
  * @return bool
  */
 function force_hide_second_widget_area_customize_section( $active,
 $section ) {
         if ( $section instanceof WP_Customize_Sidebar_Section &&
 'sidebar-2' === $section->sidebar_id ) {
                 $active = false;
         }
         return $active;
 }
 add_filter( 'customize_section_active',
 'force_hide_second_widget_area_customize_section', 10, 2 );
 }}}

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


More information about the wp-trac mailing list