WordPress.org

Make WordPress Core

Ticket #26890: 26890.2.diff

File 26890.2.diff, 4.1 KB (added by celloexpressions, 5 years ago)

Fully-functional switch themes link in the Customizer, as a back-panel heading.

  • src/wp-admin/css/customize-controls.css

     
    149149        padding-right: 54px;
    150150}
    151151
    152 .control-section.control-panel > .accordion-section-title:after {
     152.control-section.control-panel > .accordion-section-title:after,
     153#accordion-panel-themes .accordion-section-title:after {
    153154        content: "\f345";
    154155        background: #f5f5f5;
    155156        color: #555;
     
    166167        content: "\f341";
    167168}
    168169
     170#accordion-panel-themes .accordion-section-title:after {
     171        content: "\f341";
     172}
     173
     174.rtl #accordion-panel-themes .accordion-section-title:after {
     175        content: "\f345";
     176}
     177
    169178#customize-theme-controls .control-section.control-panel > h3.accordion-section-title:focus:after,
    170 #customize-theme-controls .control-section.control-panel > h3.accordion-section-title:hover:after {
     179#customize-theme-controls .control-section.control-panel > h3.accordion-section-title:hover:after,
     180#customize-theme-controls #accordion-panel-themes h3.accordion-section-title:focus:after,
     181#customize-theme-controls #accordion-panel-themes h3.accordion-section-title:hover:after {
    171182        background: #ddd;
    172183        color: #000;
    173184        border: 1px solid #d9d9d9;
  • src/wp-admin/js/customize-controls.js

     
    708708        });
    709709
    710710        /**
     711         * @since 4.2.0
     712         *
     713         * @class
     714         * @augments wp.customize.Panel
     715         * @augments wp.customize.Class
     716         */
     717        api.ThemesPanel = api.Panel.extend({
     718                /**
     719                 * Don't attach any events.
     720                 *
     721                 * @since 4.2.0
     722                 */
     723                attachEvents: function () {}
     724        });
     725
     726        /**
    711727         * A Customizer Control.
    712728         *
    713729         * A control provides a UI element that allows a user to modify a Customizer Setting.
     
    18591875                header: api.HeaderControl,
    18601876                background: api.BackgroundControl
    18611877        };
    1862         api.panelConstructor = {};
     1878        api.panelConstructor = {
     1879                themes: api.ThemesPanel
     1880        };
    18631881        api.sectionConstructor = {};
    18641882
    18651883        $( function() {
  • src/wp-includes/class-wp-customize-manager.php

     
    12471247                        'section'    => 'static_front_page',
    12481248                        'type'       => 'dropdown-pages',
    12491249                ) );
     1250
     1251                // Themes.
     1252                $this->add_panel( new WP_Customize_Themes_Panel( $this, 'themes', array(
     1253                        'title'    => sprintf( __( 'Theme: %s' ), $this->theme()->display('Name') ),
     1254                        'priority' => 0,
     1255                ) ) );
     1256                $this->add_section( 'themes_placeholder', array( 'panel' => 'themes' ) );
     1257                $this->add_setting( 'themes_placeholder', array() );
     1258                $this->add_control( 'themes_placeholder', array( 'section' => 'themes_placeholder' ) );
    12501259        }
    12511260
    12521261        /**
  • src/wp-includes/class-wp-customize-panel.php

     
    323323                <?php
    324324        }
    325325}
     326
     327/**
     328 * A placeholder panel for themes.
     329 *
     330 * Currently, this panel's title simply links to wp-admin.
     331 *
     332 * @package WordPress
     333 * @subpackage Customize
     334 * @since 4.2.0
     335 */
     336class WP_Customize_Themes_Panel extends WP_Customize_Panel {
     337        public $type = 'themes';
     338       
     339        /**
     340         * Render the panel as a linked panel heading.
     341         *
     342         * @since 4.2.0
     343         */
     344        function render() {
     345                ?>
     346                <li id="accordion-panel-<?php echo esc_attr( $this->id ); ?>" class="control-section control-panel accordion-section">
     347                        <a href="<?php echo admin_url( 'themes.php' ); ?>" class="theme-switch">
     348                                <h3 class="accordion-section-title" tabindex="0">
     349                                        <?php echo esc_html( $this->title ); ?>
     350                                        <span class="screen-reader-text"><?php _e( 'Press return or enter to open this panel' ); ?></span>
     351                                </h3>
     352                        </a>
     353                </li>
     354                <?php
     355        }
     356}
     357 No newline at end of file