Premium Analytics: show the Ads tab on WordPress.com only while WordAds is on - #52903
Conversation
…ds is on Rebased onto the registrant #52635 moved into jetpack-mu-wpcom: the plan feature alone still decided there, so every Premium-and-up Simple or Atomic site saw an Ads tab whether or not WordAds was ever turned on. The gate now also requires WordAds to be on, read as classic Stats reads it: the approval stickers on Simple, the WordAds module on Atomic. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Wpcomsh plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Code Coverage SummaryCoverage changed in 1 file.
|
Nikschavan
left a comment
There was a problem hiding this comment.
Thank you, the changes look good.
The docs still describe the old gate. dashboard-sections.md#L200 says jetpack-mu-wpcom registers Ads "when the plan includes WordAds", and line 202 gives the module being routinely off on Atomic as the reason to ignore it, which this PR reverses. The same "by plan feature" wording is in dashboard-widgets.md#L234, packages/ads/README.md#L5 and the two comments in class-wordads-premium-analytics.php. Updating them here would keep the docs in step with the new gate.
| && (bool) has_any_blog_stickers( array( 'wordads-approved', 'wordads-approved-misfits' ), get_current_blog_id() ); | ||
| } | ||
|
|
||
| // Atomic runs the Jetpack plugin, where Odyssey Stats reads the WordAds module. Not |
There was a problem hiding this comment.
Reading the module here is the right rule, but the reason in this comment does not hold: Odyssey only seeds options.wordads from the module in Odyssey_Config_Data, and the jetpack/v4/site request on load replaces it with the shadow site's has_wordads(), which reads the approval stickers. On a site with the sticker and the module off, Odyssey shows the Ads tab and this PR hides it. Hiding it seems correct to me, since a site with the module off is not running ads, so it may be worth wording the comment (and the description) as that rule rather than as matching Odyssey.
There was a problem hiding this comment.
Good catch, thank you. Reworded in 97cdd38: the comment now states the rule, a site with the WordAds module off is not running ads whatever its approval sticker says, rather than claiming to match Odyssey. The PR description says the same.
|
Tested on Simple (sandbox, with Atomic still runs Premium Analytics from Jetpack 16.2, whose preview exposes Traffic only, so the Ads tab can't appear there until 16.3 regardless of this gate. |
The docs, the sections diagram, the Ads package's README and docblock and the module registrant's comments still described the plan-only gate. The Atomic comment also claimed to match Odyssey, which reads the approval stickers through the site endpoint; the rule is that a site with the module off is not running ads. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Thanks for the review. 97cdd38 updates every place that still described the plan-only gate: |


Fixes WOOA7S-2208
Proposed changes
The product call on the soft-launch thread: follow classic Stats, which shows the Ads tab only when the site is actually using WordAds.
On WordPress.com the Ads section is registered by
jetpack-mu-wpcomwhen the plan includes the WordAds feature, so every Premium-and-up Simple or Atomic site gets an Ads tab, with empty earnings if ads were never turned on (jetpacklive.wordpress.com, for one). Classic gates on the sites API'soptions.wordads, wpcom'shas_wordads(): WordAds actually enabled. Self-hosted sites already match classic, since the WordAds module registers the section only while it is active.wpcom_premium_analytics_wordads_is_enabled().Modules::is_active( 'wordads', false ). A site with the module off is not running ads, whatever its approval sticker says: Odyssey ends up reading the shadow site's stickers throughjetpack/v4/siteand shows the tab on such a site, so this is stricter than Odyssey there, on purpose. Notavailable_only: the module list is not loaded on every request that hydrates the registry.has_wordads()reads there (trait.json-api-site-wpcom.phpon wpcom):has_any_blog_stickers( array( 'wordads-approved', 'wordads-approved-misfits' ), $blog_id ). Behindfunction_exists(), falling back to no tab, as the package's other sticker checks do.manage_optionsgate is unchanged.Tests: Atomic with the module off registers nothing; Simple follows the stickers, and the registrant asks for exactly those two. Docs, the sections diagram, the Ads package README and docblock and the module registrant's comments now describe the gate as plan feature plus WordAds on.
Supersedes #52766. That PR was closed as addressed by #52635, but #52635 moved the registrant with its plan-only gate intact:
wpcom_premium_analytics_site_has_wordads()still checkswpcom_site_has_feature( 'wordads' )and nothing else, and thejetpack-adspackage's ownis_availableis justmanage_options. So once #52864 put Ads back in the customer preview, every Premium-and-up Simple or Atomic site shows the tab again, WordAds on or not; a Simple site still at "Apply to Join WordAds" gets it. GitHub would not reopen #52766 after the rebase, hence the new PR (context). This is the same change rebased on trunk after #52635 and #52864. The check now sits insidewpcom_premium_analytics_site_has_wordads(), which both the section and the widget-type registrants read, so the widget types follow the tab.Related product discussion/links
jetpack-mu-wpcomcalling thejetpack-adspackage; Premium Analytics: Put the Ads tab back in the customer preview #52864 put the Ads tab back in the preview.Does this pull request change what data or activity we track or use?
No.
Testing instructions
jp test php packages/jetpack-mu-wpcompasses.?section=adsfalls back to Traffic; switch the module on and the tab appears.bin/jetpack-downloader test jetpack-mu-wpcom-plugin update/premium-analytics-ads-tab-wordads-enabled, then sandboxpublic-api.wordpress.com, not only the site: the tab list comes from thewpcom/v2/sites/<blog_id>/dashboards/jetpack-premium-analytics_dashboard/sectionsREST call, which is where this registrant runs. With only the site host sandboxed the change looks inert.wordads-approvedsticker no longer shows the tab, and?section=adsfalls back to Traffic.wp blog-stickers get --blog_id=<id>tells you which a site is (wp evalis disabled on the sandbox).wp blog-stickers add --blog_id=<id> --sticker=wordads-approved --who=<your login> --note="Testing jetpack#52903". Remove it afterwards withwp blog-stickers remove, same arguments: the sandbox writes to the production database.🤖 Generated with Claude Code