wp-post-meta-revisions icon indicating copy to clipboard operation
wp-post-meta-revisions copied to clipboard

Hook up metadata filter on the_preview

Open mboynes opened this issue 6 years ago • 7 comments

Resolves #30. Needs testing.

mboynes avatar Mar 16 '18 22:03 mboynes

Hi @mboynes - thanks for the PR and apologies for the long delay reviewing. I am finally getting to responding now. Do you have a description of steps to reproduce/how you tested this?

adamsilverstein avatar Mar 15 '19 14:03 adamsilverstein

related: https://github.com/adamsilverstein/wp-post-meta-revisions/pull/37

adamsilverstein avatar Mar 15 '19 14:03 adamsilverstein

Hey @adamsilverstein, no worries on the delay! Thanks for looking it over.

At the time, I tested it by making meta changes to an article, previewing that article, and confirming that my changes had been made. I haven't tried it since, so especially with the introduction of Gutenberg, I can't say for certain that this still works. Though I'd be surprised if it didn't.

I hadn't noticed #37 at the time, this accomplishes the same task. I would offer that, assuming it still works, this PR may be moderately more performant, since it's not checking is_preview() on every meta call.

Let me know if I can be of any further help!

mboynes avatar Mar 15 '19 15:03 mboynes

this PR may be moderately more performant, since it's not checking is_preview() on every meta call.

Good point, this is a better approach. Going to do some testing in 4.9/classic and 5.2/GB to verify functionality.

Thanks again for the PR @mboynes!

adamsilverstein avatar Mar 25 '19 14:03 adamsilverstein

Awesome PR @mboynes!

I borrowed some of this preview code for a project and it works great with one little change for me. This might have just been my environment, but the following condition was not evaluating to true for me:

https://github.com/adamsilverstein/wp-post-meta-revisions/blob/77696a15c6cfea13d94cf824cd5cf950e8d2a990/wp-post-meta-revisions.php#L204

Instead, the post_type value was 'page'. This might have been because the get_post() call on line 199 might be using the post ID being viewed, rather than using the ID from the get_post_meta() call.

So I think we might want to change:

https://github.com/adamsilverstein/wp-post-meta-revisions/blob/77696a15c6cfea13d94cf824cd5cf950e8d2a990/wp-post-meta-revisions.php#L199

to:

$post = get_post( $object_id );

so it queries the revision post rather than the parent post?

That seemed to solve the issue for me, and this PR worked wonders. Let me know if you want me to make a PR into your existing PR! 😄

toddmilliken avatar Nov 12 '19 20:11 toddmilliken

@toddmilliken that improvement sounds helpful, I hope to get back to working on this again soon :)

adamsilverstein avatar Dec 13 '19 16:12 adamsilverstein

@grappler thanks for confirming, still on my radar to test this.

adamsilverstein avatar Oct 03 '21 22:10 adamsilverstein