From 4aae56a0adc2e83485e118ef2547132a16ae64f6 Mon Sep 17 00:00:00 2001 From: Matthew Boynes Date: Fri, 16 Mar 2018 18:55:02 -0400 Subject: [PATCH 1/2] Hook up metadata filter on the_preview --- wp-post-meta-revisions.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wp-post-meta-revisions.php b/wp-post-meta-revisions.php index 2170cf7..5e00137 100644 --- a/wp-post-meta-revisions.php +++ b/wp-post-meta-revisions.php @@ -32,15 +32,20 @@ public function __construct() { // When revisioned post meta has changed, trigger a revision save. add_filter( 'wp_save_post_revision_post_has_changed', array( $this, '_wp_check_revisioned_meta_fields_have_changed' ), 10, 3 ); + // When `the_preview` is run, automatically add the metadata filter. + add_filter( 'the_preview', array( $this, '_add_metadata_preview_filter' ); } /** * Add the revisioned meta to get_post_metadata for preview meta data. * * @since 4.5.0 + * @param \WP_Post $post Post object. + * @return \WP_Post */ - public function _add_metadata_preview_filter() { + public function _add_metadata_preview_filter( $post ) { add_filter( 'get_post_metadata', array( $this, '_wp_preview_meta_filter' ), 10, 4 ); + return $post; } /** From 77696a15c6cfea13d94cf824cd5cf950e8d2a990 Mon Sep 17 00:00:00 2001 From: Matthew Boynes Date: Fri, 16 Mar 2018 21:09:23 -0400 Subject: [PATCH 2/2] Syntax error --- wp-post-meta-revisions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wp-post-meta-revisions.php b/wp-post-meta-revisions.php index 5e00137..f27c8db 100644 --- a/wp-post-meta-revisions.php +++ b/wp-post-meta-revisions.php @@ -33,7 +33,7 @@ public function __construct() { add_filter( 'wp_save_post_revision_post_has_changed', array( $this, '_wp_check_revisioned_meta_fields_have_changed' ), 10, 3 ); // When `the_preview` is run, automatically add the metadata filter. - add_filter( 'the_preview', array( $this, '_add_metadata_preview_filter' ); + add_filter( 'the_preview', array( $this, '_add_metadata_preview_filter' ) ); } /**