wp_save_post_revision_post_has_changed filter-hookWP 4.1.0

Filters whether a post has changed.

By default a revision is saved only if one of the revisioned fields has changed. This filter allows for additional checks to determine if there were changes.

Usage

add_filter( 'wp_save_post_revision_post_has_changed', 'wp_kama_save_post_revision_has_changed_filter', 10, 3 );

/**
 * Function for `wp_save_post_revision_post_has_changed` filter-hook.
 * 
 * @param bool    $post_has_changed Whether the post has changed.
 * @param WP_Post $latest_revision  The latest revision post object.
 * @param WP_Post $post             The post object.
 *
 * @return bool
 */
function wp_kama_save_post_revision_has_changed_filter( $post_has_changed, $latest_revision, $post ){

	// filter...
	return $post_has_changed;
}
$post_has_changed(true|false)
Whether the post has changed.
$latest_revision(WP_Post)
The latest revision post object.
$post(WP_Post)
The post object.

Changelog

Since 4.1.0 Introduced.

Where the hook is called

wp_save_post_revision()
wp_save_post_revision_post_has_changed
wp-includes/revision.php 208
$post_has_changed = (bool) apply_filters( 'wp_save_post_revision_post_has_changed', $post_has_changed, $latest_revision, $post );

Where the hook is used in WordPress

wp-includes/class-wp-customize-manager.php 2952
add_filter( 'wp_save_post_revision_post_has_changed', array( $this, '_filter_revision_post_has_changed' ), 5, 3 );
wp-includes/class-wp-customize-manager.php 2994
remove_filter( 'wp_save_post_revision_post_has_changed', array( $this, '_filter_revision_post_has_changed' ) );
wp-includes/default-filters.php 739
add_filter( 'wp_save_post_revision_post_has_changed', 'wp_check_revisioned_meta_fields_have_changed', 10, 3 );