Skip to content

Commit

Permalink
fix: add checks for Newspack plugin (#1579)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurelfulford authored Nov 4, 2023
1 parent dff89a0 commit b516a6f
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions src/templates/author-profile-card.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,20 @@ function( $data ) {
if ( $attributes['showEmail'] && ! empty( $author['email'] ) ) {
$social_links['email'] = $author['email'];
}
if ( $attributes['shownewspack_phone_number'] && ! empty( $author['newspack_phone_number'] ) ) {
$social_links['newspack_phone_number'] = $author['newspack_phone_number'];
if ( class_exists( '\Newspack\Authors_Custom_Fields' ) ) {
if ( $attributes['shownewspack_phone_number'] && ! empty( $author['newspack_phone_number'] ) ) {
$social_links['newspack_phone_number'] = $author['newspack_phone_number'];
}
}

$employment_values = [];
if ( $attributes['shownewspack_role'] && ! empty( $author['newspack_role'] ) ) {
$employment_values[] = $author['newspack_role'];
}
if ( $attributes['shownewspack_employer'] && ! empty( $author['newspack_employer'] ) ) {
$employment_values[] = $author['newspack_employer'];
if ( class_exists( '\Newspack\Authors_Custom_Fields' ) ) {
if ( $attributes['shownewspack_role'] && ! empty( $author['newspack_role'] ) ) {
$employment_values[] = $author['newspack_role'];
}
if ( $attributes['shownewspack_employer'] && ! empty( $author['newspack_employer'] ) ) {
$employment_values[] = $author['newspack_employer'];
}
}
$employment = implode( ', ', $employment_values );

Expand Down Expand Up @@ -81,11 +85,17 @@ function( $data ) {
<?php endif; ?>
</h3>

<?php if ( $attributes['shownewspack_job_title'] && ! empty( $author['newspack_job_title'] ) ) : ?>
<p class="wp-block-newspack-blocks-author-profile__job-title">
<?php echo esc_html( $author['newspack_job_title'] ); ?>
</p>
<?php endif; ?>
<?php
if ( class_exists( '\Newspack\Authors_Custom_Fields' ) ) :
if ( $attributes['shownewspack_job_title'] && ! empty( $author['newspack_job_title'] ) ) :
?>
<p class="wp-block-newspack-blocks-author-profile__job-title">
<?php echo esc_html( $author['newspack_job_title'] ); ?>
</p>
<?php
endif;
endif;
?>
<?php if ( ! empty( $employment ) ) : ?>
<p class="wp-block-newspack-blocks-author-profile__employment">
<?php echo esc_html( $employment ); ?>
Expand Down

0 comments on commit b516a6f

Please sign in to comment.