Filter hook 'wp_save_post_revision_check_for_changes'

in WP Core File wp-includes/revision.php at line 186

View Source

wp_save_post_revision_check_for_changes

Filter Hook
Description
Filters whether the post has changed since the latest revision. 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.

Hook Information

File Location wp-includes/revision.php View on GitHub
Hook Type Filter
Line Number 186

Hook Parameters

Type Name Description
bool $check_for_changes Whether to check for changes before saving a new revision. Default true.
WP_Post $latest_revision The latest revision post object.
WP_Post $post The post object.

Usage Examples

Basic Usage
<?php
// Hook into wp_save_post_revision_check_for_changes
add_filter('wp_save_post_revision_check_for_changes', 'my_custom_filter', 10, 3);

function my_custom_filter($check_for_changes, $latest_revision, $post) {
    // Your custom filtering logic here
    return $check_for_changes;
}

Source Code Context

wp-includes/revision.php:186 - How this hook is used in WordPress core
<?php
 181  		 * @param bool    $check_for_changes Whether to check for changes before saving a new revision.
 182  		 *                                   Default true.
 183  		 * @param WP_Post $latest_revision   The latest revision post object.
 184  		 * @param WP_Post $post              The post object.
 185  		 */
 186  		if ( isset( $latest_revision ) && apply_filters( 'wp_save_post_revision_check_for_changes', true, $latest_revision, $post ) ) {
 187  			$post_has_changed = false;
 188  
 189  			foreach ( array_keys( _wp_post_revision_fields( $post ) ) as $field ) {
 190  				if ( normalize_whitespace( $post->$field ) !== normalize_whitespace( $latest_revision->$field ) ) {
 191  					$post_has_changed = true;

PHP Documentation

<?php
/**
		 * Filters whether the post has changed since the latest revision.
		 *
		 * 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.
		 *
		 * @since 3.6.0
		 *
		 * @param bool    $check_for_changes Whether to check for changes before saving a new revision.
		 *                                   Default true.
		 * @param WP_Post $latest_revision   The latest revision post object.
		 * @param WP_Post $post              The post object.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 3
  • File: wp-includes/revision.php
Related Hooks

Related hooks will be displayed here in future updates.