mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
Include network-active plugins and inactive network-only plugins on the Plugins listing screen for individual sites on Multisite.
These plugins are only shown to users with the `manage_network_plugins` capability, which is Super Admins by default. This new feature lowers the blood pressure of Super Admins who may browse or search the Plugins listing screen of an individual site, having forgotten that a particular plugin is network-active. Showing inactive network-only plugins here also reduces friction when searching the Plugins listing screen on individual sites. This change introduces a `show_network_active_plugins` filter which controls whether the network-active plugins and inactive network-only plugins are shown. This can be used to enable this functionality for regular site admininstrators, or, indeed, to disable this functionality for Super Admins. Fixes #20104 Built from https://develop.svn.wordpress.org/trunk@35151 git-svn-id: http://core.svn.wordpress.org/trunk@35117 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
31b40bdbb7
commit
87aa982824
@ -881,6 +881,11 @@ p.pagenav {
|
|||||||
padding: 2px 0 0;
|
padding: 2px 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.row-actions .network_only,
|
||||||
|
.row-actions .network_active {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
tr:hover .row-actions,
|
tr:hover .row-actions,
|
||||||
.mobile .row-actions,
|
.mobile .row-actions,
|
||||||
.row-actions.visible,
|
.row-actions.visible,
|
||||||
|
@ -881,6 +881,11 @@ p.pagenav {
|
|||||||
padding: 2px 0 0;
|
padding: 2px 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.row-actions .network_only,
|
||||||
|
.row-actions .network_active {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
tr:hover .row-actions,
|
tr:hover .row-actions,
|
||||||
.mobile .row-actions,
|
.mobile .row-actions,
|
||||||
.row-actions.visible,
|
.row-actions.visible,
|
||||||
|
2
wp-admin/css/wp-admin-rtl.min.css
vendored
2
wp-admin/css/wp-admin-rtl.min.css
vendored
File diff suppressed because one or more lines are too long
2
wp-admin/css/wp-admin.min.css
vendored
2
wp-admin/css/wp-admin.min.css
vendored
File diff suppressed because one or more lines are too long
@ -127,6 +127,24 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ! $screen->in_admin( 'network' ) ) {
|
||||||
|
$show = current_user_can( 'manage_network_plugins' );
|
||||||
|
/**
|
||||||
|
* Filter whether to display network-active plugins alongside plugins active for the current site.
|
||||||
|
*
|
||||||
|
* This also controls the display of inactive network-only plugins (plugins with
|
||||||
|
* "Network: true" in the plugin header).
|
||||||
|
*
|
||||||
|
* Plugins cannot be network-activated or network-deactivated from this screen.
|
||||||
|
*
|
||||||
|
* @since 4.4.0
|
||||||
|
*
|
||||||
|
* @param bool $show Whether to show network-active plugins. Default is whether the current
|
||||||
|
* user can manage network plugins (ie. a Super Admin).
|
||||||
|
*/
|
||||||
|
$show_network_active = apply_filters( 'show_network_active_plugins', $show );
|
||||||
|
}
|
||||||
|
|
||||||
set_transient( 'plugin_slugs', array_keys( $plugins['all'] ), DAY_IN_SECONDS );
|
set_transient( 'plugin_slugs', array_keys( $plugins['all'] ), DAY_IN_SECONDS );
|
||||||
|
|
||||||
if ( $screen->in_admin( 'network' ) ) {
|
if ( $screen->in_admin( 'network' ) ) {
|
||||||
@ -168,11 +186,21 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||||||
|
|
||||||
// Filter into individual sections
|
// Filter into individual sections
|
||||||
if ( is_multisite() && ! $screen->in_admin( 'network' ) && is_network_only_plugin( $plugin_file ) && ! is_plugin_active( $plugin_file ) ) {
|
if ( is_multisite() && ! $screen->in_admin( 'network' ) && is_network_only_plugin( $plugin_file ) && ! is_plugin_active( $plugin_file ) ) {
|
||||||
// On the non-network screen, filter out network-only plugins as long as they're not individually activated
|
if ( $show_network_active ) {
|
||||||
|
// On the non-network screen, show inactive network-only plugins if allowed
|
||||||
|
$plugins['inactive'][ $plugin_file ] = $plugin_data;
|
||||||
|
} else {
|
||||||
|
// On the non-network screen, filter out network-only plugins as long as they're not individually active
|
||||||
unset( $plugins['all'][ $plugin_file ] );
|
unset( $plugins['all'][ $plugin_file ] );
|
||||||
|
}
|
||||||
} elseif ( ! $screen->in_admin( 'network' ) && is_plugin_active_for_network( $plugin_file ) ) {
|
} elseif ( ! $screen->in_admin( 'network' ) && is_plugin_active_for_network( $plugin_file ) ) {
|
||||||
// On the non-network screen, filter out network activated plugins
|
if ( $show_network_active ) {
|
||||||
|
// On the non-network screen, show network-active plugins if allowed
|
||||||
|
$plugins['active'][ $plugin_file ] = $plugin_data;
|
||||||
|
} else {
|
||||||
|
// On the non-network screen, filter out network-active plugins
|
||||||
unset( $plugins['all'][ $plugin_file ] );
|
unset( $plugins['all'][ $plugin_file ] );
|
||||||
|
}
|
||||||
} elseif ( ( ! $screen->in_admin( 'network' ) && is_plugin_active( $plugin_file ) )
|
} elseif ( ( ! $screen->in_admin( 'network' ) && is_plugin_active( $plugin_file ) )
|
||||||
|| ( $screen->in_admin( 'network' ) && is_plugin_active_for_network( $plugin_file ) ) ) {
|
|| ( $screen->in_admin( 'network' ) && is_plugin_active_for_network( $plugin_file ) ) ) {
|
||||||
// On the non-network screen, populate the active list with plugins that are individually activated
|
// On the non-network screen, populate the active list with plugins that are individually activated
|
||||||
@ -487,10 +515,15 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||||||
if ( $plugin_data['Description'] )
|
if ( $plugin_data['Description'] )
|
||||||
$description .= '<p>' . $plugin_data['Description'] . '</p>';
|
$description .= '<p>' . $plugin_data['Description'] . '</p>';
|
||||||
} else {
|
} else {
|
||||||
if ( $screen->in_admin( 'network' ) )
|
if ( $screen->in_admin( 'network' ) ) {
|
||||||
$is_active = is_plugin_active_for_network( $plugin_file );
|
$is_active = is_plugin_active_for_network( $plugin_file );
|
||||||
else
|
$restrict_network_active = false;
|
||||||
|
$restrict_network_only = false;
|
||||||
|
} else {
|
||||||
$is_active = is_plugin_active( $plugin_file );
|
$is_active = is_plugin_active( $plugin_file );
|
||||||
|
$restrict_network_active = ( is_multisite() && is_plugin_active_for_network( $plugin_file ) );
|
||||||
|
$restrict_network_only = ( is_multisite() && is_network_only_plugin( $plugin_file ) && ! $is_active );
|
||||||
|
}
|
||||||
|
|
||||||
if ( $screen->in_admin( 'network' ) ) {
|
if ( $screen->in_admin( 'network' ) ) {
|
||||||
if ( $is_active ) {
|
if ( $is_active ) {
|
||||||
@ -509,7 +542,15 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ( $is_active ) {
|
if ( $restrict_network_active ) {
|
||||||
|
$actions = array(
|
||||||
|
'network_active' => __( 'Network Active' ),
|
||||||
|
);
|
||||||
|
} elseif ( $restrict_network_only ) {
|
||||||
|
$actions = array(
|
||||||
|
'network_only' => __( 'Network Only' ),
|
||||||
|
);
|
||||||
|
} elseif ( $is_active ) {
|
||||||
/* translators: %s: plugin name */
|
/* translators: %s: plugin name */
|
||||||
$actions['deactivate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=deactivate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'deactivate-plugin_' . $plugin_file ) . '" aria-label="' . esc_attr( sprintf( __( 'Deactivate %s' ), $plugin_data['Name'] ) ) . '">' . __( 'Deactivate' ) . '</a>';
|
$actions['deactivate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=deactivate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'deactivate-plugin_' . $plugin_file ) . '" aria-label="' . esc_attr( sprintf( __( 'Deactivate %s' ), $plugin_data['Name'] ) ) . '">' . __( 'Deactivate' ) . '</a>';
|
||||||
} else {
|
} else {
|
||||||
@ -613,7 +654,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||||||
|
|
||||||
$class = $is_active ? 'active' : 'inactive';
|
$class = $is_active ? 'active' : 'inactive';
|
||||||
$checkbox_id = "checkbox_" . md5($plugin_data['Name']);
|
$checkbox_id = "checkbox_" . md5($plugin_data['Name']);
|
||||||
if ( in_array( $status, array( 'mustuse', 'dropins' ) ) ) {
|
if ( $restrict_network_active || $restrict_network_only || in_array( $status, array( 'mustuse', 'dropins' ) ) ) {
|
||||||
$checkbox = '';
|
$checkbox = '';
|
||||||
} else {
|
} else {
|
||||||
$checkbox = "<label class='screen-reader-text' for='" . $checkbox_id . "' >" . sprintf( __( 'Select %s' ), $plugin_data['Name'] ) . "</label>"
|
$checkbox = "<label class='screen-reader-text' for='" . $checkbox_id . "' >" . sprintf( __( 'Select %s' ), $plugin_data['Name'] ) . "</label>"
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.4-alpha-35150';
|
$wp_version = '4.4-alpha-35151';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user