Add multisite (Network Admin) support for the admin page#1344
Add multisite (Network Admin) support for the admin page#1344borislav-angelov wants to merge 1 commit into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Register the Plugin Check screen on the network_admin_menu hook under "Settings" (settings.php), since the "Tools" menu does not exist in the Network Admin. Also surface the plugin action link in the Network Admin plugins list via the network_admin_plugin_action_links filter, pointing to the settings.php-based URL. Fixes WordPress#64 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
6f9b0a0 to
3d831e9
Compare
|
Hello @borislav-angelov. Thanks for your contribution. You've created the menu in Network > Settings > Plugin Check. I don't think this is a good place. I understand that you would find the settings of the plugin, that we already have a page. Maybe we should create a parent menu? |
Summary
Fixes #64.
The admin screen and the plugin action link were limited to the individual site's WP Admin. This expands both to also work in the Network Admin, which is important because on some multisite configurations regular administrators are not allowed to control plugins.
Changes
includes/Admin/Admin_Page.phpadd_hooks()now also registers:network_admin_menu→add_and_initialize_network_pagenetwork_admin_plugin_action_linksfilter →filter_network_admin_plugin_action_linksadd_network_page()/add_and_initialize_network_page()— registers the screen under Settings (settings.php) viaadd_submenu_page()with themanage_network_pluginscapability, since the "Tools" menu does not exist in the Network Admin. The screen reuses the existingrender_page/initialize_pagecallbacks, so it behaves the same as in the regular WP Admin.filter_network_admin_plugin_action_links()— adds the action link in the Network Admin plugins list, pointing atnetwork_admin_url( 'settings.php?page=plugin-check' )(the page lives undersettings.phphere instead oftools.php).add_check_action_link()helper; only the base page URL is parameterized, so the existing single-site URLs are unchanged.Test coverage
tests/phpunit/tests/Admin/Admin_Page_Tests.phptest_add_hooksextended to assert the two new Network Admin hooks are registered.test_add_and_initialize_network_page— ensures the admin page is added undersettings.phpusing the Network Admin specific action (skipped on non-multisite).test_filter_network_admin_plugin_action_links— ensures the plugin link is added with thesettings.php-based URL via the Network Admin specific filter.Verified locally on WP 7.0 across both single-site and multisite runs —
Admin_Page_Testspasses in both (the network page test is correctly skipped on single-site and executes on multisite). PHPCS and PHPStan are clean on the changed files.