1<?php
2/**
3 * Customize API: WP_Customize_Themes_Panel class
4 *
5 * @package WordPress
6 * @subpackage Customize
7 * @since 4.9.0
8 */
9
10/**
11 * Customize Themes Panel Class
12 *
13 * @since 4.9.0
14 *
15 * @see WP_Customize_Panel
16 */
17class WP_Customize_Themes_Panel extends WP_Customize_Panel {
18
19 /**
20 * Panel type.
21 *
22 * @since 4.9.0
23 * @var string
24 */
25 public $type = 'themes';
26
27 /**
28 * An Underscore (JS) template for rendering this panel's container.
29 *
30 * The themes panel renders a custom panel heading with the active theme and a switch themes button.
31 *
32 * @see WP_Customize_Panel::print_template()
33 *
34 * @since 4.9.0
35 */
36 protected function render_template() {
37 ?>
38 <li id="accordion-section-{{ data.id }}" class="accordion-section control-panel-themes">
39 <h3 class="accordion-section-title">
40 <?php
41 if ( $this->manager->is_theme_active() ) {
42 echo '<span class="customize-action">' . __( 'Active theme' ) . '</span> {{ data.title }}';
43 } else {
44 echo '<span class="customize-action">' . __( 'Previewing theme' ) . '</span> {{ data.title }}';
45 }
46 ?>
47 <?php if ( current_user_can( 'switch_themes' ) ) : ?>
48 <button type="button" class="button change-theme" aria-label="<?php esc_attr_e( 'Change theme' ); ?>"><?php _ex( 'Change', 'theme' ); ?></button>
49 <?php endif; ?>
50 </h3>
51 <ul class="accordion-sub-container control-panel-content"></ul>
52 </li>
53 <?php
54 }
55
56 /**
57 * An Underscore (JS) template for this panel's content (but not its container).
58 *
59 * Class variables for this panel class are available in the `data` JS object;
60 * export custom variables by overriding WP_Customize_Panel::json().
61 *
62 * @since 4.9.0
63 *
64 * @see WP_Customize_Panel::print_template()
65 */
66 protected function content_template() {
67 ?>
68 <li class="panel-meta customize-info accordion-section <# if ( ! data.description ) { #> cannot-expand<# } #>">
69 <button class="customize-panel-back" tabindex="-1" type="button"><span class="screen-reader-text">
70 <?php
71 /* translators: Hidden accessibility text. */
72 _e( 'Back' );
73 ?>
74 </span></button>
75 <div class="accordion-section-title">
76 <span class="preview-notice">
77 <?php
78 printf(
79 /* translators: %s: Themes panel title in the Customizer. */
80 __( 'You are browsing %s' ),
81 '<strong class="panel-title">' . __( 'Themes' ) . '</strong>'
82 ); // Separate strings for consistency with other panels.
83 ?>
84 </span>
85 <?php if ( current_user_can( 'install_themes' ) && ! is_multisite() ) : ?>
86 <# if ( data.description ) { #>
87 <button class="customize-help-toggle dashicons dashicons-editor-help" type="button" aria-expanded="false"><span class="screen-reader-text">
88 <?php
89 /* translators: Hidden accessibility text. */
90 _e( 'Help' );
91 ?>
92 </span></button>
93 <# } #>
94 <?php endif; ?>
95 </div>
96 <?php if ( current_user_can( 'install_themes' ) && ! is_multisite() ) : ?>
97 <# if ( data.description ) { #>
98 <div class="description customize-panel-description">
99 {{{ data.description }}}
100 </div>
101 <# } #>
102 <?php endif; ?>
103
104 <div class="customize-control-notifications-container"></div>
105 </li>
106 <li class="customize-themes-full-container-container">
107 <div class="customize-themes-full-container">
108 <div class="customize-themes-notifications"></div>
109 </div>
110 </li>
111 <?php
112 }
113}
114