Customizer: Escape theme preview URLs.

props johnbillion, ocean90.
see #31896.

git-svn-id: https://develop.svn.wordpress.org/trunk@32134 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling (ocean90) 2015-04-15 16:32:03 +00:00
parent 686b4af44d
commit 7fba67e4b7
2 changed files with 5 additions and 2 deletions

View File

@ -511,6 +511,8 @@ function wp_prepare_themes_for_js( $themes = null ) {
* @since 4.2.0
*/
function customize_themes_print_templates() {
$preview_url = esc_url( add_query_arg( 'theme', '__THEME__' ) ); // Token because esc_url() strips curly braces.
$preview_url = str_replace( '__THEME__', '{{ data.id }}', $preview_url );
?>
<script type="text/html" id="tmpl-customize-themes-details-view">
<div class="theme-backdrop"></div>
@ -550,7 +552,7 @@ function customize_themes_print_templates() {
<# if ( ! data.active ) { #>
<div class="theme-actions">
<div class="inactive-theme">
<a href="<?php echo add_query_arg( 'theme', '{{ data.id }}' ); ?>" target="_top" class="button button-primary"><?php _e( 'Live Preview' ); ?></a>
<a href="<?php echo $preview_url; ?>" target="_top" class="button button-primary"><?php _e( 'Live Preview' ); ?></a>
</div>
</div>
<# } #>

View File

@ -1243,7 +1243,8 @@ class WP_Customize_Theme_Control extends WP_Customize_Control {
*/
public function content_template() {
$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
$preview_url = add_query_arg( 'theme', '{{ data.theme.id }}', $current_url );
$preview_url = esc_url( add_query_arg( 'theme', '__THEME__', $current_url ) ); // Token because esc_url() strips curly braces.
$preview_url = str_replace( '__THEME__', '{{ data.theme.id }}', $preview_url );
?>
<div class="theme" tabindex="0" data-preview-url="<?php echo esc_attr( $preview_url ); ?>" aria-describedby="{{ data.theme.id }}-action {{ data.theme.id }}-name">
<# if ( data.theme.screenshot[0] ) { #>