Skip to content

Commit

Permalink
fix: display underwriters with default placement value (#2061)
Browse files Browse the repository at this point in the history
* fix: display underwriters with default placement value

* fix: allow either "top" or "inherit" values for top placement
  • Loading branch information
dkoo authored Mar 17, 2023
1 parent 98c2f3b commit 265c049
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions newspack-theme/inc/newspack-sponsors.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function newspack_get_native_sponsors( $sponsors = [] ) {
}

// Scope override: if post is set to display as underwritten, return nothing.
if ( 'underwritten' === $scope_override ) {
if ( 'underwritten' === $scope_override ) {
return [];
}

Expand Down Expand Up @@ -106,7 +106,7 @@ function newspack_get_underwriter_sponsors( $sponsors = [] ) {
}

// Scope override: if post is set to display as underwritten, return all sponsors.
if ( 'underwritten' === $scope_override ) {
if ( 'underwritten' === $scope_override ) {
return $sponsors;
}

Expand Down Expand Up @@ -221,7 +221,7 @@ function newspack_sponsor_byline( $sponsors = null, $id = null, $scope = 'native
}
?>
</span><!-- .byline -->
<?php
<?php
}
}
endif;
Expand Down Expand Up @@ -276,7 +276,7 @@ function newspack_sponsor_label( $sponsors = null, $id = null, $show_info = fals
</span>
<?php endif; ?>
</span><!-- .sponsor-label -->
<?php
<?php
endif;
}
endif;
Expand All @@ -297,19 +297,19 @@ function newspack_sponsor_logo_list( $sponsors = null, $id = null, $scope = 'nat

if ( ! empty( $sponsors ) ) {
echo '<span class="sponsor-logos">';
foreach ( $sponsors as $sponsor ) {
if ( ! empty( $sponsor['sponsor_logo'] ) ) :
if ( '' !== $sponsor['sponsor_url'] ) {
echo '<a href="' . esc_url( $sponsor['sponsor_url'] ) . '" target="_blank">';
}
?>
foreach ( $sponsors as $sponsor ) {
if ( ! empty( $sponsor['sponsor_logo'] ) ) :
if ( '' !== $sponsor['sponsor_url'] ) {
echo '<a href="' . esc_url( $sponsor['sponsor_url'] ) . '" target="_blank">';
}
?>
<img src="<?php echo esc_url( $sponsor['sponsor_logo']['src'] ); ?>" width="<?php echo esc_attr( $sponsor['sponsor_logo']['img_width'] ); ?>" height="<?php echo esc_attr( $sponsor['sponsor_logo']['img_height'] ); ?>">
<?php if ( '' !== $sponsor['sponsor_url'] ) : ?>
</a>
<?php endif; ?>
<?php
endif;
}
}
echo '</span>';
}
}
Expand Down Expand Up @@ -337,7 +337,7 @@ function( $content ) use ( $sponsors ) {
ob_start();
if ( ! empty( $sponsors ) ) {
foreach ( $sponsors as $sponsor ) {
?>
?>

<div class="author-bio sponsor-bio">

Expand Down Expand Up @@ -387,7 +387,7 @@ function( $content ) use ( $sponsors ) {

</div><!-- .author-bio-text -->
</div><!-- .author-bio -->
<?php
<?php
}
}

Expand Down Expand Up @@ -447,7 +447,7 @@ function newspack_sponsor_archive_description( $sponsors = null, $id = null, $sc
<?php echo wp_kses_post( $sponsor['sponsor_blurb'] ); ?>
</div><!-- .info -->
</div><!-- .sponsor-archive -->
<?php
<?php
}
}
}
Expand All @@ -471,7 +471,7 @@ function newspack_sponsored_underwriters_info( $sponsors = null, $id = null, $sc
add_filter(
'the_content',
function( $content ) use ( $sponsors, $override_style, $override_placement ) {
$underwriters_top = array_filter(
$underwriters_top = array_filter(
$sponsors,
function( $sponsor ) use ( $override_placement ) {
if ( 'top' === $override_placement ) {
Expand All @@ -481,7 +481,7 @@ function( $sponsor ) use ( $override_placement ) {
return false;
}

return isset( $sponsor['sponsor_underwriter_placement'] ) ? 'top' === $sponsor['sponsor_underwriter_placement'] : true;
return isset( $sponsor['sponsor_underwriter_placement'] ) ? 'top' === $sponsor['sponsor_underwriter_placement'] || 'inherit' === $sponsor['sponsor_underwriter_placement'] : true;
}
);
$underwriters_bottom = array_filter(
Expand Down Expand Up @@ -518,7 +518,8 @@ function newspack_sponsors_get_underwriter_content( $sponsor, $style = 'standard
if (
( 'simple' === $style ) ||
( 'standard' !== $style && isset( $sponsor['sponsor_underwriter_style'] ) && 'simple' === $sponsor['sponsor_underwriter_style'] )
) : ?>
) :
?>
<div class="sponsor-uw-info__simple">
<?php if ( ! empty( $sponsor['sponsor_url'] ) ) : ?>
<a href="<?php echo esc_url( $sponsor['sponsor_url'] ); ?>" target="_blank">
Expand Down Expand Up @@ -547,7 +548,8 @@ function newspack_sponsors_get_underwriter_content( $sponsor, $style = 'standard
<?php echo wp_kses_post( $sponsor['sponsor_blurb'] ); ?>
</div>
</div>
<?php endif;
<?php
endif;

return ob_get_clean();
}
Expand Down

0 comments on commit 265c049

Please sign in to comment.