Make WordPress Core

Changeset 33554


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

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

Merge of [33549] to the 3.7 branch.

File:
1 edited

Legend:

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

    r25272 r33554  
    583583    // Prevent theme mods to current theme being used on theme being previewed
    584584    add_filter( 'pre_option_theme_mods_' . get_option( 'stylesheet' ), '__return_empty_array' );
    585 
    586     ob_start( 'preview_theme_ob_filter' );
    587585}
    588586add_action('setup_theme', 'preview_theme');
     
    622620 */
    623621function preview_theme_ob_filter( $content ) {
    624     return preg_replace_callback( "|(<a.*?href=([\"']))(.*?)([\"'].*?>)|", 'preview_theme_ob_filter_callback', $content );
     622    return $content;
    625623}
    626624
     
    637635 */
    638636function preview_theme_ob_filter_callback( $matches ) {
    639     if ( strpos($matches[4], 'onclick') !== false )
    640         $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.
    641     if (
    642         ( false !== strpos($matches[3], '/wp-admin/') )
    643     ||
    644         ( false !== strpos( $matches[3], '://' ) && 0 !== strpos( $matches[3], home_url() ) )
    645     ||
    646         ( false !== strpos($matches[3], '/feed/') )
    647     ||
    648         ( false !== strpos($matches[3], '/trackback/') )
    649     )
    650         return $matches[1] . "#$matches[2] onclick=$matches[2]return false;" . $matches[4];
    651 
    652     $stylesheet = isset( $_GET['stylesheet'] ) ? $_GET['stylesheet'] : '';
    653     $template   = isset( $_GET['template'] )   ? $_GET['template']   : '';
    654 
    655     $link = add_query_arg( array( 'preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'preview_iframe' => 1 ), $matches[3] );
    656     if ( 0 === strpos($link, 'preview=1') )
    657         $link = "?$link";
    658     return $matches[1] . esc_attr( $link ) . $matches[4];
     637    return $matches[0];
    659638}
    660639
Note: See TracChangeset for help on using the changeset viewer.