diff --git a/wp-admin/includes/revision.php b/wp-admin/includes/revision.php index bf0279651c..164129d10f 100644 --- a/wp-admin/includes/revision.php +++ b/wp-admin/includes/revision.php @@ -73,7 +73,28 @@ function wp_get_revision_ui_diff( $post, $compare_from, $compare_to ) { /** This filter is documented in wp-admin/includes/revision.php */ $content_to = apply_filters( "_wp_post_revision_field_$field", $compare_to->$field, $field, $compare_to, 'to' ); - $diff = wp_text_diff( $content_from, $content_to, array( 'show_split_view' => true ) ); + $args = array( + 'show_split_view' => false + ); + /** + * Filter revisions text diff options. + * + * Filter the options passed to `wp_text_diff()` when viewing a post revision. + * + * @since 4.1.0 + * + * @param array $args { + * Associative array of options to pass to `wp_text_diff()`. + * + * @type bool $show_split_view False for split view (two columns), true for + * un-split view (single column). Default false. + * } + * @param string $field The current revision field. + * @param WP_Post $compare_from The revision post to compare from. + * @param WP_Post $compare_to The revision post to compare to. + */ + $args = apply_filters( 'revision_text_diff_options', $args, $field, $compare_from, $compare_to ); + $diff = wp_text_diff( $content_from, $content_to, $args ); if ( ! $diff && 'post_title' === $field ) { // It's a better user experience to still show the Title, even if it didn't change. diff --git a/wp-includes/wp-diff.php b/wp-includes/wp-diff.php index 97e7eb9bb5..9b1b5e093a 100644 --- a/wp-includes/wp-diff.php +++ b/wp-includes/wp-diff.php @@ -153,8 +153,25 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer { public function _added( $lines, $encode = true ) { $r = ''; foreach ($lines as $line) { - if ( $encode ) - $line = htmlspecialchars( $line ); + if ( $encode ) { + $processed_line = htmlspecialchars( $line ); + + /** + * Contextually filter a diffed line. + * + * Filters TextDiff processing of diffed line. By default, diffs are processed with + * htmlspecialchars. Use this filter to remove or change the processing. Passes a context + * indicating if the line is added, deleted or unchanged. + * + * @since 4.1.0 + * + * @param String $processed_line The processed diffed line. + * @param String $line The unprocessed diffed line. + * @param string null The line context. Values are 'added', 'deleted' or 'unchanged'. + */ + $line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'added' ); + } + if ( $this->_show_split_view ) { $r .= '