fix(dashboard): resolve wu_moment ReferenceError on network dashboard activity stream#705
Conversation
…cripts The activity-stream.js was enqueued inside the view template during widget rendering (meta_box output), which fires after admin_enqueue_scripts. WordPress cannot properly resolve the dependency chain for scripts enqueued that late, so wu-functions (which defines window.wu_moment) was not loaded before activity-stream.js executed, causing 'ReferenceError: wu_moment is not defined' and leaving the Activity Stream widget stuck on 'Loading...' permanently. Move the wp_enqueue_script call to Dashboard_Widgets::enqueue_scripts() where it runs during admin_enqueue_scripts, and add moment as a declared dependency of wu-functions since functions.js uses moment.tz/moment.utc in wu_moment.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis change centralizes the enqueuing of the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔨 Build Complete - Ready for Testing!📦 Download Build Artifact (Recommended)Download the zip build, upload to WordPress and test:
🌐 Test in WordPress Playground (Very Experimental)Click the link below to instantly test this PR in your browser - no installation needed! Login credentials: |
|
Performance Test Results Performance test results for 1a9bdb9 are in 🛎️! Note: the numbers in parentheses show the difference to the previous (baseline) test run. Differences below 2% or 0.5 in absolute values are not shown. URL:
|
Summary
wu-activity-streamscript enqueue from the view template (activity-stream.php) toDashboard_Widgets::enqueue_scripts()so it runs duringadmin_enqueue_scriptswhere WordPress properly resolves the dependency chainmomentas a declared dependency ofwu-functionssincefunctions.jsusesmoment.tz/moment.utcinwu_moment()wu-activity-streamis enqueued with correct dependencies onindex.phpProblem
The Activity Stream widget on the network admin dashboard was permanently stuck on "Loading..." with:
activity-stream.jswas enqueued inside the view template during widget rendering (meta_box output phase), which fires afteradmin_enqueue_scripts. WordPress cannot properly resolve the dependency chain for scripts enqueued that late, sowu-functions(which defineswindow.wu_moment) was not guaranteed to load beforeactivity-stream.jsexecuted.Fix
Moved the
wp_enqueue_script('wu-activity-stream', ...)call fromviews/dashboard-widgets/activity-stream.phpintoDashboard_Widgets::enqueue_scripts(), which hooks onadmin_enqueue_scripts. This ensures WordPress resolves the full dependency chain (moment->wu-functions->wu-activity-stream) before any script executes.Also added
momentas an explicit dependency ofwu-functionssincefunctions.jsline 626-634 defineswu_moment()which callsmoment.tz()/moment.utc().Verification
wu_moment is not definederror is goneaidevops.sh v3.5.463 plugin for OpenCode v1.3.4 with claude-opus-4-6 spent 39m and 15,589 tokens on this as a headless worker.
Summary by CodeRabbit
Refactor
Tests