Skip to content
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

Open
wants to merge 5 commits into
base: trunk
Choose a base branch
from

Conversation

davidperezgar
Copy link
Member

Fixes #64

@davidperezgar davidperezgar linked an issue Oct 2, 2024 that may be closed by this pull request
@davidperezgar davidperezgar self-assigned this Oct 2, 2024
@davidperezgar davidperezgar marked this pull request as ready for review October 2, 2024 18:33
Copy link

github-actions bot commented Oct 2, 2024

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: davidperezgar <[email protected]>
Co-authored-by: felixarntz <[email protected]>
Co-authored-by: eclarke1 <[email protected]>
Co-authored-by: vishalkakadiya <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@davidperezgar
Copy link
Member Author

The tests are not working in GitHub actions, but when I run on local, works smoothly.

@swissspidy swissspidy requested a review from felixarntz October 2, 2024 18:59
Copy link
Member

@felixarntz felixarntz left a 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.

Comment on lines +57 to +61
$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 );
Copy link
Member

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.

Comment on lines +74 to +75
$admin_parent_page = is_multisite() ? 'settings.php' : 'tools.php';
$capabilities = is_multisite() ? 'manage_network_plugins' : 'activate_plugins';
Copy link
Member

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.

Comment on lines +74 to +75
$admin_parent_page = is_multisite() ? 'settings.php' : 'tools.php';
$capabilities = is_multisite() ? 'manage_network_plugins' : 'activate_plugins';
Copy link
Member

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.

Comment on lines +318 to +324
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' ) ) {
Copy link
Member

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.

Suggested change
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' ) ) {

@davidperezgar
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add multisite support for admin page
2 participants