You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add an opt-in Ultimate Multisite setting that reduces authenticated front-end toolbar overhead on large networks by limiting the WordPress My Sites dropdown to the current site.
The complete site list must remain available from WordPress's My Sites administration page and all wp-admin/network-admin screens.
Evidence
Production-scale local profiling used 114 network sites and a super administrator whose toolbar exposed 26 sites.
Every switch initializes active Polylang and WooCommerce integrations for that blog, amplifying options, network-options, users, terms, and translation cache traffic.
The issue is not the database query that selects sites. It is eagerly preparing and rendering every site in the authenticated front-end toolbar.
Reproducer
Configure a multisite network with at least 25 sites visible to a super administrator.
Enable Ultimate Multisite and log in as that super administrator.
Request a front-end page with the WordPress toolbar enabled.
Trace switch_blog/restore_current_blog and object-cache lookups for the request.
Observe one switch/restore pair per visible site from hide_customer_sites_from_super_admin_list() and another pair per site from wp_admin_bar_my_sites_menu().
Repeat with only the current site exposed to the toolbar; compare switch and cache-read counts.
Symptom command (run with an authenticated cookie against the local multisite fixture while request-scoped cache and switch_blog tracers are active):
object-cache lookups: 31,182
switch_blog events: 160
Site_Manager toolbar-related pairs: 26
WordPress My Sites menu pairs: 26
Expected output:
When the opt-in setting is enabled, front-end toolbar preparation is bounded to the current site and does not add one switch/restore pair per visible network site. Administrative My Sites listings remain complete.
Causal status: confirmed
Owning-path proof:
Production entry point: WP_Admin_Bar::initialize() calls get_blogs_of_user() while preparing an authenticated toolbar.
Call chain: get_blogs_of_user() → pre_get_blogs_of_user → Site_Manager::hide_customer_sites_from_super_admin_list() → per-site details; core later runs wp_admin_bar_my_sites_menu() → switch_to_blog() for every returned site.
Integrated verification: the same authenticated front-end request fell from 31,182 to 25,756 object-cache lookups when the toolbar fixture exposed only the current site.
Proposed setting
Add an opt-in toggle under Ultimate Multisite → Settings → Sites → Site Options:
Optimize the front-end My Sites toolbar
Show only the current site in the front-end toolbar to reduce processing on large networks. The complete site list remains available from the My Sites administration page.
init() registers hide_customer_sites_from_super_admin_list() on pre_get_blogs_of_user at priority 999.
Add a narrowly scoped fast path when the setting is enabled and the request is the authenticated front-end toolbar path.
Return only the current/active site needed by WP_Admin_Bar; avoid reading blogname/siteurl details for every eligible site.
Leave the existing full-list path untouched in administrative and non-toolbar contexts.
tests/WP_Ultimo/Managers/Site_Manager_Test.php
Extend the existing tests around hide_customer_sites_from_super_admin_list().
tests/WP_Ultimo/Settings_Test.php
Verify registration and the backward-compatible default.
If safely distinguishing the toolbar's nested get_blogs_of_user() call requires a small dedicated helper or lifecycle flag, keep that implementation internal to Ultimate Multisite and document why the scope cannot rely on ! is_admin() alone.
Acceptance criteria
The new setting exists, is documented in its field description, and defaults off.
With the setting off, the existing site list and toolbar behavior are unchanged.
With the setting on, an authenticated front-end toolbar request prepares only the current site.
The full site list remains available in wp-admin/my-sites.php, site admin, and network admin.
Non-toolbar calls to get_blogs_of_user() retain complete, correctly filtered results.
Super-admin filtering and customer-owned-site hiding remain correct.
The toolbar retains current-site, My Sites, and Network Admin navigation.
Tests cover enabled/disabled, front-end/admin, toolbar/non-toolbar, super-admin/non-super-admin, and multisite edge cases.
A performance regression test or bounded instrumentation demonstrates that toolbar work no longer scales linearly with the number of visible sites when enabled.
Objective
Add an opt-in Ultimate Multisite setting that reduces authenticated front-end toolbar overhead on large networks by limiting the WordPress My Sites dropdown to the current site.
The complete site list must remain available from WordPress's My Sites administration page and all wp-admin/network-admin screens.
Evidence
Production-scale local profiling used 114 network sites and a super administrator whose toolbar exposed 26 sites.
switch_blogtracing recorded 160 events. Two toolbar-related paths each produced 26 switch/restore pairs:WP_Ultimo\Managers\Site_Manager::hide_customer_sites_from_super_admin_list()wp_admin_bar_my_sites_menu()The issue is not the database query that selects sites. It is eagerly preparing and rendering every site in the authenticated front-end toolbar.
Reproducer
switch_blog/restore_current_blogand object-cache lookups for the request.hide_customer_sites_from_super_admin_list()and another pair per site fromwp_admin_bar_my_sites_menu().Symptom command (run with an authenticated cookie against the local multisite fixture while request-scoped cache and
switch_blogtracers are active):Actual output:
Expected output:
Causal status: confirmed
Owning-path proof:
WP_Admin_Bar::initialize()callsget_blogs_of_user()while preparing an authenticated toolbar.get_blogs_of_user()→pre_get_blogs_of_user→Site_Manager::hide_customer_sites_from_super_admin_list()→ per-site details; core later runswp_admin_bar_my_sites_menu()→switch_to_blog()for every returned site.Proposed setting
Add an opt-in toggle under Ultimate Multisite → Settings → Sites → Site Options:
Suggested setting key:
optimize_frontend_my_sites_toolbar.falsefor backward compatibility.Implementation context
Expected files:
inc/class-settings.phpsitessection near the Site Options fields.add_field(..., ['type' => 'toggle', 'default' => 0])patterns.inc/managers/class-site-manager.phpinit()registershide_customer_sites_from_super_admin_list()onpre_get_blogs_of_userat priority 999.WP_Admin_Bar; avoid readingblogname/siteurldetails for every eligible site.tests/WP_Ultimo/Managers/Site_Manager_Test.phphide_customer_sites_from_super_admin_list().tests/WP_Ultimo/Settings_Test.phpIf safely distinguishing the toolbar's nested
get_blogs_of_user()call requires a small dedicated helper or lifecycle flag, keep that implementation internal to Ultimate Multisite and document why the scope cannot rely on! is_admin()alone.Acceptance criteria
wp-admin/my-sites.php, site admin, and network admin.get_blogs_of_user()retain complete, correctly filtered results.Verification
Run:
Then verify in a multisite fixture with at least 25 visible sites:
wp-admin/my-sites.phpand network-admin site listings remain complete.switch_blogcounts before and after; the optimized front-end request should not perform one switch/restore pair per visible toolbar site.Out of scope