WordPress.org

Make WordPress Core

Ticket #33552: 33552.3.diff

File 33552.3.diff, 5.7 KB (added by westonruter, 5 years ago)
  • src/wp-admin/css/customize-controls.css

    diff --git src/wp-admin/css/customize-controls.css src/wp-admin/css/customize-controls.css
    index fe82af7..353a69b 100644
    body { 
    33        -webkit-text-size-adjust: 100%;
    44}
    55
     6button.not-a-button {
     7        background: transparent;
     8        border: none;
     9        -webkit-box-shadow: none;
     10        box-shadow: none;
     11        -webkit-border-radius: 0;
     12        border-radius: 0;
     13        outline: 0;
     14        padding: 0;
     15        margin: 0;
     16}
     17
    618#customize-controls a {
    719        text-decoration: none;
    820}
  • src/wp-admin/css/customize-nav-menus.css

    diff --git src/wp-admin/css/customize-nav-menus.css src/wp-admin/css/customize-nav-menus.css
    index 38716c6..35e381f 100644
     
    612612        background: transparent;
    613613}
    614614
    615 button.not-a-button {
    616         background: transparent;
    617         border: none;
    618         -webkit-box-shadow: none;
    619         box-shadow: none;
    620         -webkit-border-radius: 0;
    621         border-radius: 0;
    622         outline: 0;
    623         padding: 0;
    624         margin: 0;
    625 }
    626 
    627615#available-menu-items .accordion-section-title button {
    628616        display: block;
    629617        width: 28px;
  • src/wp-includes/class-wp-customize-manager.php

    diff --git src/wp-includes/class-wp-customize-manager.php src/wp-includes/class-wp-customize-manager.php
    index 485e164..a304b99 100644
    final class WP_Customize_Manager { 
    191191                require_once( ABSPATH . WPINC . '/class-wp-customize-panel.php' );
    192192                require_once( ABSPATH . WPINC . '/class-wp-customize-section.php' );
    193193                require_once( ABSPATH . WPINC . '/class-wp-customize-control.php' );
    194                 require_once( ABSPATH . WPINC . '/class-wp-customize-widgets.php' );
    195                 require_once( ABSPATH . WPINC . '/class-wp-customize-nav-menus.php' );
    196194
    197                 $this->widgets = new WP_Customize_Widgets( $this );
    198                 $this->nav_menus = new WP_Customize_Nav_Menus( $this );
     195                /**
     196                 * Filter the core Customizer components to load.
     197                 *
     198                 * This allows Core components to be omitted from being instantiated by
     199                 * filtering them out of the array. Note that this filter generally runs
     200                 * during the <code>plugins_loaded</code> action, so it cannot be added
     201                 * in a theme.
     202                 *
     203                 * @since 4.4.0
     204                 *
     205                 * @see WP_Customize_Manager::__construct()
     206                 *
     207                 * @param array                $components List of core components to load.
     208                 * @param WP_Customize_Manager $this       WP_Customize_Manager instance.
     209                 */
     210                $components = apply_filters( 'customize_loaded_components', array( 'widgets', 'nav_menus' ), $this );
     211
     212                if ( in_array( 'widgets', $components ) ) {
     213                        require_once( ABSPATH . WPINC . '/class-wp-customize-widgets.php' );
     214                        $this->widgets = new WP_Customize_Widgets( $this );
     215                }
     216                if ( in_array( 'nav_menus', $components ) ) {
     217                        require_once( ABSPATH . WPINC . '/class-wp-customize-nav-menus.php' );
     218                        $this->nav_menus = new WP_Customize_Nav_Menus( $this );
     219                }
    199220
    200221                add_filter( 'wp_die_handler', array( $this, 'wp_die_handler' ) );
    201222
  • tests/phpunit/tests/customize/manager.php

    diff --git tests/phpunit/tests/customize/manager.php tests/phpunit/tests/customize/manager.php
    index b9e7f31..6da2d96 100644
    class Tests_WP_Customize_Manager extends WP_UnitTestCase { 
    327327                $this->assertArrayHasKey( 'save', $data['nonce'] );
    328328                $this->assertArrayHasKey( 'preview', $data['nonce'] );
    329329        }
     330
     331        /**
     332         * @ticket 33552
     333         */
     334        function test_customize_loaded_components_filter() {
     335                $manager = new WP_Customize_Manager();
     336                $this->assertInstanceOf( 'WP_Customize_Widgets', $manager->widgets );
     337                $this->assertInstanceOf( 'WP_Customize_Nav_Menus', $manager->nav_menus );
     338
     339                add_filter( 'customize_loaded_components', array( $this, 'return_array_containing_widgets' ), 10, 2 );
     340                $manager = new WP_Customize_Manager();
     341                $this->assertInstanceOf( 'WP_Customize_Widgets', $manager->widgets );
     342                $this->assertEmpty( $manager->nav_menus );
     343                remove_all_filters( 'customize_loaded_components' );
     344
     345                add_filter( 'customize_loaded_components', array( $this, 'return_array_containing_nav_menus' ), 10, 2 );
     346                $manager = new WP_Customize_Manager();
     347                $this->assertInstanceOf( 'WP_Customize_Nav_Menus', $manager->nav_menus );
     348                $this->assertEmpty( $manager->widgets );
     349                remove_all_filters( 'customize_loaded_components' );
     350
     351                add_filter( 'customize_loaded_components', '__return_empty_array' );
     352                $manager = new WP_Customize_Manager();
     353                $this->assertEmpty( $manager->widgets );
     354                $this->assertEmpty( $manager->nav_menus );
     355                remove_all_filters( 'customize_loaded_components' );
     356        }
     357
     358        /**
     359         * @see Tests_WP_Customize_Manager::test_customize_loaded_components_filter()
     360         *
     361         * @param array                $components         Components.
     362         * @param WP_Customize_Manager $customize_manager  Manager.
     363         *
     364         * @return array Components.
     365         */
     366        function return_array_containing_widgets( $components, $customize_manager ) {
     367                $this->assertInternalType( 'array', $components );
     368                $this->assertContains( 'widgets', $components );
     369                $this->assertContains( 'nav_menus', $components );
     370                $this->assertInternalType( 'array', $components );
     371                $this->assertInstanceOf( 'WP_Customize_Manager', $customize_manager );
     372                return array( 'widgets' );
     373        }
     374
     375        /**
     376         * @see Tests_WP_Customize_Manager::test_customize_loaded_components_filter()
     377         *
     378         * @param array                $components         Components.
     379         * @param WP_Customize_Manager $customize_manager  Manager.
     380         *
     381         * @return array Components.
     382         */
     383        function return_array_containing_nav_menus( $components, $customize_manager ) {
     384                $this->assertInternalType( 'array', $components );
     385                $this->assertContains( 'widgets', $components );
     386                $this->assertContains( 'nav_menus', $components );
     387                return array( 'nav_menus' );
     388        }
    330389}