wp_save_post_revision_post_has_changed
Filter HookDescription
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.Hook Information
File Location |
wp-includes/revision.php
View on GitHub
|
Hook Type | Filter |
Line Number | 208 |
Hook Parameters
Type | Name | Description |
---|---|---|
bool
|
$post_has_changed
|
Whether the post has changed. |
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_post_has_changed
add_filter('wp_save_post_revision_post_has_changed', 'my_custom_filter', 10, 3);
function my_custom_filter($post_has_changed, $latest_revision, $post) {
// Your custom filtering logic here
return $post_has_changed;
}
Source Code Context
wp-includes/revision.php:208
- How this hook is used in WordPress core
<?php
203 *
204 * @param bool $post_has_changed Whether the post has changed.
205 * @param WP_Post $latest_revision The latest revision post object.
206 * @param WP_Post $post The post object.
207 */
208 $post_has_changed = (bool) apply_filters( 'wp_save_post_revision_post_has_changed', $post_has_changed, $latest_revision, $post );
209
210 // Don't save revision if post unchanged.
211 if ( ! $post_has_changed ) {
212 return;
213 }
PHP Documentation
<?php
/**
* 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.
*
* @since 4.1.0
*
* @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.
*/
Quick Info
- Hook Type: Filter
- Parameters: 3
- File: wp-includes/revision.php
Related Hooks
Related hooks will be displayed here in future updates.