Make WordPress Core

Ticket #34747: b2088ce.diff

File b2088ce.diff, 9.3 KB (added by ryankienstra, 9 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 1a2d346..00e3e71 100644
    h3.customize-section-title { 
    418418        transition: left ease-in-out .18s;
    419419}
    420420
     421#customize-info.no-title {
     422        display:none;
     423}
     424
    421425.ios #customize-info,
    422426.ios #customize-theme-controls > ul > .accordion-section {
    423427        -webkit-transition: left 0s;
  • src/wp-admin/customize.php

    diff --git src/wp-admin/customize.php src/wp-admin/customize.php
    index 7f667d3..be5e81d 100644
    do_action( 'customize_controls_print_scripts' ); 
    132132                        <div id="customize-info" class="accordion-section customize-info">
    133133                                <div class="accordion-section-title">
    134134                                        <span class="preview-notice"><?php
    135                                                 echo sprintf( __( 'You are customizing %s' ), '<strong class="panel-title site-title">' . get_bloginfo( 'name' ) . '</strong>' );
     135                                                echo sprintf( __( 'You are customizing %s' ), '<strong class="panel-title site-title">' . $wp_customize->get_root_panel_title() . '</strong>' );
    136136                                        ?></span>
    137                                         <button class="customize-help-toggle dashicons dashicons-editor-help" aria-expanded="false"><span class="screen-reader-text"><?php _e( 'Help' ); ?></span></button>
     137                                        <?php
     138                                        $root_panel_description = $wp_customize->get_root_panel_description();
     139                                        if ( ! empty ( $root_panel_description ) ):
     140                                        ?>
     141                                                <button class="customize-help-toggle dashicons dashicons-editor-help" aria-expanded="false"><span class="screen-reader-text"><?php _e( 'Help' ); ?></span></button>
     142                                        <?php endif; ?>
     143                                </div>
     144                                <div class="customize-panel-description">
     145                                        <?php echo $root_panel_description; ?>
    138146                                </div>
    139                                 <div class="customize-panel-description"><?php
    140                                         _e( 'The Customizer allows you to preview changes to your site before publishing them. You can also navigate to different pages on your site to preview them.' );
    141                                 ?></div>
    142147                        </div>
    143148
    144149                        <div id="customize-theme-controls">
  • src/wp-admin/js/customize-controls.js

    diff --git src/wp-admin/js/customize-controls.js src/wp-admin/js/customize-controls.js
    index e1021a3..d2c1e7c 100644
     
    32503250                });
    32513251
    32523252                // Expand/Collapse the main customizer customize info.
    3253                 $( '.customize-info' ).find( '> .accordion-section-title .customize-help-toggle' ).on( 'click keydown', function( event ) {
     3253                $( '#customize-info > .accordion-section-title .customize-help-toggle' ).on( 'click keydown', function( event ) {
    32543254                        if ( api.utils.isKeydownButNotEnterEvent( event ) ) {
    32553255                                return;
    32563256                        }
     
    36543654                } );
    36553655
    36563656                // Bind site title display to the corresponding field.
    3657                 if ( title.length ) {
    3658                         api( 'blogname', function( setting ) {
    3659                                 var updateTitle = function() {
     3657                api( 'blogname', function( setting ) {
     3658                        var updateTitle = function() {
     3659
     3660                                // Set the Customizer title.
     3661                                if ( api.settings.isRootPanelTitleOverridden ) {
     3662                                        title.text( api.settings.filteredRootPanelTitle || '' );
     3663                                } else {
    36603664                                        title.text( $.trim( setting() ) || api.l10n.untitledBlogName );
    3661                                 };
    3662                                 setting.bind( updateTitle );
    3663                                 updateTitle();
    3664                         } );
    3665                 }
     3665                                }
     3666
     3667                                // If there's no title, set a class on the info section. The CSS will hide it.
     3668                                if ( ! title.text().length ) {
     3669                                        $( '#customize-info' ).addClass( 'no-title' );
     3670                                } else {
     3671                                        $( '#customize-info' ).removeClass( 'no-title' );
     3672                                }
     3673
     3674                        };
     3675                        setting.bind( updateTitle );
     3676                        updateTitle();
     3677                } );
    36663678
    36673679                /*
    36683680                 * Create a postMessage connection with a parent frame,
  • 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 ffc3ca5..850f156 100644
    final class WP_Customize_Manager { 
    184184        protected $return_url;
    185185
    186186        /**
     187         * Title of the Customizer, shown in the top of the root panel.
     188         *
     189         * @since 4.6
     190         * @access protected
     191         * @var string
     192         */
     193        protected $root_panel_title;
     194
     195        /**
     196         * Description of the Customizer, below the title.
     197         *
     198         * @since 4.6
     199         * @access protected
     200         * @var string
     201         */
     202        protected $root_panel_description;
     203
     204        /**
    187205         * Mapping of 'panel', 'section', 'control' to the ID which should be autofocused.
    188206         *
    189207         * @since 4.4.0
    final class WP_Customize_Manager { 
    16011619        }
    16021620
    16031621        /**
     1622         * Set Customizer title at top of root Customizer panel.
     1623         *
     1624         * Appears after text "You are customizing."
     1625         *
     1626         * @since 4.6
     1627         * @access public
     1628         * @param string $root_panel_title Appears above description.
     1629         */
     1630        public function set_root_panel_title( $root_panel_title ) {
     1631                $this->root_panel_title = $root_panel_title;
     1632        }
     1633
     1634        /**
     1635         * Get Customizer title at top of root Customizer panel
     1636         *
     1637         * Appears above the description.
     1638         *
     1639         * @since 4.6
     1640         * @access public
     1641         *
     1642         * @return string Root panel title.
     1643         */
     1644        public function get_root_panel_title() {
     1645                return is_null( $this->root_panel_title ) ? get_bloginfo( 'name' ) : $this->root_panel_title;
     1646        }
     1647
     1648        /**
     1649         * Set Customizer description.
     1650         *
     1651         * To be shown at the top of the Customizer root panel.
     1652         *
     1653         * @since 4.6
     1654         * @access public
     1655         * @param string $root_panel_description Appears after Customizer title.
     1656         */
     1657        public function set_root_panel_description( $root_panel_description ) {
     1658                $this->root_panel_description = $root_panel_description;
     1659        }
     1660
     1661        /**
     1662         * Get Customizer description, to be shown in the root panel.
     1663         *
     1664         * Appears after "You are customizing" and the Customizer title.
     1665         *
     1666         * @since 4.6
     1667         * @access public
     1668         *
     1669         * @return string Root panel description.
     1670         */
     1671        public function get_root_panel_description() {
     1672                $default_description = __( 'The Customizer allows you to preview changes to your site before publishing them. You can also navigate to different pages on your site to preview them.' );
     1673                return is_null( $this->root_panel_description ) ? $default_description : $this->root_panel_description;
     1674        }
     1675
     1676        /**
    16041677         * Set the autofocused constructs.
    16051678         *
    16061679         * @since 4.4.0
    final class WP_Customize_Manager { 
    17271800                        'documentTitleTmpl' => $this->get_document_title_template(),
    17281801                        'previewableDevices' => $this->get_previewable_devices(),
    17291802                        'selectiveRefreshEnabled' => isset( $this->selective_refresh ),
     1803                        'filteredRootPanelTitle' => $this->get_root_panel_title(),
     1804                        'isRootPanelTitleOverridden' => ! is_null( $this->root_panel_title ),
    17301805                );
    17311806
    17321807                // Prepare Customize Section objects to pass to JavaScript.
  • tests/phpunit/tests/customize/manager.php

    diff --git tests/phpunit/tests/customize/manager.php tests/phpunit/tests/customize/manager.php
    index 6f5789d..a6ff1ea 100644
    class Tests_WP_Customize_Manager extends WP_UnitTestCase { 
    340340        }
    341341
    342342        /**
     343         * Test get_root_panel_title()/set_root_panel_title() methods.
     344         *
     345         * @see WP_Customize_Manager::get_root_panel_title();
     346         * @see WP_Customize_Manager::set_root_panel_title();
     347         */
     348        function test_get_root_panel_title() {
     349                $this->assertEquals( get_bloginfo( 'name' ), $this->manager->get_root_panel_title() );
     350
     351                $first_new_title = 'Different Title';
     352                $this->manager->set_root_panel_title( $first_new_title );
     353                $this->assertEquals( $first_new_title, $this->manager->get_root_panel_title() );
     354
     355                $second_new_title = 'Renamed Title';
     356                $this->manager->set_root_panel_title( $second_new_title );
     357                $this->assertEquals( $second_new_title, $this->manager->get_root_panel_title() );
     358        }
     359
     360        /**
     361         * Test get_root_panel_description()/set_root_panel_description() methods.
     362         *
     363         * @see WP_Customize_Manager::get_root_panel_title();
     364         * @see WP_Customize_Manager::set_root_panel_title();
     365         */
     366        function test_get_root_panel_description() {
     367                $default_description = __( 'The Customizer allows you to preview changes to your site before publishing them. You can also navigate to different pages on your site to preview them.' );
     368                $this->assertEquals( $default_description, $this->manager->get_root_panel_description() );
     369
     370                $first_new_description = 'Another Description';
     371                $this->manager->set_root_panel_description( $first_new_description );
     372                $this->assertEquals( $first_new_description, $this->manager->get_root_panel_description() );
     373
     374                $second_new_description = '<em>Newest Description</em>';
     375                $this->manager->set_root_panel_description( $second_new_description );
     376                $this->assertEquals( $second_new_description, $this->manager->get_root_panel_description() );
     377        }
     378
     379        /**
    343380         * Test get_autofocus()/set_autofocus() methods.
    344381         *
    345382         * @see WP_Customize_Manager::get_autofocus()
    class Tests_WP_Customize_Manager extends WP_UnitTestCase { 
    425462                $data = json_decode( $json, true );
    426463                $this->assertNotEmpty( $data );
    427464
    428                 $this->assertEqualSets( array( 'theme', 'url', 'browser', 'panels', 'sections', 'nonce', 'autofocus', 'documentTitleTmpl', 'previewableDevices', 'selectiveRefreshEnabled' ), array_keys( $data ) );
     465                $this->assertEqualSets( array( 'theme', 'url', 'browser', 'panels', 'sections', 'nonce', 'autofocus', 'documentTitleTmpl', 'previewableDevices', 'selectiveRefreshEnabled', 'filteredRootPanelTitle', 'isRootPanelTitleOverridden' ), array_keys( $data ) );
    429466                $this->assertEquals( $autofocus, $data['autofocus'] );
    430467                $this->assertArrayHasKey( 'save', $data['nonce'] );
    431468                $this->assertArrayHasKey( 'preview', $data['nonce'] );