Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hook up metadata filter on the_preview #40

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion wp-post-meta-revisions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down