Make WordPress Core

Ticket #24908: 24908.3.diff

File 24908.3.diff, 3.0 KB (added by adamsilverstein, 12 years ago)

add hook docs, adjusted filter name

  • 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                /**
     77                 * Filter revisions table structure.
     78                 *
     79                 * Specify revision comparison table as default split (two columns) or not split (single column).
     80                 *
     81                 * @since 3.8.0
     82                 * @param boolean null Whether to display revisions in a split view.
     83                 */
     84                $show_split_view = apply_filters( 'show_revisions_split_view', true );
     85                $diff = wp_text_diff( $content_from, $content_to, array( 'show_split_view' => $show_split_view ) );
    7786
    7887                if ( ! $diff && 'post_title' === $field ) {
    7988                        // It's a better user experience to still show the Title, even if it didn't change.
  • wp-includes/wp-diff.php

     
    154154                $r = '';
    155155                foreach ($lines as $line) {
    156156                        if ( $encode )
    157                                 $line = htmlspecialchars( $line );
     157
     158                                /**
     159                                 * Contextually filter a diffed line.
     160                                 *
     161                                 * Filters TextDiff default application of htmlspecialchars to the returned html for
     162                                 * all diff calculations. This filter is passed the unfiltered html and the context:
     163                                 * 'added', 'deleted' or 'context' (unchanged).
     164                                 *
     165                                 * @since 3.8.0
     166                                 * @param String $line The unfiltered diffed line.
     167                                 * @param string null  The lines context. Values are 'added', 'deleted' or 'context' (unchanged).
     168                                 */
     169                                $line = apply_filters( 'process_text_diff_html', htmlspecialchars( $line ), $line, 'added' );
    158170                        if ( $this->_show_split_view ) {
    159171                                $r .= '<tr>' . $this->emptyLine() . $this->emptyLine() . $this->addedLine( $line ) . "</tr>\n";
    160172                        } else {
     
    176188                $r = '';
    177189                foreach ($lines as $line) {
    178190                        if ( $encode )
    179                                 $line = htmlspecialchars( $line );
     191                                /** This filter is documented in /wp-includes/wp-diff.php */
     192                                $line = apply_filters( 'process_text_diff_html', htmlspecialchars( $line ), $line, 'deleted' );
    180193                        if ( $this->_show_split_view ) {
    181194                                $r .= '<tr>' . $this->deletedLine( $line ) . $this->emptyLine() . $this->emptyLine() . "</tr>\n";
    182195                        } else {
     
    199212                $r = '';
    200213                foreach ($lines as $line) {
    201214                        if ( $encode )
    202                                 $line = htmlspecialchars( $line );
     215                                /** This filter is documented in /wp-includes/wp-diff.php */
     216                                $line = apply_filters( 'process_text_diff_html', htmlspecialchars( $line ), $line, 'context' );
    203217                        if (  $this->_show_split_view ) {
    204218                                $r .= '<tr>' . $this->contextLine( $line ) . $this->emptyLine() . $this->contextLine( $line )  . "</tr>\n";
    205219                        } else {