Add multisite (Network Admin) support for the admin page#1344
Open
borislav-angelov wants to merge 1 commit into
Open
Add multisite (Network Admin) support for the admin page#1344borislav-angelov wants to merge 1 commit into
borislav-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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @felixarntz. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.