wp/wp-includes/customize/class-wp-customize-themes-panel.php
changeset 7 cf61fcea0001
child 16 a86126ab1dd4
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
       
     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  */
       
    17 class 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 current 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 
       
    48 				<?php if ( current_user_can( 'switch_themes' ) ) : ?>
       
    49 					<button type="button" class="button change-theme" aria-label="<?php esc_attr_e( 'Change theme' ); ?>"><?php _ex( 'Change', 'theme' ); ?></button>
       
    50 				<?php endif; ?>
       
    51 			</h3>
       
    52 			<ul class="accordion-sub-container control-panel-content"></ul>
       
    53 		</li>
       
    54 		<?php
       
    55 	}
       
    56 
       
    57 	/**
       
    58 	 * An Underscore (JS) template for this panel's content (but not its container).
       
    59 	 *
       
    60 	 * Class variables for this panel class are available in the `data` JS object;
       
    61 	 * export custom variables by overriding WP_Customize_Panel::json().
       
    62 	 *
       
    63 	 * @since 4.9.0
       
    64 	 *
       
    65 	 * @see WP_Customize_Panel::print_template()
       
    66 	 */
       
    67 	protected function content_template() {
       
    68 		?>
       
    69 		<li class="panel-meta customize-info accordion-section <# if ( ! data.description ) { #> cannot-expand<# } #>">
       
    70 			<button class="customize-panel-back" tabindex="-1" type="button"><span class="screen-reader-text"><?php _e( 'Back' ); ?></span></button>
       
    71 			<div class="accordion-section-title">
       
    72 				<span class="preview-notice">
       
    73 					<?php
       
    74 					/* translators: %s: themes panel title in the Customizer */
       
    75 					echo sprintf( __( 'You are browsing %s' ), '<strong class="panel-title">' . __( 'Themes' ) . '</strong>' ); // Separate strings for consistency with other panels.
       
    76 					?>
       
    77 				</span>
       
    78 				<?php if ( current_user_can( 'install_themes' ) && ! is_multisite() ) : ?>
       
    79 					<# if ( data.description ) { #>
       
    80 						<button class="customize-help-toggle dashicons dashicons-editor-help" type="button" aria-expanded="false"><span class="screen-reader-text"><?php _e( 'Help' ); ?></span></button>
       
    81 					<# } #>
       
    82 				<?php endif; ?>
       
    83 			</div>
       
    84 			<?php if ( current_user_can( 'install_themes' ) && ! is_multisite() ) : ?>
       
    85 				<# if ( data.description ) { #>
       
    86 					<div class="description customize-panel-description">
       
    87 						{{{ data.description }}}
       
    88 					</div>
       
    89 				<# } #>
       
    90 			<?php endif; ?>
       
    91 
       
    92 			<div class="customize-control-notifications-container"></div>
       
    93 		</li>
       
    94 		<li class="customize-themes-full-container-container">
       
    95 			<div class="customize-themes-full-container">
       
    96 				<div class="customize-themes-notifications"></div>
       
    97 			</div>
       
    98 		</li>
       
    99 		<?php
       
   100 	}
       
   101 }