wp_post_revision_field_<field>

Contextually filter a post revision field.

Description

apply_filters( 'wp_post_revision_field_<field>', (string) $compare_from_field, (string) $field, (WP_Post) $compare_from, (string) $from ); 

The dynamic portion(s) of the hook name refer corresponds to each of the post fields of the revision object being iterated over in a foreach statement.

Parameters (4)

0. $compare_from_field (string)
The current revision field to compare to or from.
1. $field (string)
The current revision field.
2. $compare_from (WP_Post)
The revision post object to compare to or from.
3. $from (string) => 'from'
Null The context of whether the current revision is the old or the new one. Values are to or from..

Usage

To run the hook, copy the example below.
  1. $compare_from_field = apply_filters( 'wp_post_revision_field_{$field}', $compare_from_field, $field, $compare_from, $from ); 
  2.  
  3. if ( !empty( $compare_from_field ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the wp_post_revision_field_<field> callback 
  2. function filter_wp_post_revision_field_field( $compare_from_field, $field, $compare_from, $from ) { 
  3. // make filter magic happen here... 
  4. return $compare_from_field
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( "wp_post_revision_field_{$field}", 'filter_wp_post_revision_field_field', 10, 4 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( "wp_post_revision_field_{$field}", 'filter_wp_post_revision_field_field', 10, 4 ); 

Defined (2)

The filter is defined in the following location(s).

/wp-admin/includes/revision.php  
  1. $content_from = $compare_from ? apply_filters( "_wp_post_revision_field_{$field}", $compare_from->$field, $field, $compare_from, 'from' ) : ''; 
  1. $content_to = apply_filters( "_wp_post_revision_field_{$field}", $compare_to->$field, $field, $compare_to, 'to' );