Changeset 33553
- Timestamp:
- 08/03/2015 09:21:20 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.8/src/wp-includes/theme.php
r26594 r33553 666 666 // Prevent theme mods to current theme being used on theme being previewed 667 667 add_filter( 'pre_option_theme_mods_' . get_option( 'stylesheet' ), '__return_empty_array' ); 668 669 ob_start( 'preview_theme_ob_filter' );670 668 } 671 669 add_action('setup_theme', 'preview_theme'); … … 705 703 */ 706 704 function preview_theme_ob_filter( $content ) { 707 return preg_replace_callback( "|(<a.*?href=([\"']))(.*?)([\"'].*?>)|", 'preview_theme_ob_filter_callback', $content );705 return $content; 708 706 } 709 707 … … 720 718 */ 721 719 function preview_theme_ob_filter_callback( $matches ) { 722 if ( strpos($matches[4], 'onclick') !== false ) 723 $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. 724 if ( 725 ( false !== strpos($matches[3], '/wp-admin/') ) 726 || 727 ( false !== strpos( $matches[3], '://' ) && 0 !== strpos( $matches[3], home_url() ) ) 728 || 729 ( false !== strpos($matches[3], '/feed/') ) 730 || 731 ( false !== strpos($matches[3], '/trackback/') ) 732 ) 733 return $matches[1] . "#$matches[2] onclick=$matches[2]return false;" . $matches[4]; 734 735 $stylesheet = isset( $_GET['stylesheet'] ) ? $_GET['stylesheet'] : ''; 736 $template = isset( $_GET['template'] ) ? $_GET['template'] : ''; 737 738 $link = add_query_arg( array( 'preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'preview_iframe' => 1 ), $matches[3] ); 739 if ( 0 === strpos($link, 'preview=1') ) 740 $link = "?$link"; 741 return $matches[1] . esc_attr( $link ) . $matches[4]; 720 return $matches[0]; 742 721 } 743 722
Note: See TracChangeset
for help on using the changeset viewer.