wp_save_post_revision_check_for_changes

Filters whether the post has changed since the last revision.

Description

apply_filters( 'wp_save_post_revision_check_for_changes', (bool) $check_for_changes, (WP_Post) $last_revision, (WP_Post) $post ); 

By default a revision is saved only if one of the revisioned fields has changed. This filter can override that so a revision is saved even if nothing has changed.

Parameters (3)

0. $check_for_changes — Optional. (bool) => true
Whether to check for changes before saving a new revision. Default true.
1. $last_revision (WP_Post)
The last revision post object.
2. $post (WP_Post)
The post object.

Usage

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

Defined (1)

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

/wp-includes/revision.php  
  1. if ( isset( $last_revision ) && apply_filters( 'wp_save_post_revision_check_for_changes', $check_for_changes = true, $last_revision, $post ) ) {