Ticket #34747: 2007d00.diff
File 2007d00.diff, 11.7 KB (added by , 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 { 418 418 transition: left ease-in-out .18s; 419 419 } 420 420 421 #customize-info.no-title { 422 display:none; 423 } 424 421 425 .ios #customize-info, 422 426 .ios #customize-theme-controls > ul > .accordion-section { 423 427 -webkit-transition: left 0s; -
src/wp-admin/customize.php
diff --git src/wp-admin/customize.php src/wp-admin/customize.php index 7f667d3..2fd6c9a 100644
do_action( 'customize_controls_print_scripts' ); 136 136 ?></span> 137 137 <button class="customize-help-toggle dashicons dashicons-editor-help" aria-expanded="false"><span class="screen-reader-text"><?php _e( 'Help' ); ?></span></button> 138 138 </div> 139 <div class="customize-panel-description"> <?php140 _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>139 <div class="customize-panel-description"> 140 <?php // Description produced with JavaScript ?> 141 </div> 142 142 </div> 143 143 144 144 <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..2139e19 100644
3231 3231 return; 3232 3232 } 3233 3233 3234 var parent, topFocus, 3234 var rootPanelDescription, customizeHelpButton, parent, topFocus, 3235 customizeInfoSection = $( '#customize-info'), 3235 3236 body = $( document.body ), 3236 3237 overlay = body.children( '.wp-full-overlay' ), 3237 3238 title = $( '#customize-info .panel-title.site-title' ), … … 3249 3250 } 3250 3251 }); 3251 3252 3253 rootPanelDescription = api.settings.filteredRootPanelDescription; 3254 customizeInfoSection.find( '> .customize-panel-description' ).html( rootPanelDescription ); 3255 3256 // Hide the '?' icon if the root panel description isn't present 3257 customizeHelpButton = customizeInfoSection.find( '> .accordion-section-title .customize-help-toggle' ); 3258 if ( ! rootPanelDescription ) { 3259 customizeHelpButton.hide(); 3260 } 3261 3252 3262 // Expand/Collapse the main customizer customize info. 3253 $( '.customize-info' ).find( '> .accordion-section-title .customize-help-toggle' ).on( 'click keydown', function( event ) {3263 customizeHelpButton.on( 'click keydown', function( event ) { 3254 3264 if ( api.utils.isKeydownButNotEnterEvent( event ) ) { 3255 3265 return; 3256 3266 } … … 3654 3664 } ); 3655 3665 3656 3666 // Bind site title display to the corresponding field. 3657 if ( title.length ) { 3658 api( 'blogname', function( setting ) { 3659 var updateTitle = function() { 3667 api( 'blogname', function( setting ) { 3668 var updateTitle = function() { 3669 3670 // Set the Customizer title. 3671 if ( api.settings.isRootPanelTitleFiltered ) { 3672 title.text( api.settings.filteredRootPanelTitle || '' ); 3673 } else { 3660 3674 title.text( $.trim( setting() ) || api.l10n.untitledBlogName ); 3661 }; 3662 setting.bind( updateTitle ); 3663 updateTitle(); 3664 } ); 3665 } 3675 } 3676 3677 // If there's no title, set a class on the info section. The CSS will hide it. 3678 if ( ! title.text().length ) { 3679 customizeInfoSection.addClass( 'no-title' ); 3680 } else { 3681 customizeInfoSection.removeClass( 'no-title' ); 3682 } 3683 3684 }; 3685 setting.bind( updateTitle ); 3686 updateTitle(); 3687 } ); 3666 3688 3667 3689 /* 3668 3690 * 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..55a3ddf 100644
final class WP_Customize_Manager { 184 184 protected $return_url; 185 185 186 186 /** 187 * Original title of the Customizer, before being filtered. 188 * 189 * @since 4.6 190 * @access protected 191 * @var string 192 */ 193 protected $original_customizer_title; 194 195 /** 196 * Filtered title of the Customizer, shown in the top of the root panel. 197 * 198 * @since 4.6 199 * @access protected 200 * @var string 201 */ 202 protected $filtered_root_panel_title; 203 204 /** 205 * Filtered description of the Customizer, below the title. 206 * 207 * @since 4.6 208 * @access protected 209 * @var string 210 */ 211 protected $filtered_root_panel_description; 212 213 /** 187 214 * Mapping of 'panel', 'section', 'control' to the ID which should be autofocused. 188 215 * 189 216 * @since 4.4.0 … … final class WP_Customize_Manager { 1601 1628 } 1602 1629 1603 1630 /** 1631 * Set Customizer title at top of root Customizer panel. 1632 * 1633 * Appears after text "You are customizing." 1634 * 1635 * @since 4.6 1636 * @access public 1637 */ 1638 public function set_filtered_root_panel_title() { 1639 $this->original_customizer_title = get_bloginfo( 'name' ); 1640 1641 /** 1642 * Filter title in root Customizer panel. 1643 * 1644 * @since 4.6 1645 * 1646 * @param string $customizer_title Appears at top of root Customizer panel. 1647 */ 1648 $this->filtered_root_panel_title = apply_filters( 'customize_root_panel_title', $this->original_customizer_title ); 1649 } 1650 1651 /** 1652 * Get Customizer title at top of root Customizer panel 1653 * 1654 * Appears above the description. 1655 * 1656 * @since 4.6 1657 * @access public 1658 */ 1659 public function get_filtered_root_panel_title() { 1660 if ( isset( $this->filtered_root_panel_title ) ) { 1661 return $this->filtered_root_panel_title; 1662 } 1663 } 1664 1665 /** 1666 * Whether the Customizer root panel title has been filtered. 1667 * 1668 * True if this title is different from the original title. 1669 * 1670 * @since 4.6 1671 * @access public 1672 * 1673 * @return bool 1674 */ 1675 public function is_root_panel_title_filtered() { 1676 if ( ( isset( $this->filtered_root_panel_title ) ) && ( isset( $this->original_customizer_title ) ) ) { 1677 return ( $this->filtered_root_panel_title !== $this->original_customizer_title ); 1678 } else { 1679 return false; 1680 } 1681 } 1682 1683 /** 1684 * Set Customizer description. 1685 * 1686 * To be shown at the top of the Customizer root panel. 1687 * 1688 * @since 4.6 1689 * @access public 1690 */ 1691 public function set_filtered_root_panel_description() { 1692 1693 /** 1694 * Filter description in primary Customizer panel. 1695 * 1696 * @since 4.6 1697 * 1698 * @param string $customizer_description Appears at top of root Customizer panel, under Customizer title. 1699 */ 1700 $this->filtered_root_panel_description = apply_filters( 'customize_root_panel_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.' ) ); 1701 } 1702 1703 /** 1704 * Get Customizer description, to be shown in the root panel. 1705 * 1706 * Appears after "You are customizing" and the Customizer title. 1707 * 1708 * @since 4.6 1709 * @access public 1710 */ 1711 public function get_filtered_root_panel_description() { 1712 if ( isset( $this->filtered_root_panel_description ) ) { 1713 return $this->filtered_root_panel_description; 1714 } 1715 } 1716 1717 /** 1604 1718 * Set the autofocused constructs. 1605 1719 * 1606 1720 * @since 4.4.0 … … final class WP_Customize_Manager { 1686 1800 $allowed_urls[] = home_url( '/', 'https' ); 1687 1801 } 1688 1802 1803 // Set title and description displayed at top of root Customizer panel. 1804 $this->set_filtered_root_panel_title(); 1805 $this->set_filtered_root_panel_description(); 1806 1689 1807 /** 1690 1808 * Filter the list of URLs allowed to be clicked and followed in the Customizer preview. 1691 1809 * … … final class WP_Customize_Manager { 1727 1845 'documentTitleTmpl' => $this->get_document_title_template(), 1728 1846 'previewableDevices' => $this->get_previewable_devices(), 1729 1847 'selectiveRefreshEnabled' => isset( $this->selective_refresh ), 1848 'filteredRootPanelTitle' => $this->get_filtered_root_panel_title(), 1849 'isRootPanelTitleFiltered' => $this->is_root_panel_title_filtered(), 1850 'filteredRootPanelDescription' => $this->get_filtered_root_panel_description(), 1730 1851 ); 1731 1852 1732 1853 // 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..cf3fcf6 100644
class Tests_WP_Customize_Manager extends WP_UnitTestCase { 340 340 } 341 341 342 342 /** 343 * Test get_filtered_root_panel_title()/set_filtered_root_panel_title() methods. 344 * 345 * @see WP_Customize_Manager::get_filtered_root_panel_title(); 346 * @see WP_Customize_Manager::set_filtered_root_panel_title(); 347 */ 348 function test_get_filtered_root_panel_title() { 349 $this->assertEmpty( $this->manager->get_filtered_root_panel_title() ); 350 351 $this->manager->set_filtered_root_panel_title(); 352 $this->assertEquals( get_bloginfo( 'name' ), $this->manager->get_filtered_root_panel_title() ); 353 354 add_filter( 'customize_root_panel_title', array( $this, 'filter_root_panel_title' ) ); 355 $this->manager->set_filtered_root_panel_title(); 356 $this->assertEquals( 'New Title', $this->manager->get_filtered_root_panel_title() ); 357 } 358 359 /** 360 * Test is_root_panel_title_filtered() method. 361 * 362 * @see WP_Customize_Manager::is_root_panel_title_filtered(); 363 */ 364 function test_is_root_panel_title_filtered() { 365 $this->manager->set_filtered_root_panel_title(); 366 $this->assertEquals( false, $this->manager->is_root_panel_title_filtered() ); 367 368 $filtered_title = 'foo'; 369 add_filter( 'customize_root_panel_title', array( $this, 'filter_root_panel_title' ) ); 370 $this->manager->set_filtered_root_panel_title(); 371 $this->assertEquals( true, $this->manager->is_root_panel_title_filtered() ); 372 } 373 374 /** 375 * Filter for title at top of root panel. 376 * 377 * @return string Title. 378 */ 379 function filter_root_panel_title() { 380 return 'New Title'; 381 } 382 383 /** 384 * Test get_filtered_root_panel_description()/set_filtered_root_panel_description() methods. 385 * 386 * @see WP_Customize_Manager::get_filtered_root_panel_title(); 387 * @see WP_Customize_Manager::set_filtered_root_panel_title(); 388 */ 389 function test_get_filtered_root_panel_description() { 390 $this->assertEmpty( $this->manager->get_filtered_root_panel_description() ); 391 392 $this->manager->set_filtered_root_panel_description(); 393 $original_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.' ); 394 $this->assertEquals( $original_description, $this->manager->get_filtered_root_panel_description() ); 395 396 $filtered_description = 'bar'; 397 add_filter( 'customize_root_panel_description', array( $this, 'filter_root_panel_description' ) ); 398 $this->manager->set_filtered_root_panel_description(); 399 $this->assertEquals( 'bar', $this->manager->get_filtered_root_panel_description() ); 400 } 401 402 /** 403 * Filter for description at top of root panel. 404 * 405 * @return string Description. 406 */ 407 function filter_root_panel_description() { 408 return 'bar'; 409 } 410 411 /** 343 412 * Test get_autofocus()/set_autofocus() methods. 344 413 * 345 414 * @see WP_Customize_Manager::get_autofocus() … … class Tests_WP_Customize_Manager extends WP_UnitTestCase { 425 494 $data = json_decode( $json, true ); 426 495 $this->assertNotEmpty( $data ); 427 496 428 $this->assertEqualSets( array( 'theme', 'url', 'browser', 'panels', 'sections', 'nonce', 'autofocus', 'documentTitleTmpl', 'previewableDevices', 'selectiveRefreshEnabled' ), array_keys( $data ) );497 $this->assertEqualSets( array( 'theme', 'url', 'browser', 'panels', 'sections', 'nonce', 'autofocus', 'documentTitleTmpl', 'previewableDevices', 'selectiveRefreshEnabled', 'filteredRootPanelTitle', 'isRootPanelTitleFiltered', 'filteredRootPanelDescription' ), array_keys( $data ) ); 429 498 $this->assertEquals( $autofocus, $data['autofocus'] ); 430 499 $this->assertArrayHasKey( 'save', $data['nonce'] ); 431 500 $this->assertArrayHasKey( 'preview', $data['nonce'] );