From 29bc67a9897f682a9eaa5775d06c580c44e80b62 Mon Sep 17 00:00:00 2001 From: nacin Date: Wed, 21 Mar 2012 16:19:27 +0000 Subject: [PATCH] Visually merge a plugin with its update notice. Same applies to themes in the network admin. Move from 'update automatically' to 'update now'. fixes #20273. git-svn-id: http://svn.automattic.com/wordpress/trunk@20236 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/css/wp-admin.dev.css | 19 +++++++++++++++++-- .../class-wp-ms-themes-list-table.php | 15 ++++++++++----- .../includes/class-wp-plugins-list-table.php | 19 +++++++++++-------- wp-admin/includes/theme.php | 2 +- wp-admin/includes/update.php | 4 ++-- 5 files changed, 41 insertions(+), 18 deletions(-) diff --git a/wp-admin/css/wp-admin.dev.css b/wp-admin/css/wp-admin.dev.css index 12280219b..6594b0b42 100644 --- a/wp-admin/css/wp-admin.dev.css +++ b/wp-admin/css/wp-admin.dev.css @@ -4425,15 +4425,30 @@ input.button-highlighted, padding: 5px 7px 0; } -#wpbody-content .plugins .plugin-title, #wpbody-content .plugins .theme-title { +.plugins .update th, +.plugins .update td { + border-bottom: 0; +} +.plugin-update-tr td { + border-top: 0; +} + +#wpbody-content .plugins .plugin-title, +#wpbody-content .plugins .theme-title { padding-right: 12px; white-space:nowrap; } -.plugins .second, .plugins .row-actions-visible { +.plugins .second, +.plugins .row-actions-visible { padding: 0 0 5px; } +.plugins .update .second, +.plugins .update .row-actions-visible { + padding-bottom: 0; +} + .plugins-php .widefat tfoot th, .plugins-php .widefat tfoot td { border-top-style: solid; 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 84360a462..9fc3251d7 100644 --- a/wp-admin/includes/class-wp-ms-themes-list-table.php +++ b/wp-admin/includes/class-wp-ms-themes-list-table.php @@ -71,7 +71,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table { $allowed_where = 'network'; } - $maybe_update = current_user_can( 'update_themes' ) && ! $this->is_site_themes && get_site_transient( 'update_themes' ); + $maybe_update = current_user_can( 'update_themes' ) && ! $this->is_site_themes && $current = get_site_transient( 'update_themes' ); foreach ( (array) $themes['all'] as $key => $theme ) { if ( $this->is_site_themes && $theme->is_allowed( 'network' ) ) { @@ -79,11 +79,13 @@ class WP_MS_Themes_List_Table extends WP_List_Table { continue; } + if ( $maybe_update && isset( $current->response[ $key ] ) ) { + $themes['all'][ $key ]->update = true; + $themes['upgrade'][ $key ] = $themes['all'][ $key ]; + } + $filter = $theme->is_allowed( $allowed_where, $this->site_id ) ? 'enabled' : 'disabled'; $themes[ $filter ][ $key ] = $themes['all'][ $key ]; - - if ( $maybe_update && isset( $current->response[ $key ] ) ) - $themes['upgrade'][ $key ] = $themes['all'][ $key ]; } if ( $s ) { @@ -261,7 +263,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table { } function single_row( $key, $theme ) { - global $status, $page, $s; + global $status, $page, $s, $totals; $context = $status; @@ -305,6 +307,9 @@ class WP_MS_Themes_List_Table extends WP_List_Table { $id = sanitize_html_class( $theme->get_stylesheet() ); + if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) ) + $class .= ' update'; + echo ""; list( $columns, $hidden ) = $this->get_column_info(); diff --git a/wp-admin/includes/class-wp-plugins-list-table.php b/wp-admin/includes/class-wp-plugins-list-table.php index 84e0f7466..01fcaeb21 100644 --- a/wp-admin/includes/class-wp-plugins-list-table.php +++ b/wp-admin/includes/class-wp-plugins-list-table.php @@ -65,10 +65,14 @@ class WP_Plugins_List_Table extends WP_List_Table { if ( apply_filters( 'show_advanced_plugins', true, 'dropins' ) ) $plugins['dropins'] = get_dropins(); - $current = get_site_transient( 'update_plugins' ); - foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) { - if ( isset( $current->response[ $plugin_file ] ) ) - $plugins['upgrade'][ $plugin_file ] = $plugin_data; + if ( current_user_can( 'update_plugins' ) ) { + $current = get_site_transient( 'update_plugins' ); + foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) { + if ( isset( $current->response[ $plugin_file ] ) ) { + $plugins['all'][ $plugin_file ]['update'] = true; + $plugins['upgrade'][ $plugin_file ] = $plugins['all'][ $plugin_file ]; + } + } } } @@ -100,9 +104,6 @@ class WP_Plugins_List_Table extends WP_List_Table { } } - if ( !current_user_can( 'update_plugins' ) ) - $plugins['upgrade'] = array(); - if ( $s ) { $status = 'search'; $plugins['search'] = array_filter( $plugins['all'], array( &$this, '_search_callback' ) ); @@ -312,7 +313,7 @@ class WP_Plugins_List_Table extends WP_List_Table { } function single_row( $plugin_file, $plugin_data ) { - global $status, $page, $s; + global $status, $page, $s, $totals; $context = $status; @@ -394,6 +395,8 @@ class WP_Plugins_List_Table extends WP_List_Table { } $id = sanitize_title( $plugin_name ); + if ( ! empty( $totals['upgrade'] ) && ! empty( $plugin_data['update'] ) ) + $class .= ' update'; echo ""; diff --git a/wp-admin/includes/theme.php b/wp-admin/includes/theme.php index 4ac66c1f5..d66c2ab58 100644 --- a/wp-admin/includes/theme.php +++ b/wp-admin/includes/theme.php @@ -135,7 +135,7 @@ function theme_update_available( $theme ) { else if ( empty($update['package']) ) printf( '

' . __('There is a new version of %1$s available. View version %3$s details. Automatic update is unavailable for this theme.') . '

', $theme_name, $details_url, $update['new_version']); else - printf( '

' . __('There is a new version of %1$s available. View version %3$s details or update automatically.') . '

', $theme_name, $details_url, $update['new_version'], $update_url, $update_onclick ); + printf( '

' . __('There is a new version of %1$s available. View version %3$s details or update now.') . '

', $theme_name, $details_url, $update['new_version'], $update_url, $update_onclick ); } } } diff --git a/wp-admin/includes/update.php b/wp-admin/includes/update.php index c69c3c0a4..c1ffd3c30 100644 --- a/wp-admin/includes/update.php +++ b/wp-admin/includes/update.php @@ -199,7 +199,7 @@ function wp_plugin_update_row( $file, $plugin_data ) { else if ( empty($r->package) ) printf( __('There is a new version of %1$s available. View version %4$s details. Automatic update is unavailable for this plugin.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version ); else - printf( __('There is a new version of %1$s available. View version %4$s details or update automatically.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version, wp_nonce_url( self_admin_url('update.php?action=upgrade-plugin&plugin=') . $file, 'upgrade-plugin_' . $file) ); + printf( __('There is a new version of %1$s available. View version %4$s details or update now.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version, wp_nonce_url( self_admin_url('update.php?action=upgrade-plugin&plugin=') . $file, 'upgrade-plugin_' . $file) ); do_action( "in_plugin_update_message-$file", $plugin_data, $r ); @@ -271,7 +271,7 @@ function wp_theme_update_row( $theme_key, $theme ) { else if ( empty( $r['package'] ) ) printf( __('There is a new version of %1$s available. View version %4$s details. Automatic update is unavailable for this theme.'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r['new_version'] ); else - printf( __('There is a new version of %1$s available. View version %4$s details or update automatically.'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r['new_version'], wp_nonce_url( self_admin_url('update.php?action=upgrade-theme&theme=') . $theme_key, 'upgrade-theme_' . $theme_key) ); + printf( __('There is a new version of %1$s available. View version %4$s details or update now.'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r['new_version'], wp_nonce_url( self_admin_url('update.php?action=upgrade-theme&theme=') . $theme_key, 'upgrade-theme_' . $theme_key) ); do_action( "in_theme_update_message-$theme_key", $theme, $r );