Changeset 33554
- Timestamp:
- 08/03/2015 09:21:33 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.7/src/wp-includes/theme.php
r25272 r33554 583 583 // Prevent theme mods to current theme being used on theme being previewed 584 584 add_filter( 'pre_option_theme_mods_' . get_option( 'stylesheet' ), '__return_empty_array' ); 585 586 ob_start( 'preview_theme_ob_filter' );587 585 } 588 586 add_action('setup_theme', 'preview_theme'); … … 622 620 */ 623 621 function preview_theme_ob_filter( $content ) { 624 return preg_replace_callback( "|(<a.*?href=([\"']))(.*?)([\"'].*?>)|", 'preview_theme_ob_filter_callback', $content );622 return $content; 625 623 } 626 624 … … 637 635 */ 638 636 function 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]; 659 638 } 660 639
Note: See TracChangeset
for help on using the changeset viewer.