From b0788900917f612fe236d3c93a4bf81b0edab038 Mon Sep 17 00:00:00 2001 From: scribu Date: Thu, 4 Nov 2010 20:49:30 +0000 Subject: [PATCH] Fix screen options for the network admin themes and plugins. Props ocean90. Fixes #15269. Also fixes [16190] git-svn-id: http://svn.automattic.com/wordpress/trunk@16194 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../class-wp-ms-themes-list-table.php | 2 +- .../includes/class-wp-plugins-list-table.php | 32 ++++++++++--------- wp-admin/includes/misc.php | 7 ++-- wp-admin/network/themes.php | 2 +- wp-admin/plugins.php | 2 +- 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/wp-admin/includes/class-wp-ms-themes-list-table.php b/wp-admin/includes/class-wp-ms-themes-list-table.php index 6a5d5d8fc..f97456b84 100644 --- a/wp-admin/includes/class-wp-ms-themes-list-table.php +++ b/wp-admin/includes/class-wp-ms-themes-list-table.php @@ -95,7 +95,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table { uasort( $this->items, array( &$this, '_order_callback' ) ); } - $themes_per_page = $this->get_items_per_page( 'themes_per_page', 999 ); + $themes_per_page = $this->get_items_per_page( 'themes_network_per_page' ); $start = ( $page - 1 ) * $themes_per_page; diff --git a/wp-admin/includes/class-wp-plugins-list-table.php b/wp-admin/includes/class-wp-plugins-list-table.php index a54c7ac81..2607dafd1 100644 --- a/wp-admin/includes/class-wp-plugins-list-table.php +++ b/wp-admin/includes/class-wp-plugins-list-table.php @@ -20,6 +20,8 @@ class WP_Plugins_List_Table extends WP_List_Table { if ( $status != $default_status && 'search' != $status ) update_user_meta( get_current_user_id(), 'plugins_last_view', $status ); + $page = $this->get_pagenum(); + parent::WP_List_Table( array( 'plural' => 'plugins', ) ); @@ -55,7 +57,7 @@ class WP_Plugins_List_Table extends WP_List_Table { 'dropins' => array() ); - if ( ! is_multisite() || ( is_network_admin() && current_user_can('manage_network_plugins') ) ) { + if ( ! is_multisite() || ( $this->_screen->is_network && current_user_can('manage_network_plugins') ) ) { if ( apply_filters( 'show_advanced_plugins', true, 'mustuse' ) ) $plugins['mustuse'] = get_mu_plugins(); if ( apply_filters( 'show_advanced_plugins', true, 'dropins' ) ) @@ -83,16 +85,16 @@ class WP_Plugins_List_Table extends WP_List_Table { foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) { // Filter into individual sections - if ( is_plugin_active_for_network($plugin_file) && !is_network_admin() ) { + if ( is_plugin_active_for_network($plugin_file) && !$this->_screen->is_network ) { unset( $plugins['all'][ $plugin_file ] ); continue; } elseif ( is_multisite() && is_network_only_plugin( $plugin_file ) && !current_user_can( 'manage_network_plugins' ) ) { $plugins['network'][ $plugin_file ] = $plugin_data; - } elseif ( ( !is_network_admin() && is_plugin_active( $plugin_file ) ) - || ( is_network_admin() && is_plugin_active_for_network( $plugin_file ) ) ) { + } elseif ( ( !$this->_screen->is_network && is_plugin_active( $plugin_file ) ) + || ( $this->_screen->is_network && is_plugin_active_for_network( $plugin_file ) ) ) { $plugins['active'][ $plugin_file ] = $plugin_data; } else { - if ( !is_network_admin() && isset( $recently_activated[ $plugin_file ] ) ) // Was the plugin recently activated? + if ( !$this->_screen->is_network && isset( $recently_activated[ $plugin_file ] ) ) // Was the plugin recently activated? $plugins['recently_activated'][ $plugin_file ] = $plugin_data; $plugins['inactive'][ $plugin_file ] = $plugin_data; } @@ -126,7 +128,7 @@ class WP_Plugins_List_Table extends WP_List_Table { uasort( $this->items, array( &$this, '_order_callback' ) ); } - $plugins_per_page = $this->get_items_per_page( 'plugins_per_page', 999 ); + $plugins_per_page = $this->get_items_per_page( str_replace( '-', '_', "{$this->_screen->id}_per_page" ) ); $start = ( $page - 1 ) * $plugins_per_page; @@ -252,14 +254,14 @@ class WP_Plugins_List_Table extends WP_List_Table { $actions = array(); if ( 'active' != $status ) { - $action = is_network_admin() ? 'network-activate-selected' : 'activate-selected'; + $action = $this->_screen->is_network ? 'network-activate-selected' : 'activate-selected'; $actions[ $action ] = __( 'Activate' ); } if ( 'inactive' != $status && 'recent' != $status ) $actions['deactivate-selected'] = __( 'Deactivate' ); - if ( !is_multisite() || is_network_admin() ) { + if ( !is_multisite() || $this->_screen->is_network ) { if ( current_user_can( 'update_plugins' ) ) $actions['update-selected'] = __( 'Update' ); if ( current_user_can( 'delete_plugins' ) && ( 'active' != $status ) ) @@ -311,11 +313,11 @@ class WP_Plugins_List_Table extends WP_List_Table { ); if ( 'mustuse' == $context ) { - if ( is_multisite() && !is_network_admin() ) + if ( is_multisite() && !$this->_screen->is_network ) continue; $is_active = true; } elseif ( 'dropins' == $context ) { - if ( is_multisite() && !is_network_admin() ) + if ( is_multisite() && !$this->_screen->is_network ) continue; $dropins = _get_dropins(); $plugin_name = $plugin_file; @@ -335,15 +337,15 @@ class WP_Plugins_List_Table extends WP_List_Table { $description .= '

' . $plugin_data['Description'] . '

'; } else { $is_active_for_network = is_plugin_active_for_network($plugin_file); - if ( is_network_admin() ) + if ( $this->_screen->is_network ) $is_active = $is_active_for_network; else $is_active = is_plugin_active( $plugin_file ); - if ( $is_active_for_network && !is_super_admin() && !is_network_admin() ) + if ( $is_active_for_network && !is_super_admin() && !$this->_screen->is_network ) continue; - if ( is_network_admin() ) { + if ( $this->_screen->is_network ) { if ( $is_active_for_network ) { if ( current_user_can( 'manage_network_plugins' ) ) $actions['network_deactivate'] = '' . __('Network Deactivate') . ''; @@ -357,7 +359,7 @@ class WP_Plugins_List_Table extends WP_List_Table { if ( $is_active ) { $actions['deactivate'] = '' . __('Deactivate') . ''; } else { - if ( is_network_only_plugin( $plugin_file ) && !is_network_admin() ) + if ( is_network_only_plugin( $plugin_file ) && !$this->_screen->is_network ) continue; $actions['activate'] = '' . __('Activate') . ''; @@ -365,7 +367,7 @@ class WP_Plugins_List_Table extends WP_List_Table { if ( ! is_multisite() && current_user_can('delete_plugins') ) $actions['delete'] = '' . __('Delete') . ''; } // end if $is_active - } // end if is_network_admin() + } // end if $this->_screen->is_network if ( current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) ) $actions['edit'] = '' . __('Edit') . ''; diff --git a/wp-admin/includes/misc.php b/wp-admin/includes/misc.php index 133ecdbe2..0f9ac032e 100644 --- a/wp-admin/includes/misc.php +++ b/wp-admin/includes/misc.php @@ -343,13 +343,16 @@ function set_screen_options() { switch ( $map_option ) { case 'edit_per_page': - case 'sites_network_per_page': case 'users_per_page': - case 'users_network_per_page': case 'edit_comments_per_page': case 'upload_per_page': case 'edit_tags_per_page': case 'plugins_per_page': + // Network admin + case 'sites_network_per_page': + case 'users_network_per_page': + case 'plugins_network_per_page': + case 'themes_network_per_page': $value = (int) $value; if ( $value < 1 || $value > 999 ) return; diff --git a/wp-admin/network/themes.php b/wp-admin/network/themes.php index 301412662..2d11663d4 100644 --- a/wp-admin/network/themes.php +++ b/wp-admin/network/themes.php @@ -60,7 +60,7 @@ if ( $action ) { $wp_list_table->prepare_items(); add_thickbox(); -add_screen_option( 'per_page', array('label' => _x( 'Themes', 'themes per page (screen options)' ), 'default' => 999) ); +add_screen_option( 'per_page', array('label' => _x( 'Themes', 'themes per page (screen options)' )) ); add_contextual_help($current_screen, '

' . __('This screen enables and disables the inclusion of themes available to choose in the Appearance menu for each site. It does not activate or deactivate which theme a site is currently using.') . '

' . diff --git a/wp-admin/plugins.php b/wp-admin/plugins.php index e4b48b0e2..d22ea0cbf 100644 --- a/wp-admin/plugins.php +++ b/wp-admin/plugins.php @@ -296,7 +296,7 @@ $wp_list_table->prepare_items(); wp_enqueue_script('plugin-install'); add_thickbox(); -add_screen_option( 'per_page', array('label' => _x( 'Plugins', 'plugins per page (screen options)' ), 'default' => 999) ); +add_screen_option( 'per_page', array('label' => _x( 'Plugins', 'plugins per page (screen options)' )) ); add_contextual_help($current_screen, '

' . __('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.') . '

' .