-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support to multisite #690
base: trunk
Are you sure you want to change the base?
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. |
The tests are not working in GitHub actions, but when I run on local, works smoothly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davidperezgar I think we need to discuss a bit more what we want Multisite support of Plugin Check to look like. It's probably a bit too early to implement this PR without thinking about this more.
For example, what would be the benefit of having the admin page in the Network Admin instead of regular WP Admin if the functionality is exactly the same? Should we maybe show it under both? Also, what about the behavior in terms of runtime checks? Should the Network Admin UI only allow covering network-active plugins?
There are several questions to discuss here, so I suggest we move this conversation to the issue before we work on the code, to make decisions on these blocking questions.
$admin_menu_hook = is_multisite() ? 'network_admin_menu' : 'admin_menu'; | ||
$plugin_action_link_hook = is_multisite() ? 'network_admin_plugin_action_links' : 'plugin_action_links'; | ||
|
||
add_action( $admin_menu_hook, array( $this, 'add_and_initialize_page' ) ); | ||
add_filter( $plugin_action_link_hook, array( $this, 'filter_plugin_action_links' ), 10, 4 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we would want to only show the Plugin Check UI in the Network Admin just because it's a Multisite network. Maybe it should be in addition instead? I think that's worth discussing further before we make a decision and implement it.
$admin_parent_page = is_multisite() ? 'settings.php' : 'tools.php'; | ||
$capabilities = is_multisite() ? 'manage_network_plugins' : 'activate_plugins'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above, maybe this should support both regular WP Admin and Network Admin?
Instead of checking is_multisite()
(which forces it to only work for one of the two), you could check for is_network_admin()
to make the decision.
$admin_parent_page = is_multisite() ? 'settings.php' : 'tools.php'; | ||
$capabilities = is_multisite() ? 'manage_network_plugins' : 'activate_plugins'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable should probably be called $capability
since it only stores one capability.
if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) { | ||
$actions[] = sprintf( | ||
'<a href="%1$s">%2$s</a>', | ||
esc_url( network_admin_url( "settings.php?page=plugin-check&plugin={$plugin_file}" ) ), | ||
esc_html__( 'Check this plugin', 'plugin-check' ) | ||
); | ||
} elseif ( current_user_can( 'activate_plugins' ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above, this could also support both WP Admin and Network Admin UIs.
if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) { | |
$actions[] = sprintf( | |
'<a href="%1$s">%2$s</a>', | |
esc_url( network_admin_url( "settings.php?page=plugin-check&plugin={$plugin_file}" ) ), | |
esc_html__( 'Check this plugin', 'plugin-check' ) | |
); | |
} elseif ( current_user_can( 'activate_plugins' ) ) { | |
if ( is_network_admin() && current_user_can( 'manage_network_plugins' ) ) { | |
$actions[] = sprintf( | |
'<a href="%1$s">%2$s</a>', | |
esc_url( network_admin_url( "settings.php?page=plugin-check&plugin={$plugin_file}" ) ), | |
esc_html__( 'Check this plugin', 'plugin-check' ) | |
); | |
} elseif ( ! is_network_admin() && current_user_can( 'activate_plugins' ) ) { |
Thanks for your feedback, yes, maybe we could discuss in the issue, what would expect to have in MU, and then this PR. I agree what you mentioned. |
Fixes #64