~canonical-sysadmins/wordpress/4.4.1

« back to all changes in this revision

Viewing changes to wp-includes/theme.php

  • Committer: Dave Lawson
  • Date: 2015-08-10 14:35:56 UTC
  • Revision ID: dave.lawson@canonical.com-20150810143556-7i5p0omn6ei8jwlg
Merge 4.2.4 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
673
673
 
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
 
680
678
/**
711
709
 * @return string
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
 
717
715
/**
726
724
 * @return string
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
 
751
730
/**