fix(newspack-theme): apply ad background color to Broadstreet ads#167
Open
dkoo wants to merge 1 commit into
Open
fix(newspack-theme): apply ad background color to Broadstreet ads#167dkoo wants to merge 1 commit into
dkoo wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the Newspack Theme ad background color treatment to Broadstreet ads rendered by the standalone Broadstreet plugin.
Changes:
- Adds Broadstreet ad containers to the generated custom ad background color CSS.
- Adds SCSS to center Broadstreet ad content and apply matching padding when custom ad backgrounds are enabled.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
themes/newspack-theme/newspack-theme/inc/color-patterns.php |
Includes broadstreet-zone-container in the custom ad background selector list. |
themes/newspack-theme/newspack-theme/sass/plugins/newspack-ads.scss |
Adds layout and padding styles for Broadstreet containers under .custom-ad-bg. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes NPPM-2829.
The Newspack Theme's Ads Background Color Customizer setting (Appearance → Customize → Colors) applies a chosen background behind ads. It worked for ads rendered with Newspack Ads markup (
.newspack_global_ad,div[class*="newspack-ads-blocks-ad-unit"], etc.) but not for ads embedded via the standalone Broadstreet WordPress plugin, which renders<broadstreet-zone-container>/<broadstreet-zone>custom elements that none of the theme's selectors targeted. Reported by Fort Worth Report.This is a CSS-only change that makes the Broadstreet container inherit the same treatment as Newspack ad units.
Changes
inc/color-patterns.php— addbroadstreet-zone-containerto the ad background-color selector list (already gated onads_color === 'custom').sass/plugins/newspack-ads.scss— add abroadstreet-zone-containerrule inside.custom-ad-bg:display: flex+ centering +8pxpadding, mirroring the Newspack ad-unit treatment. This promotes the inline custom element to a block-level full-width wrapper so the background spans the column and the ad centers.Why target
broadstreet-zone-containerThe Broadstreet plugin's PHP only emits a bare
<broadstreet-zone>; the<broadstreet-zone-container>wrapper is created client-side by Broadstreet's CDN script when it hydrates the zone and injects the ad. That container is the structural parallel to Newspack's outerdiv[class*="newspack-ads-blocks-ad-unit"]wrapper, and targeting it (rather than the bare zone) avoids painting an empty colored box before the ad loads. All styling is gated on the publisher having set a custom ad background, so sites on the default background are untouched.Out of scope
<script>mode and AMP<amp-ad>output (different markup; AMP is legacy).custom_selectorrenaming the zone element.Testing
Verified locally in an isolated environment using markup mimicking Broadstreet's hydrated DOM (injected via a mu-plugin to bypass content sanitization): body receives
custom-ad-bg, the runtimecolor-patterns.phprule emitsbroadstreet-zone-container{background-color: …}, and the compiled stylesheet serves the flex/padding rule.🤖 Generated with Claude Code