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: display underwriters with default placement value #2061

Merged
merged 2 commits into from
Mar 17, 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
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