Reapply: Rename Advertising to Blaze Ads, add context-aware menu and campaign promotion#47858
Reapply: Rename Advertising to Blaze Ads, add context-aware menu and campaign promotion#47858
Conversation
|
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: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Code Coverage SummaryCoverage changed in 2 files.
|
…tection Simple Sites have two issues with the menu changes from #47582: 1. has_site_campaigns() always returns false because it uses Client::wpcom_json_api_request_as_user() which relies on Jetpack Signature — unavailable on Simple Sites. Switch to request_as_blog() which uses WPCOM_API_Direct on Simple Sites (no HTTP round-trip). 2. The embedded dashboard (admin.php?page=advertising) under the 'jetpack' parent menu is not routable by the WPCOM admin bridge on Simple Sites — it falls back to /home/. Fix by using the external Calypso URL (https://wordpress.com/advertising/...) on Simple Sites, matching the pattern used by every other Jetpack submenu item. Also skip the legacy tools.php → admin.php redirect on Simple Sites since admin.php?page=advertising is not routable there. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
On Simple Sites the WPCOM admin bridge only routes tools.php?page=… URLs. Changing the dashboard base to admin.php (needed for Jetpack/Woo parent menus on Atomic and self-hosted) breaks Simple Sites because admin.php?page=advertising falls back to /home/. Fix: detect Simple Sites (IS_WPCOM) and keep tools.php as the dashboard base while still using the new parent menu and campaign detection logic. Also keep request_as_blog for has_site_campaigns() since it uses WPCOM_API_Direct on Simple Sites (no HTTP round-trip needed). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Temporary error_log to trace which code branch executes on Simple Sites. Logs: parent_slug, is_simple, dashboard_enabled, has_campaigns, wpcom_admin_interface. Remove before merging. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Clean up temporary error_log from investigation. Fix all Generic.Formatting.MultipleStatementAlignment warnings. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Restore self::has_site_campaigns() call lost during debug cleanup - Fix equals sign alignment in get_campaign_management_url Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
On Simple Sites the WPCOM admin bridge only routes tools.php?page=… URLs. Registering under a plugin parent (jetpack, woocommerce-marketing) produces admin.php?page=… which the bridge cannot route. Fix: on Simple Sites, register the actual page callback under tools.php (so the URL is routable), then hide it from the Tools menu and add a visible link under the Jetpack parent (or top-level) pointing to the tools.php URL. This gives us the desired menu placement while keeping the page functional. Non-Simple sites (Atomic, self-hosted) are unaffected — they use admin.php?page=… directly which works fine with any parent menu. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Simple Sites can use admin.php?page=slug like every other environment. Remove the $is_simple_site branching that registered the page under tools.php and pointed menu items to it. Now all environments share the same code path: add_menu_page / add_submenu_page with the slug directly. The legacy redirect (tools.php?page=advertising → admin.php) now also applies on Simple Sites so old bookmarks keep working. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The WPCOM platform branch was using the Calypso URL as the menu slug, which in wp-admin got rewritten to wp-admin/advertising (broken). Now it uses the same slug and render callback as the dashboard-enabled branch, so the menu correctly points to admin.php?page=advertising. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
On Simple Sites, the Jetpack top-level menu is created at priority 1000
by Admin_Menu::admin_menu_hook_callback(), but Blaze registers its
submenu at priority 999. When add_submenu_page('jetpack', ...) is called
before the parent menu exists, WordPress computes the wrong page
hookname (admin_page_advertising instead of jetpack_page_advertising).
This causes the menu link href to be just "advertising" instead of
"admin.php?page=advertising", resulting in a broken URL.
Fix: Use Admin_Menu::add_menu() (the same pattern Social uses) when
registering under the Jetpack parent. This queues the item and registers
it at priority 1000, after the top-level menu exists. For other parents
(tools.php, woocommerce-marketing) that exist at priority 999, keep
using add_submenu_page directly.
Also consolidate the is_dashboard_enabled and is_wpcom_platform branches
which contained identical logic.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When the parent is 'jetpack', the menu item is now queued via Admin_Menu::add_menu() instead of added directly to $submenu. The test needs to call Admin_Menu::admin_menu_hook_callback() to flush the queue before checking $submenu. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
sbarbosa
left a comment
There was a problem hiding this comment.
I tested this on an ephemeral site, an atomic and simple site. I added some comments for the ephemeral test.
I was not able to validate the Root-level link on my atomic site. I still see it under Jetpack, and that's my main site (I have 200+ campaigns in there). I created a new campaign to see if that worked, but the menu is still under Jetpack.
All of my simple sites already have campaigns, but I was able to see the link at the root level and it worked fine for me.
| * | ||
| * @return string The parent menu slug. | ||
| */ | ||
| public static function get_menu_parent() { |
There was a problem hiding this comment.
If we add the menu this way, there will be problems if the Blaze Ads plugin is also installed on the site:
The Blaze Ads plugin currently hides the Jetpack Dashboard and also includes the link on the Marketing page.
We had the is_dashboard_enabled condition here before, so I think the new changes are not currently checking for it. If the dashboard is disabled, we shouldn't put the menu anywhere.
If we want Blaze Ads to always be present in Marketing when running alongside Woo (regardless of whether Blaze Ads is installed), I think it's only possible by checking here whether the plugin is installed and, if it is, ignoring adding it (to prevent duplicate menus).
There was a problem hiding this comment.
Sounds good. I'll add the condition. We can still modify blaze-ads to behave how we want. I think the blaze-ads plugin feels very redundant when user has WooCommerce. I'll think about it, but I can see a lot of redundancy here. For now, i'll check if the user got the plugin. good catch!
Yes, ephemeral sites are just those short-lived sites that JN and other tools create. I tested it with JN, so you should be able to reproduce it. For the JN test, I did this: All plugin versions are from production (only the ones being pulled from dotorg). For the atomic test, I just installed Jetpack Beta on my atomic site and tested it with this specific branch version. |

Proposed changes:
Renames the "Advertising" menu item to "Blaze Ads" and makes the menu placement context-aware across all installation types. When a site has active campaigns, the menu is promoted to a top-level entry for better visibility.
Changes in
jetpack-blazepackage:get_menu_parent()for context-aware parent menu selection: WooCommerce Marketing (with menu existence guard) > Jetpack > Tools fallbackhas_active_campaigns()with 1-hour transient cache for campaign detection via WPCOM DSP APIadd_menu_page()when active campaigns exist (both dashboard-enabled and WPCOM non-dashboard paths)DashboardandDashboard_Config_Dataconstructor defaults fromtools.phptoadmin.phpget_campaign_management_url()to useadmin.php?page=advertisingredirect_legacy_advertising_url()(302 redirect fromtools.php?page=advertising)Changes in
jetpack-mu-wpcompackage:advertisingfrom Tools submenu reorder arrayadvertisingto Jetpack submenu reorder arrayChanges in Jetpack plugin:
tools.php?page=advertisingURL inblaze.jsxsettings panelOther information:
Related product discussion/links
Does this pull request change what data or activity we track or use?
No. The campaign detection API call uses the existing WPCOM DSP proxy and results are cached in a transient. No new tracking is introduced.
Testing instructions:
Context-aware menu placement (no campaigns):
Top-level promotion (with campaigns):
delete_transient('jetpack_blaze_has_active_campaigns_{blog_id}')) to verify state transitionsLegacy URL redirect:
tools.php?page=advertisingand verify it 302-redirects toadmin.php?page=advertisingDashboard functionality:
🤖 Jurassic Ninja Test Results (2026-04-01)
Test matrix
tools.php→admin.phptools.php→admin.phpTest sites used
registered-haddock-lemur.jurassic.ninjabird-of-rabbits.jurassic.ninjaNotes
javiolmo89/ads-796-blaze-ads-menu-reproinstalled via Jetpack Beta Testerjetpack_blaze_has_site_campaigns_{blog_id}toyes(the DSP API does not immediately return campaigns in moderation as active, so transient simulation was used)tools.php?page=advertising→admin.php?page=advertising) verified on both sites