Skip to content

GH#836: add Network Activate button in setup wizard for non-network-active plugin#851

Merged
superdav42 merged 1 commit intomainfrom
feature/auto-20260414-093145
Apr 14, 2026
Merged

GH#836: add Network Activate button in setup wizard for non-network-active plugin#851
superdav42 merged 1 commit intomainfrom
feature/auto-20260414-093145

Conversation

@superdav42
Copy link
Copy Markdown
Collaborator

Summary

When Ultimate Multisite is not network active, the Pre-install Checks step in the setup wizard previously showed only a Read More link. This PR replaces that link with a Network Activate button that attempts to activate the plugin automatically. The Read More link is preserved as a hidden fallback, shown only when AJAX activation fails.

Changes

inc/admin-pages/class-setup-wizard-admin-page.php

  • Added ajax_network_activate() method — nonce-protected, manage_network-gated AJAX handler that calls activate_plugin(WP_ULTIMO_PLUGIN_BASENAME, '', true)
  • Registered wp_ajax_wu_setup_network_activate action in __construct()
  • Updated renders_requirements_table() to compute $is_network_active and $can_network_activate and pass can_activate, network_activate_nonce, and has_activate_button to the template

views/wizards/setup/requirements_table.php

  • When can_activate is true on a plugin requirement row, shows a primary Network Activate button with a spinner
  • On AJAX success: reloads the page so the checks refresh
  • On AJAX failure: hides the button, reveals the fallback Read More link, and displays the error message
  • Updated the bottom error message to contextually reference the button when $has_activate_button is true

tests/WP_Ultimo/Admin_Pages/Setup_Wizard_Admin_Page_Test.php

  • Added test_constructor_registers_network_activate_ajax_action — verifies action hook registration
  • Added test_ajax_network_activate_sends_json_error_without_permission — provides valid nonce, sets user to 0, expects JSON error response

Verification

WP_TESTS_DIR=/tmp/wordpress-tests-lib vendor/bin/phpunit --filter "Setup_Wizard_Admin_Page_Test"
# All 37+ tests pass (exit 0)

vendor/bin/phpstan analyse inc/admin-pages/class-setup-wizard-admin-page.php --no-progress
# [OK] No errors

Resolves #836

…ive plugin

When Ultimate Multisite is not network active, the Pre-install Checks step
now shows a 'Network Activate' button instead of only a 'Read More' link.

- Add ajax_network_activate() AJAX handler in Setup_Wizard_Admin_Page
  to perform network activation of the plugin
- Update renders_requirements_table() to compute can_activate flag and
  nonce, passing them to the wp-ultimo plugin requirement item
- Update requirements_table.php view: show 'Network Activate' button when
  can_activate is true; on AJAX failure, reveal the 'Read More' fallback
  link; update bottom error message to reference the button
- Add inline JS (jQuery) to call the AJAX handler and reload on success,
  or surface the fallback link on failure
- Add tests for the new AJAX action hook registration and permission guard

Resolves #836
@superdav42 superdav42 added the origin:interactive Created by interactive user session label Apr 14, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

Warning

Rate limit exceeded

@superdav42 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 48 minutes and 2 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 48 minutes and 2 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a42a3fb6-6352-48bb-a57c-7d9862a51b59

📥 Commits

Reviewing files that changed from the base of the PR and between 0584d52 and 6c5cbb8.

📒 Files selected for processing (3)
  • inc/admin-pages/class-setup-wizard-admin-page.php
  • tests/WP_Ultimo/Admin_Pages/Setup_Wizard_Admin_Page_Test.php
  • views/wizards/setup/requirements_table.php
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/auto-20260414-093145

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@superdav42
Copy link
Copy Markdown
Collaborator Author

Merge Summary

Issue: #836 — If ultimate multisite is not network active in setup wizard it should try to activate it

What was implemented:

  • Added ajax_network_activate() AJAX handler (nonce + manage_network capability gated) in Setup_Wizard_Admin_Page
  • Updated renders_requirements_table() to pass can_activate, network_activate_nonce, and has_activate_button to the requirements table view
  • Updated views/wizards/setup/requirements_table.php: when the plugin is not network active and the current user can manage the network, a Network Activate button is shown instead of the Read More link. On AJAX success, the page reloads; on failure, the button is hidden and the Read More link appears as a fallback
  • Updated the bottom error message to contextually reference the button vs Read More links
  • Added 2 new tests: action hook registration and permission guard for the new AJAX endpoint

Files changed:

  • inc/admin-pages/class-setup-wizard-admin-page.php (new AJAX handler + nonce generation)
  • views/wizards/setup/requirements_table.php (button UI + inline JS)
  • tests/WP_Ultimo/Admin_Pages/Setup_Wizard_Admin_Page_Test.php (2 new tests)

Verification: 37 PHPUnit tests pass, PHPStan level 0 clean.


aidevops.sh v3.8.24 plugin for OpenCode v1.4.3 with claude-sonnet-4-6 spent 10m and 294 tokens on this as a headless worker. Overall, 23s since this issue was created.

@github-actions
Copy link
Copy Markdown

🔨 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!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

@superdav42 superdav42 merged commit bbcffc0 into main Apr 14, 2026
9 of 11 checks passed
@github-actions
Copy link
Copy Markdown

Performance Test Results

Performance test results for d478a0e 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: /

Run DB Queries Memory Before Template Template WP Total LCP TTFB LCP - TTFB
0 40 37.75 MB 819.00 ms (-48.50 ms / -6% ) 171.00 ms 1040.00 ms (-31.00 ms / -3% ) 2066.00 ms 1965.15 ms 92.90 ms
1 56 49.03 MB 910.50 ms (-28.00 ms / -3% ) 149.00 ms 1058.50 ms (-30.00 ms / -3% ) 2042.00 ms 1962.70 ms 80.70 ms (-1.80 ms / -2% )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

origin:interactive Created by interactive user session

Projects

None yet

Development

Successfully merging this pull request may close these issues.

If ultimate multisite is not network active in setup wizard it should try to activate it

1 participant