Make WordPress Core

Ticket #24908: 24908.4.diff

File 24908.4.diff, 3.4 KB (added by adamsilverstein, 10 years ago)

updates as per suggestions

  • src/wp-admin/includes/revision.php

     
    7373                /** This filter is documented in wp-admin/includes/revision.php */
    7474                $content_to = apply_filters( "_wp_post_revision_field_$field", $compare_to->$field, $field, $compare_to, 'to' );
    7575
    76                 $diff = wp_text_diff( $content_from, $content_to, array( 'show_split_view' => true ) );
     76                $wp_text_diff_options = array( 'show_split_view' => false );
     77                /**
     78                 * Filter revisions text diff options.
     79                 *
     80                 * Filter the options passed to wp_text_diff.
     81                 *
     82                 * @param array $args {
     83                 *                  Associative array of options to pass to wp_text_diff.
     84                 *
     85                 *                  @type bool wp_text_diff_options False for split (two columns), true for
     86                 *                  not split (single column). Default false.
     87                 *              }
     88                 *
     89                 * @since 4.1.0
     90                 *
     91                 */
     92                $wp_text_diff_options = apply_filters( 'wp_text_diff_options', $wp_text_diff_options );
     93                $diff = wp_text_diff( $content_from, $content_to, $wp_text_diff_options );
    7794
    7895                if ( ! $diff && 'post_title' === $field ) {
    7996                        // It's a better user experience to still show the Title, even if it didn't change.
  • src/wp-includes/wp-diff.php

     
    153153        public function _added( $lines, $encode = true ) {
    154154                $r = '';
    155155                foreach ($lines as $line) {
    156                         if ( $encode )
    157                                 $line = htmlspecialchars( $line );
     156                        if ( $encode ) {
     157                                $processed_line = htmlspecialchars( $line );
     158
     159                                /**
     160                                 * Contextually filter a diffed line.
     161                                 *
     162                                 * Filters TextDiff processing of diffed line. By default, diffs are processed with
     163                                 * htmlspecialchars. Use this filter to remove or change the processing. Passes a context
     164                                 * indicating if the line is added, deleted or unchanged.
     165                                 *
     166                                 * @since 4.1.0
     167                                 *
     168                                 * @param String $processed_line The processed diffed line.
     169                                 * @param String $line           The unprocessed diffed line.
     170                                 * @param string null            The line context. Values are 'added', 'deleted' or 'context' (unchanged).
     171                                 */
     172                                $line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'added' );
     173                        }
     174
    158175                        if ( $this->_show_split_view ) {
    159176                                $r .= '<tr>' . $this->emptyLine() . $this->emptyLine() . $this->addedLine( $line ) . "</tr>\n";
    160177                        } else {
     
    176193                $r = '';
    177194                foreach ($lines as $line) {
    178195                        if ( $encode )
    179                                 $line = htmlspecialchars( $line );
     196                                /** This filter is documented in /wp-includes/wp-diff.php */
     197                                $line = apply_filters( 'process_text_diff_html', htmlspecialchars( $line ), $line, 'deleted' );
    180198                        if ( $this->_show_split_view ) {
    181199                                $r .= '<tr>' . $this->deletedLine( $line ) . $this->emptyLine() . $this->emptyLine() . "</tr>\n";
    182200                        } else {
     
    199217                $r = '';
    200218                foreach ($lines as $line) {
    201219                        if ( $encode )
    202                                 $line = htmlspecialchars( $line );
     220                                /** This filter is documented in /wp-includes/wp-diff.php */
     221                                $line = apply_filters( 'process_text_diff_html', htmlspecialchars( $line ), $line, 'context' );
    203222                        if (  $this->_show_split_view ) {
    204223                                $r .= '<tr>' . $this->contextLine( $line ) . $this->emptyLine() . $this->contextLine( $line )  . "</tr>\n";
    205224                        } else {