Themes: Fix some broken links in the legacy theme preview.

Merge of [33549] to the 3.8 branch.
Built from https://develop.svn.wordpress.org/branches/3.8@33553


git-svn-id: http://core.svn.wordpress.org/branches/3.8@33520 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2015-08-04 04:58:04 +00:00
parent ebe4779cea
commit 6d3a23c410
1 changed files with 2 additions and 23 deletions

View File

@ -665,8 +665,6 @@ function preview_theme() {
// 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' );
}
add_action('setup_theme', 'preview_theme');
@ -704,7 +702,7 @@ function _preview_theme_stylesheet_filter() {
* @return string
*/
function preview_theme_ob_filter( $content ) {
return preg_replace_callback( "|(<a.*?href=([\"']))(.*?)([\"'].*?>)|", 'preview_theme_ob_filter_callback', $content );
return $content;
}
/**
@ -719,26 +717,7 @@ function preview_theme_ob_filter( $content ) {
* @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];
return $matches[0];
}
/**