diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index 4cfad6ed87..486282ac2a 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -1541,6 +1541,15 @@ function wp_create_post_autosave( $post_data ) { return 0; } + /** + * Fires before an autosave is stored. + * + * @since 4.1.0 + * + * @param array $new_autosave Post array - the autosave that is about to be saved. + */ + do_action( 'wp_creating_autosave', $new_autosave ); + return wp_update_post( $new_autosave ); } diff --git a/wp-admin/includes/revision.php b/wp-admin/includes/revision.php index 151cd64454..4e20f2d608 100644 --- a/wp-admin/includes/revision.php +++ b/wp-admin/includes/revision.php @@ -92,7 +92,18 @@ function wp_get_revision_ui_diff( $post, $compare_from, $compare_to ) { ); } } - return $return; + + /** + * Filter the fields displayed in the post revision diff UI. + * + * @since 4.1.0 + * + * @param array $return Revision UI fields. Each item is an array of id, name and diff. + * @param WP_Post $compare_from The revision post to compare from. + * @param WP_Post $compare_to The revision post to compare to. + */ + return apply_filters( 'wp_get_revision_ui_diff', $return, $compare_from, $compare_to ); + } /** diff --git a/wp-includes/revision.php b/wp-includes/revision.php index 45e436f567..68ad112683 100644 --- a/wp-includes/revision.php +++ b/wp-includes/revision.php @@ -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; + } } } diff --git a/wp-includes/version.php b/wp-includes/version.php index 0478c1bcdb..db0a3126cf 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.1-alpha-30090'; +$wp_version = '4.1-alpha-30091'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.