3 * Customize API: WP_Customize_Theme_Control class
6 * @subpackage Customize
11 * Customize Theme Control class.
15 * @see WP_Customize_Control
17 class WP_Customize_Theme_Control extends WP_Customize_Control {
20 * Customize control type.
26 public $type = 'theme';
38 * Refresh the parameters passed to the JavaScript via JSON.
43 * @see WP_Customize_Control::to_json()
45 public function to_json() {
47 $this->json['theme'] = $this->theme;
51 * Don't render the control content from PHP, as it's rendered via JS on load.
56 public function render_content() {}
59 * Render a JS template for theme display.
64 public function content_template() {
65 $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
66 $active_url = esc_url( remove_query_arg( 'theme', $current_url ) );
67 $preview_url = esc_url( add_query_arg( 'theme', '__THEME__', $current_url ) ); // Token because esc_url() strips curly braces.
68 $preview_url = str_replace( '__THEME__', '{{ data.theme.id }}', $preview_url );
70 <# if ( data.theme.isActiveTheme ) { #>
71 <div class="theme active" tabindex="0" data-preview-url="<?php echo esc_attr( $active_url ); ?>" aria-describedby="{{ data.theme.id }}-action {{ data.theme.id }}-name">
73 <div class="theme" tabindex="0" data-preview-url="<?php echo esc_attr( $preview_url ); ?>" aria-describedby="{{ data.theme.id }}-action {{ data.theme.id }}-name">
76 <# if ( data.theme.screenshot[0] ) { #>
77 <div class="theme-screenshot">
78 <img data-src="{{ data.theme.screenshot[0] }}" alt="" />
81 <div class="theme-screenshot blank"></div>
84 <# if ( data.theme.isActiveTheme ) { #>
85 <span class="more-details" id="{{ data.theme.id }}-action"><?php _e( 'Customize' ); ?></span>
87 <span class="more-details" id="{{ data.theme.id }}-action"><?php _e( 'Live Preview' ); ?></span>
90 <div class="theme-author"><?php printf( __( 'By %s' ), '{{ data.theme.author }}' ); ?></div>
92 <# if ( data.theme.isActiveTheme ) { #>
93 <h3 class="theme-name" id="{{ data.theme.id }}-name">
95 /* translators: %s: theme name */
96 printf( __( '<span>Active:</span> %s' ), '{{{ data.theme.name }}}' );
100 <h3 class="theme-name" id="{{ data.theme.id }}-name">{{{ data.theme.name }}}</h3>
101 <div class="theme-actions">
102 <button type="button" class="button theme-details"><?php _e( 'Theme Details' ); ?></button>