Make WordPress Core

Changeset 33551


Ignore:
Timestamp:
08/03/2015 09:20:25 PM (11 years ago)
Author:
ocean90
Message:

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

Merge of [33549] to the 4.0 branch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/4.0/src/wp-includes/theme.php

    r29275 r33551  
    674674    // Prevent theme mods to current theme being used on theme being previewed
    675675    add_filter( 'pre_option_theme_mods_' . get_option( 'stylesheet' ), '__return_empty_array' );
    676 
    677     ob_start( 'preview_theme_ob_filter' );
    678676}
    679677add_action('setup_theme', 'preview_theme');
     
    713711 */
    714712function preview_theme_ob_filter( $content ) {
    715     return preg_replace_callback( "|(<a.*?href=([\"']))(.*?)([\"'].*?>)|", 'preview_theme_ob_filter_callback', $content );
     713    return $content;
    716714}
    717715
     
    728726 */
    729727function preview_theme_ob_filter_callback( $matches ) {
    730     if ( strpos($matches[4], 'onclick') !== false )
    731         $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.
    732     if (
    733         ( false !== strpos($matches[3], '/wp-admin/') )
    734     ||
    735         ( false !== strpos( $matches[3], '://' ) && 0 !== strpos( $matches[3], home_url() ) )
    736     ||
    737         ( false !== strpos($matches[3], '/feed/') )
    738     ||
    739         ( false !== strpos($matches[3], '/trackback/') )
    740     )
    741         return $matches[1] . "#$matches[2] onclick=$matches[2]return false;" . $matches[4];
    742 
    743     $stylesheet = isset( $_GET['stylesheet'] ) ? $_GET['stylesheet'] : '';
    744     $template   = isset( $_GET['template'] )   ? $_GET['template']   : '';
    745 
    746     $link = add_query_arg( array( 'preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'preview_iframe' => 1 ), $matches[3] );
    747     if ( 0 === strpos($link, 'preview=1') )
    748         $link = "?$link";
    749     return $matches[1] . esc_attr( $link ) . $matches[4];
     728    return $matches[0];
    750729}
    751730
Note: See TracChangeset for help on using the changeset viewer.