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.
- $check_for_changes = apply_filters( 'wp_save_post_revision_check_for_changes', $check_for_changes, $last_revision, $post );
- if ( !empty( $check_for_changes ) ) {
- // everything has led up to this point...
- }
- The following example is for adding a hook callback.
- // define the wp_save_post_revision_check_for_changes callback
- function filter_wp_save_post_revision_check_for_changes( $check_for_changes, $last_revision, $post ) {
- // make filter magic happen here...
- return $check_for_changes;
- };
- // add the filter
- 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.
- // remove the filter
- 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
- if ( isset( $last_revision ) && apply_filters( 'wp_save_post_revision_check_for_changes', $check_for_changes = true, $last_revision, $post ) ) {