Skip to content

fix(tours): wu_tours is not defined on network dashboard #707

Description

@superdav42

Bug

Uncaught ReferenceError: wu_tours is not defined
    at HTMLDocument.<anonymous> (tours.js:7:10)

The guided tour on the network admin dashboard (/wp-admin/network/) throws a ReferenceError because wu_tours is never defined.

Root Cause

tours.js line 7 calls _.each(wu_tours, ...) unconditionally. The wu_tours variable is localized onto the wu-admin script handle (wp_localize_script('wu-admin', 'wu_tours', ...) in Tours::enqueue_scripts() line 95).

Since PR #433 (cb5a40fd — "Scope admin asset enqueues to WP Ultimo pages only"), wu-admin is only enqueued on pages where wu_is_wu_page() returns true. The network dashboard (index.php, hook suffix dashboard-network) is not a WU page, so wu-admin is never enqueued there and wu_tours is never defined.

The code comment on line 94 says "wu-admin which will always be there" — this assumption was broken by the performance scoping change.

Affected Pages

  • Network admin dashboard (/wp-admin/network/) — Dashboard_Widgets::register_network_widgets() creates a "dashboard" tour at line 104

Other pages that create tours (class-dashboard-admin-page.php, class-product-edit-admin-page.php, etc.) are WU pages where wu-admin IS enqueued, so they're unaffected.

Fix Options

  1. In Tours::enqueue_scripts(): Instead of localizing onto wu-admin, enqueue a lightweight carrier script (or use wp_add_inline_script on underscore) to define wu_tours and wu_tours_vars as globals. This decouples tours from wu-admin.

  2. In tours.js: Add a guard if (typeof wu_tours === 'undefined') return; before the _.each call. This prevents the error but means tours silently won't work if the localization is missing — the underlying localization issue still needs fixing.

  3. In Dashboard_Widgets::enqueue_scripts(): Explicitly enqueue wu-admin on the dashboard (like was done for wu-functions). This is the simplest fix but re-loads wu-admin on a non-WU page, partially undoing the performance optimization.

Option 1 is the cleanest — it fixes the architectural issue (tours shouldn't depend on wu-admin being present).

Related


aidevops.sh v3.5.463 plugin for OpenCode v1.3.4 with claude-opus-4-6 spent 1h 5m and 22,392 tokens on this with the user in an interactive session.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingstatus:in-reviewPR open, awaiting review/merge

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions