Changeset 33492
- Timestamp:
- 07/29/2015 06:35:40 PM (9 years ago)
- Location:
- trunk/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/customize.php
r33153 r33492 214 214 $allowed_urls = array_unique( apply_filters( 'customize_allowed_urls', $allowed_urls ) ); 215 215 216 $fallback_url = add_query_arg( array(217 'preview' => 1,218 'template' => $wp_customize->get_template(),219 'stylesheet' => $wp_customize->get_stylesheet(),220 'preview_iframe' => true,221 'TB_iframe' => 'true'222 ), home_url( '/' ) );223 224 216 $login_url = add_query_arg( array( 225 217 'interim-login' => 1, … … 240 232 'allowed' => array_map( 'esc_url_raw', $allowed_urls ), 241 233 'isCrossDomain' => $cross_domain, 242 'fallback' => esc_url_raw( $fallback_url ),243 234 'home' => esc_url_raw( home_url( '/' ) ), 244 235 'login' => esc_url_raw( $login_url ), -
trunk/src/wp-admin/includes/class-wp-themes-list-table.php
r32656 r33492 175 175 $activate_link = wp_nonce_url( "themes.php?action=activate&template=" . urlencode( $template ) . "&stylesheet=" . urlencode( $stylesheet ), 'switch-theme_' . $stylesheet ); 176 176 177 $preview_link = esc_url( add_query_arg(178 array( 'preview' => 1, 'template' => urlencode( $template ), 'stylesheet' => urlencode( $stylesheet ), 'preview_iframe' => true, 'TB_iframe' => 'true' ),179 home_url( '/' ) ) );180 181 177 $actions = array(); 182 178 $actions['activate'] = '<a href="' . $activate_link . '" class="activatelink" title="' 183 179 . esc_attr( sprintf( __( 'Activate “%s”' ), $title ) ) . '">' . __( 'Activate' ) . '</a>'; 184 185 $actions['preview'] = '<a href="' . $preview_link . '" class="hide-if-customize" title="'186 . esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ) . '">' . __( 'Preview' ) . '</a>';187 180 188 181 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { … … 206 199 ?> 207 200 208 < a href="<?php echo $preview_link; ?>"class="screenshot hide-if-customize">201 <span class="screenshot hide-if-customize"> 209 202 <?php if ( $screenshot = $theme->get_screenshot() ) : ?> 210 203 <img src="<?php echo esc_url( $screenshot ); ?>" alt="" /> 211 204 <?php endif; ?> 212 </ a>205 </span> 213 206 <a href="<?php echo wp_customize_url( $stylesheet ); ?>" class="screenshot load-customize hide-if-no-customize"> 214 207 <?php if ( $screenshot = $theme->get_screenshot() ) : ?> -
trunk/src/wp-admin/includes/class-wp-upgrader-skins.php
r32974 r33492 651 651 $template = $theme_info->get_template(); 652 652 653 $preview_link = add_query_arg( array(654 'preview' => 1,655 'template' => urlencode( $template ),656 'stylesheet' => urlencode( $stylesheet ),657 ), trailingslashit( home_url() ) );658 659 653 $activate_link = add_query_arg( array( 660 654 'action' => 'activate', … … 665 659 666 660 $install_actions = array(); 667 $install_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-customize"><span aria-hidden="true">' . __( 'Preview' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Preview “%s”' ), $name ) . '</span></a>'; 661 668 662 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { 669 663 $install_actions['preview'] .= '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __( 'Live Preview' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Live Preview “%s”' ), $name ) . '</span></a>'; … … 733 727 $template = $theme_info->get_template(); 734 728 735 $preview_link = add_query_arg( array(736 'preview' => 1,737 'template' => urlencode( $template ),738 'stylesheet' => urlencode( $stylesheet ),739 ), trailingslashit( home_url() ) );740 741 729 $activate_link = add_query_arg( array( 742 730 'action' => 'activate', … … 751 739 } 752 740 } elseif ( current_user_can( 'switch_themes' ) ) { 753 $update_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-customize"><span aria-hidden="true">' . __( 'Preview' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Preview “%s”' ), $name ) . '</span></a>';754 741 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { 755 742 $update_actions['preview'] .= '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __( 'Live Preview' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Live Preview “%s”' ), $name ) . '</span></a>'; -
trunk/src/wp-admin/includes/theme.php
r32965 r33492 480 480 'activate' => current_user_can( 'switch_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=activate&stylesheet=' . $encoded_slug ), 'switch-theme_' . $slug ) : null, 481 481 'customize' => ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) ? wp_customize_url( $slug ) : null, 482 'preview' => add_query_arg( array(483 'preview' => 1,484 'template' => urlencode( $theme->get_template() ),485 'stylesheet' => urlencode( $slug ),486 'preview_iframe' => true,487 'TB_iframe' => true,488 ), home_url( '/' ) ),489 482 'delete' => current_user_can( 'delete_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=delete&stylesheet=' . $encoded_slug ), 'delete-theme_' . $slug ) : null, 490 483 ), -
trunk/src/wp-admin/js/customize-controls.js
r33454 r33492 3037 3037 } 3038 3038 3039 // Redirect to the fallback preview if any incompatibilities are found. 3040 if ( ! $.support.postMessage || ( ! $.support.cors && api.settings.isCrossDomain ) ) 3041 return window.location = api.settings.url.fallback; 3039 // Bail if any incompatibilities are found. 3040 if ( ! $.support.postMessage || ( ! $.support.cors && api.settings.isCrossDomain ) ) { 3041 return; 3042 } 3042 3043 3043 3044 var parent, topFocus, -
trunk/src/wp-admin/themes.php
r33456 r33492 246 246 <?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?> 247 247 <a class="button button-primary load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Live Preview' ); ?></a> 248 <a class="button button-secondary hide-if-customize" href="<?php echo $theme['actions']['preview']; ?>"><?php _e( 'Preview' ); ?></a>249 248 <?php } ?> 250 249 <?php } ?> … … 348 347 <a class="button button-secondary activate" href="{{{ data.actions.activate }}}"><?php _e( 'Activate' ); ?></a> 349 348 <a class="button button-primary load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Live Preview' ); ?></a> 350 <a class="button button-secondary hide-if-customize" href="{{{ data.actions.preview }}}"><?php _e( 'Preview' ); ?></a>351 349 <# } #> 352 350 … … 410 408 <# } #> 411 409 <a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a> 412 <a href="{{{ data.actions.preview }}}" class="button button-secondary hide-if-customize"><?php _e( 'Preview' ); ?></a>413 410 </div> 414 411 -
trunk/src/wp-includes/default-filters.php
r33187 r33492 336 336 */ 337 337 // Theme 338 add_action( 'setup_theme', 'preview_theme' );339 338 add_action( 'wp_loaded', '_custom_header_background_just_in_time' ); 340 339 add_action( 'plugins_loaded', '_wp_customize_include' ); -
trunk/src/wp-includes/deprecated.php
r32964 r33492 3494 3494 3495 3495 /** 3496 * Start preview theme output buffer. 3497 * 3498 * Will only perform task if the user has permissions and template and preview 3499 * query variables exist. 3500 * 3501 * @since 2.6.0 3502 * @deprecated 4.3.0 3503 */ 3504 function preview_theme() { 3505 _deprecated_function( __FUNCTION__, '4.3' ); 3506 } 3507 3508 /** 3509 * Private function to modify the current template when previewing a theme 3510 * 3511 * @since 2.9.0 3512 * @deprecated 4.3.0 3513 * @access private 3514 * 3515 * @return string 3516 */ 3517 function _preview_theme_template_filter() { 3518 _deprecated_function( __FUNCTION__, '4.3' ); 3519 return ''; 3520 } 3521 3522 /** 3523 * Private function to modify the current stylesheet when previewing a theme 3524 * 3525 * @since 2.9.0 3526 * @deprecated 4.3.0 3527 * @access private 3528 * 3529 * @return string 3530 */ 3531 function _preview_theme_stylesheet_filter() { 3532 _deprecated_function( __FUNCTION__, '4.3' ); 3533 return ''; 3534 } 3535 3536 /** 3537 * Callback function for ob_start() to capture all links in the theme. 3538 * 3539 * @since 2.6.0 3540 * @deprecated 4.3.0 3541 * @access private 3542 * 3543 * @param string $content 3544 * @return string 3545 */ 3546 function preview_theme_ob_filter( $content ) { 3547 _deprecated_function( __FUNCTION__, '4.3' ); 3548 return $content; 3549 } 3550 3551 /** 3552 * Manipulates preview theme links in order to control and maintain location. 3553 * 3554 * Callback function for preg_replace_callback() to accept and filter matches. 3555 * 3556 * @since 2.6.0 3557 * @deprecated 4.3.0 3558 * @access private 3559 * 3560 * @param array $matches 3561 * @return string 3562 */ 3563 function preview_theme_ob_filter_callback( $matches ) { 3564 _deprecated_function( __FUNCTION__, '4.3' ); 3565 return ''; 3566 } 3567 3568 /** 3496 3569 * Formats text for the rich text editor. 3497 3570 * -
trunk/src/wp-includes/theme.php
r33278 r33492 662 662 663 663 /** 664 * Start preview theme output buffer.665 *666 * Will only perform task if the user has permissions and template and preview667 * query variables exist.668 *669 * @since 2.6.0670 */671 function preview_theme() {672 if ( ! (isset($_GET['template']) && isset($_GET['preview'])) )673 return;674 675 if ( !current_user_can( 'switch_themes' ) )676 return;677 678 // Admin Thickbox requests679 if ( isset( $_GET['preview_iframe'] ) )680 show_admin_bar( false );681 682 $_GET['template'] = preg_replace('|[^a-z0-9_./-]|i', '', $_GET['template']);683 684 if ( validate_file($_GET['template']) )685 return;686 687 add_filter( 'template', '_preview_theme_template_filter' );688 689 if ( isset($_GET['stylesheet']) ) {690 $_GET['stylesheet'] = preg_replace('|[^a-z0-9_./-]|i', '', $_GET['stylesheet']);691 if ( validate_file($_GET['stylesheet']) )692 return;693 add_filter( 'stylesheet', '_preview_theme_stylesheet_filter' );694 }695 696 // Prevent theme mods to current theme being used on theme being previewed697 add_filter( 'pre_option_theme_mods_' . get_option( 'stylesheet' ), '__return_empty_array' );698 699 ob_start( 'preview_theme_ob_filter' );700 }701 702 /**703 * Private function to modify the current template when previewing a theme704 *705 * @since 2.9.0706 * @access private707 *708 * @return string709 */710 function _preview_theme_template_filter() {711 return isset($_GET['template']) ? $_GET['template'] : '';712 }713 714 /**715 * Private function to modify the current stylesheet when previewing a theme716 *717 * @since 2.9.0718 * @access private719 *720 * @return string721 */722 function _preview_theme_stylesheet_filter() {723 return isset($_GET['stylesheet']) ? $_GET['stylesheet'] : '';724 }725 726 /**727 * Callback function for ob_start() to capture all links in the theme.728 *729 * @since 2.6.0730 * @access private731 *732 * @param string $content733 * @return string734 */735 function preview_theme_ob_filter( $content ) {736 return preg_replace_callback( "|(<a.*?href=([\"']))(.*?)([\"'].*?>)|", 'preview_theme_ob_filter_callback', $content );737 }738 739 /**740 * Manipulates preview theme links in order to control and maintain location.741 *742 * Callback function for preg_replace_callback() to accept and filter matches.743 *744 * @since 2.6.0745 * @access private746 *747 * @param array $matches748 * @return string749 */750 function preview_theme_ob_filter_callback( $matches ) {751 if ( strpos($matches[4], 'onclick') !== false )752 $matches[4] = preg_replace('#onclick=([\'"]).*?(?<!\\\)\\1#i', '', $matches[4]); //Strip out any onclicks from rest of <a>. (?<!\\\) means to ignore the '" if it's escaped by \ to prevent breaking mid-attribute.753 if (754 ( false !== strpos($matches[3], '/wp-admin/') )755 ||756 ( false !== strpos( $matches[3], '://' ) && 0 !== strpos( $matches[3], home_url() ) )757 ||758 ( false !== strpos($matches[3], '/feed/') )759 ||760 ( false !== strpos($matches[3], '/trackback/') )761 )762 return $matches[1] . "#$matches[2] onclick=$matches[2]return false;" . $matches[4];763 764 $stylesheet = isset( $_GET['stylesheet'] ) ? $_GET['stylesheet'] : '';765 $template = isset( $_GET['template'] ) ? $_GET['template'] : '';766 767 $link = add_query_arg( array( 'preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'preview_iframe' => 1 ), $matches[3] );768 if ( 0 === strpos($link, 'preview=1') )769 $link = "?$link";770 return $matches[1] . esc_attr( $link ) . $matches[4];771 }772 773 /**774 664 * Switches the theme. 775 665 *
Note: See TracChangeset
for help on using the changeset viewer.