Index: wp-includes/wp-diff.php
===================================================================
--- wp-includes/wp-diff.php (revision 24177)
+++ wp-includes/wp-diff.php (working copy)
@@ -154,7 +154,7 @@
$r = '';
foreach ($lines as $line) {
if ( $encode )
- $line = wp_kses_post( $line );
+ $line = $this->prepare_line( $line );
if ( $this->_show_split_view ) {
$r .= '
' . $this->emptyLine() . $this->emptyLine() . $this->addedLine( $line ) . "
\n";
} else {
@@ -176,7 +176,7 @@
$r = '';
foreach ($lines as $line) {
if ( $encode )
- $line = wp_kses_post( $line );
+ $line = $this->prepare_line( $line );
if ( $this->_show_split_view ) {
$r .= '' . $this->deletedLine( $line ) . $this->emptyLine() . $this->emptyLine() . "
\n";
} else {
@@ -199,7 +199,7 @@
$r = '';
foreach ($lines as $line) {
if ( $encode )
- $line = wp_kses_post( $line );
+ $line = $this->prepare_line( $line );
if ( $this->_show_split_view ) {
$r .= '' . $this->contextLine( $line ) . $this->emptyLine() . $this->contextLine( $line ) . "
\n";
} else {
@@ -210,6 +210,19 @@
}
/**
+ * Prepares lines for printing. Applies shortcodes and wp_kses_post.
+ *
+ * @since 3.6.0
+ * @see do_shortcode() in wp-includes/shortcodes.php
+ * @see get_shortcode_regex() in wp-includes/shortcodes.php
+ */
+ private function prepare_line( $line ) {
+ $tags = join( '|', array( 'gallery', 'wp_caption', 'caption' ) );
+ $shortcodes_regex = "\\[(\\[?)($tags)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)";
+ return preg_replace_callback( "/{$shortcodes_regex}/s", 'do_shortcode_tag', wp_kses_post( $line ) );
+ }
+
+ /**
* Process changed lines to do word-by-word diffs for extra highlighting.
*
* (TRAC style) sometimes these lines can actually be deleted or added rows.