Make WordPress Core

Changeset 33550


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

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

Merge of [33549] to the 4.1 branch.

File:
1 edited

Legend:

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

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