Changeset 33551
- Timestamp:
- 08/03/2015 09:20:25 PM (11 years ago)
- File:
-
- 1 edited
-
branches/4.0/src/wp-includes/theme.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/4.0/src/wp-includes/theme.php
r29275 r33551 674 674 // Prevent theme mods to current theme being used on theme being previewed 675 675 add_filter( 'pre_option_theme_mods_' . get_option( 'stylesheet' ), '__return_empty_array' ); 676 677 ob_start( 'preview_theme_ob_filter' );678 676 } 679 677 add_action('setup_theme', 'preview_theme'); … … 713 711 */ 714 712 function preview_theme_ob_filter( $content ) { 715 return preg_replace_callback( "|(<a.*?href=([\"']))(.*?)([\"'].*?>)|", 'preview_theme_ob_filter_callback', $content );713 return $content; 716 714 } 717 715 … … 728 726 */ 729 727 function preview_theme_ob_filter_callback( $matches ) { 730 if ( strpos($matches[4], 'onclick') !== false ) 731 $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. 732 if ( 733 ( false !== strpos($matches[3], '/wp-admin/') ) 734 || 735 ( false !== strpos( $matches[3], '://' ) && 0 !== strpos( $matches[3], home_url() ) ) 736 || 737 ( false !== strpos($matches[3], '/feed/') ) 738 || 739 ( false !== strpos($matches[3], '/trackback/') ) 740 ) 741 return $matches[1] . "#$matches[2] onclick=$matches[2]return false;" . $matches[4]; 742 743 $stylesheet = isset( $_GET['stylesheet'] ) ? $_GET['stylesheet'] : ''; 744 $template = isset( $_GET['template'] ) ? $_GET['template'] : ''; 745 746 $link = add_query_arg( array( 'preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'preview_iframe' => 1 ), $matches[3] ); 747 if ( 0 === strpos($link, 'preview=1') ) 748 $link = "?$link"; 749 return $matches[1] . esc_attr( $link ) . $matches[4]; 728 return $matches[0]; 750 729 } 751 730
Note: See TracChangeset
for help on using the changeset viewer.