2015-10-24 14:57:25 -04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Customize API: WP_Customize_Theme_Control class
|
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Customize
|
|
|
|
* @since 4.4.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Customize Theme Control class.
|
|
|
|
*
|
|
|
|
* @since 4.2.0
|
|
|
|
*
|
|
|
|
* @see WP_Customize_Control
|
|
|
|
*/
|
|
|
|
class WP_Customize_Theme_Control extends WP_Customize_Control {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Customize control type.
|
|
|
|
*
|
|
|
|
* @since 4.2.0
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public $type = 'theme';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Theme object.
|
|
|
|
*
|
|
|
|
* @since 4.2.0
|
|
|
|
* @var WP_Theme
|
|
|
|
*/
|
|
|
|
public $theme;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Refresh the parameters passed to the JavaScript via JSON.
|
|
|
|
*
|
|
|
|
* @since 4.2.0
|
|
|
|
*
|
|
|
|
* @see WP_Customize_Control::to_json()
|
|
|
|
*/
|
|
|
|
public function to_json() {
|
|
|
|
parent::to_json();
|
|
|
|
$this->json['theme'] = $this->theme;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Don't render the control content from PHP, as it's rendered via JS on load.
|
|
|
|
*
|
|
|
|
* @since 4.2.0
|
|
|
|
*/
|
|
|
|
public function render_content() {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render a JS template for theme display.
|
|
|
|
*
|
|
|
|
* @since 4.2.0
|
|
|
|
*/
|
|
|
|
public function content_template() {
|
2016-11-04 13:18:26 -04:00
|
|
|
$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
|
|
|
|
$active_url = esc_url( remove_query_arg( 'customize_theme', $current_url ) );
|
|
|
|
$preview_url = esc_url( add_query_arg( 'customize_theme', '__THEME__', $current_url ) ); // Token because esc_url() strips curly braces.
|
|
|
|
$preview_url = str_replace( '__THEME__', '{{ data.theme.id }}', $preview_url );
|
2015-10-24 14:57:25 -04:00
|
|
|
?>
|
2016-11-04 13:18:26 -04:00
|
|
|
<# if ( data.theme.isActiveTheme ) { #>
|
|
|
|
<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">
|
2015-10-24 14:57:25 -04:00
|
|
|
<# } else { #>
|
2016-11-04 13:18:26 -04:00
|
|
|
<div class="theme" tabindex="0" data-preview-url="<?php echo esc_attr( $preview_url ); ?>" aria-describedby="{{ data.theme.id }}-action {{ data.theme.id }}-name">
|
2015-10-24 14:57:25 -04:00
|
|
|
<# } #>
|
|
|
|
|
2016-11-04 13:18:26 -04:00
|
|
|
<# if ( data.theme.screenshot[0] ) { #>
|
2015-10-24 14:57:25 -04:00
|
|
|
<div class="theme-screenshot">
|
|
|
|
<img data-src="{{ data.theme.screenshot[0] }}" alt="" />
|
|
|
|
</div>
|
|
|
|
<# } else { #>
|
|
|
|
<div class="theme-screenshot blank"></div>
|
|
|
|
<# } #>
|
|
|
|
|
2016-11-04 13:18:26 -04:00
|
|
|
<# if ( data.theme.isActiveTheme ) { #>
|
|
|
|
<span class="more-details" id="{{ data.theme.id }}-action"><?php _e( 'Customize' ); ?></span>
|
|
|
|
<# } else { #>
|
|
|
|
<span class="more-details" id="{{ data.theme.id }}-action"><?php _e( 'Live Preview' ); ?></span>
|
2016-10-18 23:20:29 -04:00
|
|
|
<# } #>
|
|
|
|
|
2016-11-20 21:46:30 -05:00
|
|
|
<div class="theme-author"><?php
|
|
|
|
/* translators: Theme author name */
|
|
|
|
printf( _x( 'By %s', 'theme author' ), '{{ data.theme.author }}' );
|
|
|
|
?></div>
|
2016-11-04 13:18:26 -04:00
|
|
|
|
|
|
|
<# if ( data.theme.isActiveTheme ) { #>
|
|
|
|
<h3 class="theme-name" id="{{ data.theme.id }}-name">
|
2015-10-24 14:57:25 -04:00
|
|
|
<?php
|
|
|
|
/* translators: %s: theme name */
|
2016-11-04 13:18:26 -04:00
|
|
|
printf( __( '<span>Active:</span> %s' ), '{{{ data.theme.name }}}' );
|
2015-10-24 14:57:25 -04:00
|
|
|
?>
|
|
|
|
</h3>
|
|
|
|
<# } else { #>
|
2016-11-04 13:18:26 -04:00
|
|
|
<h3 class="theme-name" id="{{ data.theme.id }}-name">{{{ data.theme.name }}}</h3>
|
2015-10-24 14:57:25 -04:00
|
|
|
<div class="theme-actions">
|
2016-11-04 13:18:26 -04:00
|
|
|
<button type="button" class="button theme-details"><?php _e( 'Theme Details' ); ?></button>
|
2015-10-24 14:57:25 -04:00
|
|
|
</div>
|
|
|
|
<# } #>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
}
|