[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 00:00:07 UTC 2014
#30235: Improve ability to filter active state for widget area Customizer sections
--------------------------+-------------------------
Reporter: westonruter | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 4.1
Component: Customize | Version: trunk
Severity: normal | Keywords: needs-patch
Focuses: javascript |
--------------------------+-------------------------
Currently in trunk, to mark a Customizer section representing a widget
area (sidebar) you have to supply two separate filters instead of one:
{{{#!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 ( 'sidebar-widgets-sidebar-2' === $section->id ) {
$active = false;
}
return $active;
}
add_filter( 'customize_section_active',
'force_hide_second_widget_area_customize_section', 10, 2 );
/**
* Prevent the second widget area (sidebar) from being displayed in the
Customizer.
*
* @param bool $active
* @param WP_Customize_Control $control
* @return bool
*/
function force_hide_second_widget_area_customize_control( $active,
$control ) {
if ( 'sidebars_widgets[sidebar-2]' === $control->id ) {
$active = false;
}
return $active;
}
add_filter( 'customize_control_active',
'force_hide_second_widget_area_customize_control', 10, 2 );
}}}
Only the first one really should be needed, but the `SidebarControl`
currently syncs its `active` state to the containing section:
{{{!#js
// Update the model with whether or not the sidebar is rendered
self.active.bind( function ( active ) {
registeredSidebar.set( 'is_rendered', active );
api.section( self.section.get() ).active( active );
} );
}}}
This was done in 4.0 because there was no `active` state for sections,
since there were no models for sections at all. But now that there are
models for sections (and panels) we should allow just filtering of
`customize_section_active` to be able to inactivate a section.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/30235>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list