Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: _wp_post_revision_field_{$field}

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 2 times in this file.

Line Code
62            * fields of the revision object being iterated over in a foreach statement.
63            *
64            * @since 3.6.0
65            *
66            * @param string  $compare_from->$field The current revision field to compare to or from.
67            * @param string  $field                The current revision field.
68            * @param WP_Post $compare_from         The revision post object to compare to or from.
69            * @param string  null                  The context of whether the current revision is the old or the new one. Values are 'to' or 'from'.
70            */
71           $content_from = $compare_from ? apply_filters( "_wp_post_revision_field_$field", $compare_from->$field, $field, $compare_from, 'from' ) : '';
72
73           /** This filter is documented in wp-admin/includes/revision.php */
74           $content_to = apply_filters( "_wp_post_revision_field_$field", $compare_to->$field, $field, $compare_to, 'to' );
75
76           $diff = wp_text_diff( $content_from, $content_to, array( 'show_split_view' => true ) );
77
78           if ( ! $diff && 'post_title' === $field ) {
79                // It's a better user experience to still show the Title, even if it didn't change.
80                // No, you didn't see this.
81                $diff = '<table class="diff"><colgroup><col class="content diffsplit left"><col class="content diffsplit middle"><col class="content diffsplit right"></colgroup><tbody><tr>';
82                $diff .= '<td>' . esc_html( $compare_from->post_title ) . '</td><td></td><td>' . esc_html( $compare_to->post_title ) . '</td>';
83                $diff .= '</tr></tbody>';