From 4cedf9bdc038133cc225a3236147bdf37eff6a5b Mon Sep 17 00:00:00 2001 From: Adam Borowski Date: Tue, 1 Nov 2022 12:10:24 +0100 Subject: [PATCH] fix: usage of filter for post author footer bio name The filter was added in #1806, then its use was partially removed in #1848. This change introduces a different approach to the issue (partially) solved in #1848, and re-enables the newspack_author_bio_name filter. --- .../template-parts/post/author-bio.php | 16 +++++----- newspack-theme/inc/trust-indicators.php | 19 +++++++++-- .../template-parts/post/author-bio.php | 32 +++++-------------- 3 files changed, 33 insertions(+), 34 deletions(-) diff --git a/newspack-sacha/template-parts/post/author-bio.php b/newspack-sacha/template-parts/post/author-bio.php index 85a38840a..5e3150a50 100644 --- a/newspack-sacha/template-parts/post/author-bio.php +++ b/newspack-sacha/template-parts/post/author-bio.php @@ -41,7 +41,7 @@

- display_name ), array( 'span' => array( 'class' => array() ) ) ); ?> + display_name, $author->ID ), array( 'span' => array( 'class' => array() ) ) ); ?>

user_email ) : ?> @@ -81,12 +81,12 @@
- + ?>
@@ -94,15 +94,15 @@

- array( 'class' => array() ) ) ); ?> + array( 'class' => array() ) ) ); ?>

diff --git a/newspack-theme/inc/trust-indicators.php b/newspack-theme/inc/trust-indicators.php index 9c663ed42..7033ea855 100644 --- a/newspack-theme/inc/trust-indicators.php +++ b/newspack-theme/inc/trust-indicators.php @@ -83,7 +83,7 @@ function newspack_trust_indicators_output_author_info() { } } - $author_phone = get_user_meta( $author->ID, 'public_contact_info_tel', true ); + $author_phone = get_user_meta( $author->ID, 'public_contact_info_tel', true ); $author_twitter = get_user_meta( $author->ID, 'twitter', true ); ?>
@@ -129,6 +129,21 @@ function newspack_trust_indicators_output_author_job_title( $title ) { } add_filter( 'get_the_archive_title', 'newspack_trust_indicators_output_author_job_title' ); +/** + * Adds author role to author footer. + * + * @param string $author_name string The author name. + * @param int $author_id string The author ID. + */ +function newspack_trust_indicators_author_bio_name( $author_name, $author_id ) { + $role = get_user_meta( $author_id, 'title', true ); + if ( $role ) { + $author_name .= '' . $role . ''; + } + return $author_name; +} +add_filter( 'newspack_author_bio_name', 'newspack_trust_indicators_author_bio_name', 10, 2 ); + /** * Gets author role to add to single post author bios. */ @@ -150,7 +165,7 @@ function newspack_trust_indicators_output_author_details() { $author = get_queried_object(); $all_settings_fields = Trust_Indicators_User_Settings::get_fields(); - $fields = [ + $fields = [ 'location', 'languages_spoken', 'areas_of_expertise', diff --git a/newspack-theme/template-parts/post/author-bio.php b/newspack-theme/template-parts/post/author-bio.php index 56d0beb8c..ee7aa1d6b 100755 --- a/newspack-theme/template-parts/post/author-bio.php +++ b/newspack-theme/template-parts/post/author-bio.php @@ -45,15 +45,7 @@

- display_name ); - if ( class_exists( 'Trust_Indicators' ) ) { - $author_role = newspack_trust_indicators_job_title_single( $author->ID ); - if ( '' !== $author_role ) { - echo '' . esc_html( $author_role ) . ''; - } - } - ?> + display_name, $author->ID ), array( 'span' => array( 'class' => array() ) ) ); ?>

user_email ) || true === get_theme_mod( 'show_author_social', false ) ) : ?> @@ -95,21 +87,21 @@
- + ?>
@@ -117,15 +109,7 @@

- ' . esc_html( $author_role ) . ''; - } - } - ?> + array( 'class' => array() ) ) ); ?>