From 541b88a09605c7ad4f3a5433ef8be8dddb13ab95 Mon Sep 17 00:00:00 2001 From: nacin Date: Mon, 1 Nov 2010 20:08:25 +0000 Subject: [PATCH] Add theme updates to the network themes screen. props PeteMall, see #14897. git-svn-id: http://svn.automattic.com/wordpress/trunk@16141 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/update.php | 37 ++++++++++++++++++++++++++++++++++++ wp-admin/network/themes.php | 1 + 2 files changed, 38 insertions(+) diff --git a/wp-admin/includes/update.php b/wp-admin/includes/update.php index 320d90019..396211323 100644 --- a/wp-admin/includes/update.php +++ b/wp-admin/includes/update.php @@ -241,6 +241,43 @@ function wp_update_theme($theme, $feedback = '') { return $upgrader->upgrade($theme); } +function wp_theme_update_rows() { + if ( !current_user_can('update_themes' ) ) + return; + + $themes = get_site_transient( 'update_themes' ); + if ( isset($themes->response) && is_array($themes->response) ) { + $themes = array_keys( $themes->response ); + + foreach( $themes as $theme ) { + add_action( "after_theme_row_$theme", 'wp_theme_update_row', 10, 2 ); + } + } +} +add_action( 'admin_init', 'wp_theme_update_rows' ); + +function wp_theme_update_row( $theme_key, $theme ) { + $current = get_site_transient( 'update_themes' ); + if ( !isset( $current->response[ $theme_key ] ) ) + return false; + $r = $current->response[ $theme_key ]; + $themes_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array()); + $theme_name = wp_kses( $theme['Name'], $themes_allowedtags ); + + $details_url = self_admin_url("theme-install.php?tab=theme-information&theme=$theme_key&TB_iframe=true&width=600&height=400"); + + echo '
'; + if ( ! current_user_can('update_themes') ) + printf( __('There is a new version of %1$s available. View version %4$s details.'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r->new_version ); + else if ( empty( $r['package'] ) ) + printf( __('There is a new version of %1$s available. View version %4$s details. Automatic upgrade is unavailable for this plugin.'), $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 upgrade 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) ); + + do_action( "in_theme_update_message-$theme_key", $theme, $r ); + + echo '
'; +} function wp_update_core($current, $feedback = '') { if ( !empty($feedback) ) diff --git a/wp-admin/network/themes.php b/wp-admin/network/themes.php index 9beaaaa67..db96add70 100644 --- a/wp-admin/network/themes.php +++ b/wp-admin/network/themes.php @@ -64,6 +64,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) );