From dd123ab2c013bb5eca2cb828656d93277d8575bc Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 11 Jan 2016 20:28:28 +0000 Subject: [PATCH] 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 --- wp-includes/class-wp-customize-manager.php | 19 ++++++++++++------- wp-includes/version.php | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/wp-includes/class-wp-customize-manager.php b/wp-includes/class-wp-customize-manager.php index 4f4fcf1b64..f5aa604468 100644 --- a/wp-includes/class-wp-customize-manager.php +++ b/wp-includes/class-wp-customize-manager.php @@ -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 %3$s filter instead.' ), $id, diff --git a/wp-includes/version.php b/wp-includes/version.php index 0304c3f1d8..7fc6d954f2 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.