Make WordPress Core

Changeset 33553


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

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

Merge of [33549] to the 3.8 branch.

File:
1 edited

Legend:

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

    r26594 r33553  
    666666    // Prevent theme mods to current theme being used on theme being previewed
    667667    add_filter( 'pre_option_theme_mods_' . get_option( 'stylesheet' ), '__return_empty_array' );
    668 
    669     ob_start( 'preview_theme_ob_filter' );
    670668}
    671669add_action('setup_theme', 'preview_theme');
     
    705703 */
    706704function preview_theme_ob_filter( $content ) {
    707     return preg_replace_callback( "|(<a.*?href=([\"']))(.*?)([\"'].*?>)|", 'preview_theme_ob_filter_callback', $content );
     705    return $content;
    708706}
    709707
     
    720718 */
    721719function preview_theme_ob_filter_callback( $matches ) {
    722     if ( strpos($matches[4], 'onclick') !== false )
    723         $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.
    724     if (
    725         ( false !== strpos($matches[3], '/wp-admin/') )
    726     ||
    727         ( false !== strpos( $matches[3], '://' ) && 0 !== strpos( $matches[3], home_url() ) )
    728     ||
    729         ( false !== strpos($matches[3], '/feed/') )
    730     ||
    731         ( false !== strpos($matches[3], '/trackback/') )
    732     )
    733         return $matches[1] . "#$matches[2] onclick=$matches[2]return false;" . $matches[4];
    734 
    735     $stylesheet = isset( $_GET['stylesheet'] ) ? $_GET['stylesheet'] : '';
    736     $template   = isset( $_GET['template'] )   ? $_GET['template']   : '';
    737 
    738     $link = add_query_arg( array( 'preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'preview_iframe' => 1 ), $matches[3] );
    739     if ( 0 === strpos($link, 'preview=1') )
    740         $link = "?$link";
    741     return $matches[1] . esc_attr( $link ) . $matches[4];
     720    return $matches[0];
    742721}
    743722
Note: See TracChangeset for help on using the changeset viewer.