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

fix: set correct post context for author hooks #4011 #4037

Merged
merged 1 commit into from
Aug 2, 2023
Merged
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: 7 additions & 0 deletions inc/views/partials/post_meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ public static function neve_get_author_meta( $post_id = null, $show_before = tru
if ( ! isset( $current_post ) ) {
return false;
}
// we need to set the global post to the current post in order to allow other filters that hook into get_the_author_meta hooks access to the current post.
// we reset this at the end of the function.
$original_global_post = $post;
$post = $current_post; //phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
setup_postdata( $current_post );

$author_id = $current_post->post_author;
$user_nicename = get_the_author_meta( 'user_nicename', $author_id );
Expand Down Expand Up @@ -312,6 +317,8 @@ public static function neve_get_author_meta( $post_id = null, $show_before = tru
*/
$markup = apply_filters( 'neve_filter_author_meta_markup', $markup, $post_id, $show_before );

$post = $original_global_post; //phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
wp_reset_postdata();
return wp_kses_post( $markup );
}

Expand Down
Loading