Changeset 33549 for branches/4.2/src/wp-includes/theme.php
- Timestamp:
- 08/03/2015 09:19:19 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.2/src/wp-includes/theme.php
r32048 r33549 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 … … 712 710 */ 713 711 function preview_theme_ob_filter( $content ) { 714 return preg_replace_callback( "|(<a.*?href=([\"']))(.*?)([\"'].*?>)|", 'preview_theme_ob_filter_callback', $content );712 return $content; 715 713 } 716 714 … … 727 725 */ 728 726 function 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]; 749 728 } 750 729
Note: See TracChangeset
for help on using the changeset viewer.