WordPress.org

Make WordPress Core

Changeset 36262


Ignore:
Timestamp:
01/11/2016 08:27:40 PM (4 years ago)
Author:
westonruter
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-customize-manager.php

    r36261 r36262  
    9393     */
    9494    protected $panels = array();
     95
     96    /**
     97     * List of core components.
     98     *
     99     * @since 4.5.0
     100     * @access protected
     101     * @var array
     102     */
     103    protected $components = array( 'widgets', 'nav_menus' );
    95104
    96105    /**
     
    239248         * @param WP_Customize_Manager $this       WP_Customize_Manager instance.
    240249         */
    241         $components = apply_filters( 'customize_loaded_components', array( 'widgets', 'nav_menus' ), $this );
     250        $components = apply_filters( 'customize_loaded_components', $this->components, $this );
    242251
    243252        if ( in_array( 'widgets', $components ) ) {
     
    11991208     */
    12001209    public function remove_panel( $id ) {
    1201         $core_panels = array(
    1202             'widgets',
    1203             'nav_menus',
    1204         );
    1205 
    1206         if ( in_array( $id, $core_panels, true ) ) {
     1210        // Removing core components this way is _doing_it_wrong().
     1211        if ( in_array( $id, $this->components, true ) ) {
    12071212            /* translators: 1: panel id, 2: filter reference URL, 3: filter name */
    12081213            $message = sprintf( __( 'Removing %1$s manually will cause PHP warnings. Use the <a href="%2$s">%3$s</a> filter instead.' ),
Note: See TracChangeset for help on using the changeset viewer.