Implement 'Recently Active' functionality for network-wide plugins in the Network Admin.
Fixes #20468 Thanks to WordCamp RI attendees for testing! Built from https://develop.svn.wordpress.org/trunk@34551 git-svn-id: http://core.svn.wordpress.org/trunk@34515 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6ebc79e80c
commit
a729efa688
|
@ -129,12 +129,21 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
||||||
|
|
||||||
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' ) ) {
|
||||||
|
$recently_activated = get_site_option( 'recently_activated', array() );
|
||||||
|
} else {
|
||||||
$recently_activated = get_option( 'recently_activated', array() );
|
$recently_activated = get_option( 'recently_activated', array() );
|
||||||
|
}
|
||||||
|
|
||||||
foreach ( $recently_activated as $key => $time )
|
foreach ( $recently_activated as $key => $time ) {
|
||||||
if ( $time + WEEK_IN_SECONDS < time() )
|
if ( $time + WEEK_IN_SECONDS < time() ) {
|
||||||
unset( $recently_activated[$key] );
|
unset( $recently_activated[$key] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $screen->in_admin( 'network' ) ) {
|
||||||
|
update_site_option( 'recently_activated', $recently_activated );
|
||||||
|
} else {
|
||||||
update_option( 'recently_activated', $recently_activated );
|
update_option( 'recently_activated', $recently_activated );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,8 +179,8 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
||||||
// On the network-admin screen, populate the active list with plugins that are network activated
|
// On the network-admin screen, populate the active list with plugins that are network activated
|
||||||
$plugins['active'][ $plugin_file ] = $plugin_data;
|
$plugins['active'][ $plugin_file ] = $plugin_data;
|
||||||
} else {
|
} else {
|
||||||
if ( ! $screen->in_admin( 'network' ) && isset( $recently_activated[ $plugin_file ] ) ) {
|
if ( isset( $recently_activated[ $plugin_file ] ) ) {
|
||||||
// On the non-network screen, populate the recently activated list with plugins that have been recently activated
|
// Populate the recently activated list with plugins that have been recently activated
|
||||||
$plugins['recently_activated'][ $plugin_file ] = $plugin_data;
|
$plugins['recently_activated'][ $plugin_file ] = $plugin_data;
|
||||||
}
|
}
|
||||||
// Populate the inactive list with plugins that aren't activated
|
// Populate the inactive list with plugins that aren't activated
|
||||||
|
@ -400,7 +409,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
||||||
|
|
||||||
echo '<div class="alignleft actions">';
|
echo '<div class="alignleft actions">';
|
||||||
|
|
||||||
if ( ! $this->screen->in_admin( 'network' ) && 'recently_activated' === $status ) {
|
if ( 'recently_activated' == $status ) {
|
||||||
submit_button( __( 'Clear List' ), 'button', 'clear-recent-list', false );
|
submit_button( __( 'Clear List' ), 'button', 'clear-recent-list', false );
|
||||||
} elseif ( 'top' === $which && 'mustuse' === $status ) {
|
} elseif ( 'top' === $which && 'mustuse' === $status ) {
|
||||||
echo '<p>' . sprintf( __( 'Files in the <code>%s</code> directory are executed automatically.' ), str_replace( ABSPATH, '/', WPMU_PLUGIN_DIR ) ) . '</p>';
|
echo '<p>' . sprintf( __( 'Files in the <code>%s</code> directory are executed automatically.' ), str_replace( ABSPATH, '/', WPMU_PLUGIN_DIR ) ) . '</p>';
|
||||||
|
|
|
@ -71,8 +71,11 @@ case 'update':
|
||||||
if ( is_plugin_active($file) )
|
if ( is_plugin_active($file) )
|
||||||
deactivate_plugins($file, true);
|
deactivate_plugins($file, true);
|
||||||
|
|
||||||
if ( ! is_network_admin() )
|
if ( ! is_network_admin() ) {
|
||||||
update_option( 'recently_activated', array( $file => time() ) + (array) get_option( 'recently_activated' ) );
|
update_option( 'recently_activated', array( $file => time() ) + (array) get_option( 'recently_activated' ) );
|
||||||
|
} else {
|
||||||
|
update_site_option( 'recently_activated', array( $file => time() ) + (array) get_site_option( 'recently_activated' ) );
|
||||||
|
}
|
||||||
|
|
||||||
wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file=$file&liveupdate=1&scrollto=$scrollto&networkwide=" . $network_wide));
|
wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file=$file&liveupdate=1&scrollto=$scrollto&networkwide=" . $network_wide));
|
||||||
exit;
|
exit;
|
||||||
|
|
|
@ -54,6 +54,10 @@ if ( $action ) {
|
||||||
$recent = (array) get_option( 'recently_activated' );
|
$recent = (array) get_option( 'recently_activated' );
|
||||||
unset( $recent[ $plugin ] );
|
unset( $recent[ $plugin ] );
|
||||||
update_option( 'recently_activated', $recent );
|
update_option( 'recently_activated', $recent );
|
||||||
|
} else {
|
||||||
|
$recent = (array) get_site_option( 'recently_activated' );
|
||||||
|
unset( $recent[ $plugin ] );
|
||||||
|
update_site_option( 'recently_activated', $recent );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset($_GET['from']) && 'import' == $_GET['from'] ) {
|
if ( isset($_GET['from']) && 'import' == $_GET['from'] ) {
|
||||||
|
@ -96,9 +100,18 @@ if ( $action ) {
|
||||||
|
|
||||||
if ( ! is_network_admin() ) {
|
if ( ! is_network_admin() ) {
|
||||||
$recent = (array) get_option('recently_activated' );
|
$recent = (array) get_option('recently_activated' );
|
||||||
foreach ( $plugins as $plugin )
|
} else {
|
||||||
unset( $recent[ $plugin ] );
|
$recent = (array) get_site_option('recently_activated' );
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ( $plugins as $plugin ) {
|
||||||
|
unset( $recent[ $plugin ] );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! is_network_admin() ) {
|
||||||
update_option( 'recently_activated', $recent );
|
update_option( 'recently_activated', $recent );
|
||||||
|
} else {
|
||||||
|
update_site_option( 'recently_activated', $recent );
|
||||||
}
|
}
|
||||||
|
|
||||||
wp_redirect( self_admin_url("plugins.php?activate-multi=true&plugin_status=$status&paged=$page&s=$s") );
|
wp_redirect( self_admin_url("plugins.php?activate-multi=true&plugin_status=$status&paged=$page&s=$s") );
|
||||||
|
@ -165,8 +178,13 @@ if ( $action ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
deactivate_plugins( $plugin, false, is_network_admin() );
|
deactivate_plugins( $plugin, false, is_network_admin() );
|
||||||
if ( ! is_network_admin() )
|
|
||||||
|
if ( ! is_network_admin() ) {
|
||||||
update_option( 'recently_activated', array( $plugin => time() ) + (array) get_option( 'recently_activated' ) );
|
update_option( 'recently_activated', array( $plugin => time() ) + (array) get_option( 'recently_activated' ) );
|
||||||
|
} else {
|
||||||
|
update_site_option( 'recently_activated', array( $plugin => time() ) + (array) get_site_option( 'recently_activated' ) );
|
||||||
|
}
|
||||||
|
|
||||||
if ( headers_sent() )
|
if ( headers_sent() )
|
||||||
echo "<meta http-equiv='refresh' content='" . esc_attr( "0;url=plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s" ) . "' />";
|
echo "<meta http-equiv='refresh' content='" . esc_attr( "0;url=plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s" ) . "' />";
|
||||||
else
|
else
|
||||||
|
@ -194,11 +212,15 @@ if ( $action ) {
|
||||||
|
|
||||||
deactivate_plugins( $plugins, false, is_network_admin() );
|
deactivate_plugins( $plugins, false, is_network_admin() );
|
||||||
|
|
||||||
|
$deactivated = array();
|
||||||
|
foreach ( $plugins as $plugin ) {
|
||||||
|
$deactivated[ $plugin ] = time();
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! is_network_admin() ) {
|
if ( ! is_network_admin() ) {
|
||||||
$deactivated = array();
|
|
||||||
foreach ( $plugins as $plugin )
|
|
||||||
$deactivated[ $plugin ] = time();
|
|
||||||
update_option( 'recently_activated', $deactivated + (array) get_option( 'recently_activated' ) );
|
update_option( 'recently_activated', $deactivated + (array) get_option( 'recently_activated' ) );
|
||||||
|
} else {
|
||||||
|
update_site_option( 'recently_activated', $deactivated + (array) get_site_option( 'recently_activated' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
wp_redirect( self_admin_url("plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page&s=$s") );
|
wp_redirect( self_admin_url("plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page&s=$s") );
|
||||||
|
@ -354,8 +376,11 @@ if ( $action ) {
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
case 'clear-recent-list':
|
case 'clear-recent-list':
|
||||||
if ( ! is_network_admin() )
|
if ( ! is_network_admin() ) {
|
||||||
update_option( 'recently_activated', array() );
|
update_option( 'recently_activated', array() );
|
||||||
|
} else {
|
||||||
|
update_site_option( 'recently_activated', array() );
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.4-alpha-34550';
|
$wp_version = '4.4-alpha-34551';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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