Customizer: Re-use list of components to eliminate code duplication.
Introduces protected `WP_Customize_Manager::$components` to store list of loaded core components filtered by `customize_loaded_components`. Props DrewAPicture. See #35242 See #33552. Fixes #35354. Built from https://develop.svn.wordpress.org/trunk@36262 git-svn-id: http://core.svn.wordpress.org/trunk@36229 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3e35a7157f
commit
dd123ab2c0
|
@ -93,6 +93,15 @@ final class WP_Customize_Manager {
|
|||
*/
|
||||
protected $panels = array();
|
||||
|
||||
/**
|
||||
* List of core components.
|
||||
*
|
||||
* @since 4.5.0
|
||||
* @access protected
|
||||
* @var array
|
||||
*/
|
||||
protected $components = array( 'widgets', 'nav_menus' );
|
||||
|
||||
/**
|
||||
* Registered instances of WP_Customize_Section.
|
||||
*
|
||||
|
@ -238,7 +247,7 @@ final class WP_Customize_Manager {
|
|||
* @param array $components List of core components to load.
|
||||
* @param WP_Customize_Manager $this WP_Customize_Manager instance.
|
||||
*/
|
||||
$components = apply_filters( 'customize_loaded_components', array( 'widgets', 'nav_menus' ), $this );
|
||||
$components = apply_filters( 'customize_loaded_components', $this->components, $this );
|
||||
|
||||
if ( in_array( 'widgets', $components ) ) {
|
||||
require_once( ABSPATH . WPINC . '/class-wp-customize-widgets.php' );
|
||||
|
@ -1198,12 +1207,8 @@ final class WP_Customize_Manager {
|
|||
* @param string $id Panel ID to remove.
|
||||
*/
|
||||
public function remove_panel( $id ) {
|
||||
$core_panels = array(
|
||||
'widgets',
|
||||
'nav_menus',
|
||||
);
|
||||
|
||||
if ( in_array( $id, $core_panels, true ) ) {
|
||||
// Removing core components this way is _doing_it_wrong().
|
||||
if ( in_array( $id, $this->components, true ) ) {
|
||||
/* translators: 1: panel id, 2: filter reference URL, 3: filter name */
|
||||
$message = sprintf( __( 'Removing %1$s manually will cause PHP warnings. Use the <a href="%2$s">%3$s</a> filter instead.' ),
|
||||
$id,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.5-alpha-36261';
|
||||
$wp_version = '4.5-alpha-36262';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue