mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-03 06:57:35 +01:00
Themes: Remove legacy theme preview.
The pre-3.4 theme previewer doesn't work when using a static front page. We kept the old theme preview for no-JS and some browsers that were less capable. But since browsers are doing a better job today we don't need to continue fixing/shipping this legacy code. Bye! fixes #33178. Built from https://develop.svn.wordpress.org/trunk@33492 git-svn-id: http://core.svn.wordpress.org/trunk@33459 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
49b3ad2251
commit
8679a93f16
@ -213,14 +213,6 @@ do_action( 'customize_controls_print_scripts' );
|
|||||||
*/
|
*/
|
||||||
$allowed_urls = array_unique( apply_filters( 'customize_allowed_urls', $allowed_urls ) );
|
$allowed_urls = array_unique( apply_filters( 'customize_allowed_urls', $allowed_urls ) );
|
||||||
|
|
||||||
$fallback_url = add_query_arg( array(
|
|
||||||
'preview' => 1,
|
|
||||||
'template' => $wp_customize->get_template(),
|
|
||||||
'stylesheet' => $wp_customize->get_stylesheet(),
|
|
||||||
'preview_iframe' => true,
|
|
||||||
'TB_iframe' => 'true'
|
|
||||||
), home_url( '/' ) );
|
|
||||||
|
|
||||||
$login_url = add_query_arg( array(
|
$login_url = add_query_arg( array(
|
||||||
'interim-login' => 1,
|
'interim-login' => 1,
|
||||||
'customize-login' => 1
|
'customize-login' => 1
|
||||||
@ -239,7 +231,6 @@ do_action( 'customize_controls_print_scripts' );
|
|||||||
'ajax' => esc_url_raw( admin_url( 'admin-ajax.php', 'relative' ) ),
|
'ajax' => esc_url_raw( admin_url( 'admin-ajax.php', 'relative' ) ),
|
||||||
'allowed' => array_map( 'esc_url_raw', $allowed_urls ),
|
'allowed' => array_map( 'esc_url_raw', $allowed_urls ),
|
||||||
'isCrossDomain' => $cross_domain,
|
'isCrossDomain' => $cross_domain,
|
||||||
'fallback' => esc_url_raw( $fallback_url ),
|
|
||||||
'home' => esc_url_raw( home_url( '/' ) ),
|
'home' => esc_url_raw( home_url( '/' ) ),
|
||||||
'login' => esc_url_raw( $login_url ),
|
'login' => esc_url_raw( $login_url ),
|
||||||
),
|
),
|
||||||
|
@ -174,17 +174,10 @@ class WP_Themes_List_Table extends WP_List_Table {
|
|||||||
|
|
||||||
$activate_link = wp_nonce_url( "themes.php?action=activate&template=" . urlencode( $template ) . "&stylesheet=" . urlencode( $stylesheet ), 'switch-theme_' . $stylesheet );
|
$activate_link = wp_nonce_url( "themes.php?action=activate&template=" . urlencode( $template ) . "&stylesheet=" . urlencode( $stylesheet ), 'switch-theme_' . $stylesheet );
|
||||||
|
|
||||||
$preview_link = esc_url( add_query_arg(
|
|
||||||
array( 'preview' => 1, 'template' => urlencode( $template ), 'stylesheet' => urlencode( $stylesheet ), 'preview_iframe' => true, 'TB_iframe' => 'true' ),
|
|
||||||
home_url( '/' ) ) );
|
|
||||||
|
|
||||||
$actions = array();
|
$actions = array();
|
||||||
$actions['activate'] = '<a href="' . $activate_link . '" class="activatelink" title="'
|
$actions['activate'] = '<a href="' . $activate_link . '" class="activatelink" title="'
|
||||||
. esc_attr( sprintf( __( 'Activate “%s”' ), $title ) ) . '">' . __( 'Activate' ) . '</a>';
|
. esc_attr( sprintf( __( 'Activate “%s”' ), $title ) ) . '">' . __( 'Activate' ) . '</a>';
|
||||||
|
|
||||||
$actions['preview'] = '<a href="' . $preview_link . '" class="hide-if-customize" title="'
|
|
||||||
. esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ) . '">' . __( 'Preview' ) . '</a>';
|
|
||||||
|
|
||||||
if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
|
if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
|
||||||
$actions['preview'] .= '<a href="' . wp_customize_url( $stylesheet ) . '" class="load-customize hide-if-no-customize">'
|
$actions['preview'] .= '<a href="' . wp_customize_url( $stylesheet ) . '" class="load-customize hide-if-no-customize">'
|
||||||
. __( 'Live Preview' ) . '</a>';
|
. __( 'Live Preview' ) . '</a>';
|
||||||
@ -205,11 +198,11 @@ class WP_Themes_List_Table extends WP_List_Table {
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<a href="<?php echo $preview_link; ?>" class="screenshot hide-if-customize">
|
<span class="screenshot hide-if-customize">
|
||||||
<?php if ( $screenshot = $theme->get_screenshot() ) : ?>
|
<?php if ( $screenshot = $theme->get_screenshot() ) : ?>
|
||||||
<img src="<?php echo esc_url( $screenshot ); ?>" alt="" />
|
<img src="<?php echo esc_url( $screenshot ); ?>" alt="" />
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</a>
|
</span>
|
||||||
<a href="<?php echo wp_customize_url( $stylesheet ); ?>" class="screenshot load-customize hide-if-no-customize">
|
<a href="<?php echo wp_customize_url( $stylesheet ); ?>" class="screenshot load-customize hide-if-no-customize">
|
||||||
<?php if ( $screenshot = $theme->get_screenshot() ) : ?>
|
<?php if ( $screenshot = $theme->get_screenshot() ) : ?>
|
||||||
<img src="<?php echo esc_url( $screenshot ); ?>" alt="" />
|
<img src="<?php echo esc_url( $screenshot ); ?>" alt="" />
|
||||||
|
@ -650,12 +650,6 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin {
|
|||||||
$stylesheet = $this->upgrader->result['destination_name'];
|
$stylesheet = $this->upgrader->result['destination_name'];
|
||||||
$template = $theme_info->get_template();
|
$template = $theme_info->get_template();
|
||||||
|
|
||||||
$preview_link = add_query_arg( array(
|
|
||||||
'preview' => 1,
|
|
||||||
'template' => urlencode( $template ),
|
|
||||||
'stylesheet' => urlencode( $stylesheet ),
|
|
||||||
), trailingslashit( home_url() ) );
|
|
||||||
|
|
||||||
$activate_link = add_query_arg( array(
|
$activate_link = add_query_arg( array(
|
||||||
'action' => 'activate',
|
'action' => 'activate',
|
||||||
'template' => urlencode( $template ),
|
'template' => urlencode( $template ),
|
||||||
@ -664,7 +658,7 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin {
|
|||||||
$activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
|
$activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
|
||||||
|
|
||||||
$install_actions = array();
|
$install_actions = array();
|
||||||
$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>';
|
|
||||||
if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
|
if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
|
||||||
$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>';
|
$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>';
|
||||||
}
|
}
|
||||||
@ -732,12 +726,6 @@ class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
|
|||||||
$stylesheet = $this->upgrader->result['destination_name'];
|
$stylesheet = $this->upgrader->result['destination_name'];
|
||||||
$template = $theme_info->get_template();
|
$template = $theme_info->get_template();
|
||||||
|
|
||||||
$preview_link = add_query_arg( array(
|
|
||||||
'preview' => 1,
|
|
||||||
'template' => urlencode( $template ),
|
|
||||||
'stylesheet' => urlencode( $stylesheet ),
|
|
||||||
), trailingslashit( home_url() ) );
|
|
||||||
|
|
||||||
$activate_link = add_query_arg( array(
|
$activate_link = add_query_arg( array(
|
||||||
'action' => 'activate',
|
'action' => 'activate',
|
||||||
'template' => urlencode( $template ),
|
'template' => urlencode( $template ),
|
||||||
@ -750,7 +738,6 @@ class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
|
|||||||
$update_actions['preview'] = '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __( 'Customize' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Customize “%s”' ), $name ) . '</span></a>';
|
$update_actions['preview'] = '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __( 'Customize' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Customize “%s”' ), $name ) . '</span></a>';
|
||||||
}
|
}
|
||||||
} elseif ( current_user_can( 'switch_themes' ) ) {
|
} elseif ( current_user_can( 'switch_themes' ) ) {
|
||||||
$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>';
|
|
||||||
if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
|
if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
|
||||||
$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>';
|
$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>';
|
||||||
}
|
}
|
||||||
|
@ -479,13 +479,6 @@ function wp_prepare_themes_for_js( $themes = null ) {
|
|||||||
'actions' => array(
|
'actions' => array(
|
||||||
'activate' => current_user_can( 'switch_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=activate&stylesheet=' . $encoded_slug ), 'switch-theme_' . $slug ) : null,
|
'activate' => current_user_can( 'switch_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=activate&stylesheet=' . $encoded_slug ), 'switch-theme_' . $slug ) : null,
|
||||||
'customize' => ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) ? wp_customize_url( $slug ) : null,
|
'customize' => ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) ? wp_customize_url( $slug ) : null,
|
||||||
'preview' => add_query_arg( array(
|
|
||||||
'preview' => 1,
|
|
||||||
'template' => urlencode( $theme->get_template() ),
|
|
||||||
'stylesheet' => urlencode( $slug ),
|
|
||||||
'preview_iframe' => true,
|
|
||||||
'TB_iframe' => true,
|
|
||||||
), home_url( '/' ) ),
|
|
||||||
'delete' => current_user_can( 'delete_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=delete&stylesheet=' . $encoded_slug ), 'delete-theme_' . $slug ) : null,
|
'delete' => current_user_can( 'delete_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=delete&stylesheet=' . $encoded_slug ), 'delete-theme_' . $slug ) : null,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -3036,9 +3036,10 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redirect to the fallback preview if any incompatibilities are found.
|
// Bail if any incompatibilities are found.
|
||||||
if ( ! $.support.postMessage || ( ! $.support.cors && api.settings.isCrossDomain ) )
|
if ( ! $.support.postMessage || ( ! $.support.cors && api.settings.isCrossDomain ) ) {
|
||||||
return window.location = api.settings.url.fallback;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var parent, topFocus,
|
var parent, topFocus,
|
||||||
body = $( document.body ),
|
body = $( document.body ),
|
||||||
|
2
wp-admin/js/customize-controls.min.js
vendored
2
wp-admin/js/customize-controls.min.js
vendored
File diff suppressed because one or more lines are too long
@ -245,7 +245,6 @@ foreach ( $themes as $theme ) :
|
|||||||
<a class="button button-secondary activate" href="<?php echo $theme['actions']['activate']; ?>"><?php _e( 'Activate' ); ?></a>
|
<a class="button button-secondary activate" href="<?php echo $theme['actions']['activate']; ?>"><?php _e( 'Activate' ); ?></a>
|
||||||
<?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
|
<?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
|
||||||
<a class="button button-primary load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Live Preview' ); ?></a>
|
<a class="button button-primary load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Live Preview' ); ?></a>
|
||||||
<a class="button button-secondary hide-if-customize" href="<?php echo $theme['actions']['preview']; ?>"><?php _e( 'Preview' ); ?></a>
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
@ -347,7 +346,6 @@ $can_delete = current_user_can( 'delete_themes' );
|
|||||||
<# } else { #>
|
<# } else { #>
|
||||||
<a class="button button-secondary activate" href="{{{ data.actions.activate }}}"><?php _e( 'Activate' ); ?></a>
|
<a class="button button-secondary activate" href="{{{ data.actions.activate }}}"><?php _e( 'Activate' ); ?></a>
|
||||||
<a class="button button-primary load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Live Preview' ); ?></a>
|
<a class="button button-primary load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Live Preview' ); ?></a>
|
||||||
<a class="button button-secondary hide-if-customize" href="{{{ data.actions.preview }}}"><?php _e( 'Preview' ); ?></a>
|
|
||||||
<# } #>
|
<# } #>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@ -409,7 +407,6 @@ $can_delete = current_user_can( 'delete_themes' );
|
|||||||
<a href="{{{ data.actions.activate }}}" class="button button-secondary activate"><?php _e( 'Activate' ); ?></a>
|
<a href="{{{ data.actions.activate }}}" class="button button-secondary activate"><?php _e( 'Activate' ); ?></a>
|
||||||
<# } #>
|
<# } #>
|
||||||
<a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a>
|
<a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a>
|
||||||
<a href="{{{ data.actions.preview }}}" class="button button-secondary hide-if-customize"><?php _e( 'Preview' ); ?></a>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<# if ( ! data.active && data.actions['delete'] ) { #>
|
<# if ( ! data.active && data.actions['delete'] ) { #>
|
||||||
|
@ -335,7 +335,6 @@ add_action( 'split_shared_term', '_wp_check_split_terms_in_menus', 10, 4 );
|
|||||||
* Filters formerly mixed into wp-includes
|
* Filters formerly mixed into wp-includes
|
||||||
*/
|
*/
|
||||||
// Theme
|
// Theme
|
||||||
add_action( 'setup_theme', 'preview_theme' );
|
|
||||||
add_action( 'wp_loaded', '_custom_header_background_just_in_time' );
|
add_action( 'wp_loaded', '_custom_header_background_just_in_time' );
|
||||||
add_action( 'plugins_loaded', '_wp_customize_include' );
|
add_action( 'plugins_loaded', '_wp_customize_include' );
|
||||||
add_action( 'admin_enqueue_scripts', '_wp_customize_loader_settings' );
|
add_action( 'admin_enqueue_scripts', '_wp_customize_loader_settings' );
|
||||||
|
@ -3492,6 +3492,79 @@ function url_is_accessable_via_ssl( $url ) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start preview theme output buffer.
|
||||||
|
*
|
||||||
|
* Will only perform task if the user has permissions and template and preview
|
||||||
|
* query variables exist.
|
||||||
|
*
|
||||||
|
* @since 2.6.0
|
||||||
|
* @deprecated 4.3.0
|
||||||
|
*/
|
||||||
|
function preview_theme() {
|
||||||
|
_deprecated_function( __FUNCTION__, '4.3' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private function to modify the current template when previewing a theme
|
||||||
|
*
|
||||||
|
* @since 2.9.0
|
||||||
|
* @deprecated 4.3.0
|
||||||
|
* @access private
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _preview_theme_template_filter() {
|
||||||
|
_deprecated_function( __FUNCTION__, '4.3' );
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private function to modify the current stylesheet when previewing a theme
|
||||||
|
*
|
||||||
|
* @since 2.9.0
|
||||||
|
* @deprecated 4.3.0
|
||||||
|
* @access private
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _preview_theme_stylesheet_filter() {
|
||||||
|
_deprecated_function( __FUNCTION__, '4.3' );
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback function for ob_start() to capture all links in the theme.
|
||||||
|
*
|
||||||
|
* @since 2.6.0
|
||||||
|
* @deprecated 4.3.0
|
||||||
|
* @access private
|
||||||
|
*
|
||||||
|
* @param string $content
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function preview_theme_ob_filter( $content ) {
|
||||||
|
_deprecated_function( __FUNCTION__, '4.3' );
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manipulates preview theme links in order to control and maintain location.
|
||||||
|
*
|
||||||
|
* Callback function for preg_replace_callback() to accept and filter matches.
|
||||||
|
*
|
||||||
|
* @since 2.6.0
|
||||||
|
* @deprecated 4.3.0
|
||||||
|
* @access private
|
||||||
|
*
|
||||||
|
* @param array $matches
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function preview_theme_ob_filter_callback( $matches ) {
|
||||||
|
_deprecated_function( __FUNCTION__, '4.3' );
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats text for the rich text editor.
|
* Formats text for the rich text editor.
|
||||||
*
|
*
|
||||||
|
@ -660,116 +660,6 @@ function locale_stylesheet() {
|
|||||||
echo '<link rel="stylesheet" href="' . $stylesheet . '" type="text/css" media="screen" />';
|
echo '<link rel="stylesheet" href="' . $stylesheet . '" type="text/css" media="screen" />';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Start preview theme output buffer.
|
|
||||||
*
|
|
||||||
* Will only perform task if the user has permissions and template and preview
|
|
||||||
* query variables exist.
|
|
||||||
*
|
|
||||||
* @since 2.6.0
|
|
||||||
*/
|
|
||||||
function preview_theme() {
|
|
||||||
if ( ! (isset($_GET['template']) && isset($_GET['preview'])) )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ( !current_user_can( 'switch_themes' ) )
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Admin Thickbox requests
|
|
||||||
if ( isset( $_GET['preview_iframe'] ) )
|
|
||||||
show_admin_bar( false );
|
|
||||||
|
|
||||||
$_GET['template'] = preg_replace('|[^a-z0-9_./-]|i', '', $_GET['template']);
|
|
||||||
|
|
||||||
if ( validate_file($_GET['template']) )
|
|
||||||
return;
|
|
||||||
|
|
||||||
add_filter( 'template', '_preview_theme_template_filter' );
|
|
||||||
|
|
||||||
if ( isset($_GET['stylesheet']) ) {
|
|
||||||
$_GET['stylesheet'] = preg_replace('|[^a-z0-9_./-]|i', '', $_GET['stylesheet']);
|
|
||||||
if ( validate_file($_GET['stylesheet']) )
|
|
||||||
return;
|
|
||||||
add_filter( 'stylesheet', '_preview_theme_stylesheet_filter' );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prevent theme mods to current theme being used on theme being previewed
|
|
||||||
add_filter( 'pre_option_theme_mods_' . get_option( 'stylesheet' ), '__return_empty_array' );
|
|
||||||
|
|
||||||
ob_start( 'preview_theme_ob_filter' );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Private function to modify the current template when previewing a theme
|
|
||||||
*
|
|
||||||
* @since 2.9.0
|
|
||||||
* @access private
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function _preview_theme_template_filter() {
|
|
||||||
return isset($_GET['template']) ? $_GET['template'] : '';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Private function to modify the current stylesheet when previewing a theme
|
|
||||||
*
|
|
||||||
* @since 2.9.0
|
|
||||||
* @access private
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function _preview_theme_stylesheet_filter() {
|
|
||||||
return isset($_GET['stylesheet']) ? $_GET['stylesheet'] : '';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback function for ob_start() to capture all links in the theme.
|
|
||||||
*
|
|
||||||
* @since 2.6.0
|
|
||||||
* @access private
|
|
||||||
*
|
|
||||||
* @param string $content
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function preview_theme_ob_filter( $content ) {
|
|
||||||
return preg_replace_callback( "|(<a.*?href=([\"']))(.*?)([\"'].*?>)|", 'preview_theme_ob_filter_callback', $content );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Manipulates preview theme links in order to control and maintain location.
|
|
||||||
*
|
|
||||||
* Callback function for preg_replace_callback() to accept and filter matches.
|
|
||||||
*
|
|
||||||
* @since 2.6.0
|
|
||||||
* @access private
|
|
||||||
*
|
|
||||||
* @param array $matches
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function preview_theme_ob_filter_callback( $matches ) {
|
|
||||||
if ( strpos($matches[4], 'onclick') !== false )
|
|
||||||
$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.
|
|
||||||
if (
|
|
||||||
( false !== strpos($matches[3], '/wp-admin/') )
|
|
||||||
||
|
|
||||||
( false !== strpos( $matches[3], '://' ) && 0 !== strpos( $matches[3], home_url() ) )
|
|
||||||
||
|
|
||||||
( false !== strpos($matches[3], '/feed/') )
|
|
||||||
||
|
|
||||||
( false !== strpos($matches[3], '/trackback/') )
|
|
||||||
)
|
|
||||||
return $matches[1] . "#$matches[2] onclick=$matches[2]return false;" . $matches[4];
|
|
||||||
|
|
||||||
$stylesheet = isset( $_GET['stylesheet'] ) ? $_GET['stylesheet'] : '';
|
|
||||||
$template = isset( $_GET['template'] ) ? $_GET['template'] : '';
|
|
||||||
|
|
||||||
$link = add_query_arg( array( 'preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'preview_iframe' => 1 ), $matches[3] );
|
|
||||||
if ( 0 === strpos($link, 'preview=1') )
|
|
||||||
$link = "?$link";
|
|
||||||
return $matches[1] . esc_attr( $link ) . $matches[4];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Switches the theme.
|
* Switches the theme.
|
||||||
*
|
*
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.3-beta4-33491';
|
$wp_version = '4.3-beta4-33492';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user