Introduce some actions and filters which aid plugins in revisioning post meta.

* `wp_save_post_revision_post_has_changed` filter which can be used to determine if a post has been changed, and therefore if a revision should be created for a post.
 * `wp_get_revision_ui_diff` filter which can be used to filter the fields displayed in the post revision diff UI.
 * `wp_creating_autosave` action which is fired just before an autosave is created.

See #20564.
Props mattheu, adamsilverstein.


git-svn-id: https://develop.svn.wordpress.org/trunk@30091 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
John Blackbourn
2014-10-29 19:01:15 +00:00
parent 1767706fc2
commit 32d38fc080
3 changed files with 39 additions and 2 deletions
+18 -1
View File
@@ -133,9 +133,26 @@ function wp_save_post_revision( $post_id ) {
break;
}
}
/**
* Filter 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 $last_revision The the last revision post object.
* @param WP_Post $post The post object.
*
*/
$post_has_changed = (bool) apply_filters( 'wp_save_post_revision_post_has_changed', $post_has_changed, $last_revision, $post );
//don't save revision if post unchanged
if( ! $post_has_changed )
if( ! $post_has_changed ) {
return;
}
}
}