-
Notifications
You must be signed in to change notification settings - Fork 53
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -54,8 +54,11 @@ | |||||||||||||||||||||||||||||
* @since 1.0.0 | ||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||
public function add_hooks() { | ||||||||||||||||||||||||||||||
add_action( 'admin_menu', array( $this, 'add_and_initialize_page' ) ); | ||||||||||||||||||||||||||||||
add_filter( 'plugin_action_links', array( $this, 'filter_plugin_action_links' ), 10, 4 ); | ||||||||||||||||||||||||||||||
$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 ); | ||||||||||||||||||||||||||||||
add_action( 'admin_enqueue_scripts', array( $this, 'add_jump_to_line_code_editor' ) ); | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
$this->admin_ajax->add_hooks(); | ||||||||||||||||||||||||||||||
|
@@ -64,13 +67,18 @@ | |||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||
* Adds the admin page under the tools menu. | ||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||
* @since n.e.x.t Added multisite support. | ||||||||||||||||||||||||||||||
* @since 1.0.0 | ||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||
public function add_page() { | ||||||||||||||||||||||||||||||
$this->hook_suffix = add_management_page( | ||||||||||||||||||||||||||||||
$admin_parent_page = is_multisite() ? 'settings.php' : 'tools.php'; | ||||||||||||||||||||||||||||||
$capabilities = is_multisite() ? 'manage_network_plugins' : 'activate_plugins'; | ||||||||||||||||||||||||||||||
Comment on lines
+74
to
+75
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Comment on lines
+74
to
+75
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This variable should probably be called |
||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
$this->hook_suffix = add_submenu_page( | ||||||||||||||||||||||||||||||
$admin_parent_page, | ||||||||||||||||||||||||||||||
__( 'Plugin Check', 'plugin-check' ), | ||||||||||||||||||||||||||||||
__( 'Plugin Check', 'plugin-check' ), | ||||||||||||||||||||||||||||||
'activate_plugins', | ||||||||||||||||||||||||||||||
$capabilities, | ||||||||||||||||||||||||||||||
'plugin-check', | ||||||||||||||||||||||||||||||
array( $this, 'render_page' ) | ||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||
|
@@ -307,7 +315,13 @@ | |||||||||||||||||||||||||||||
return $actions; | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
if ( current_user_can( 'activate_plugins' ) ) { | ||||||||||||||||||||||||||||||
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' ) ) { | ||||||||||||||||||||||||||||||
Comment on lines
+318
to
+324
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||||||||||||||||||||||||||||||
$actions[] = sprintf( | ||||||||||||||||||||||||||||||
'<a href="%1$s">%2$s</a>', | ||||||||||||||||||||||||||||||
esc_url( admin_url( "tools.php?page=plugin-check&plugin={$plugin_file}" ) ), | ||||||||||||||||||||||||||||||
|
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.