Make WordPress Core

Changeset 33549


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

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

File:
1 edited

Legend:

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

    r32048 r33549  
    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}
    679677
     
    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.