wp/wp-admin/update.php
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
     4  *
     4  *
     5  * @package WordPress
     5  * @package WordPress
     6  * @subpackage Administration
     6  * @subpackage Administration
     7  */
     7  */
     8 
     8 
     9 if ( ! defined( 'IFRAME_REQUEST' ) && isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'update-selected', 'activate-plugin', 'update-selected-themes' ) ) )
     9 if ( ! defined( 'IFRAME_REQUEST' ) && isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'update-selected', 'activate-plugin', 'update-selected-themes' ) ) ) {
    10 	define( 'IFRAME_REQUEST', true );
    10 	define( 'IFRAME_REQUEST', true );
       
    11 }
    11 
    12 
    12 /** WordPress Administration Bootstrap */
    13 /** WordPress Administration Bootstrap */
    13 require_once( dirname( __FILE__ ) . '/admin.php' );
    14 require_once( dirname( __FILE__ ) . '/admin.php' );
    14 
    15 
    15 include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
    16 include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
    16 
    17 
    17 if ( isset($_GET['action']) ) {
    18 if ( isset( $_GET['action'] ) ) {
    18 	$plugin = isset($_REQUEST['plugin']) ? trim($_REQUEST['plugin']) : '';
    19 	$plugin = isset( $_REQUEST['plugin'] ) ? trim( $_REQUEST['plugin'] ) : '';
    19 	$theme = isset($_REQUEST['theme']) ? urldecode($_REQUEST['theme']) : '';
    20 	$theme  = isset( $_REQUEST['theme'] ) ? urldecode( $_REQUEST['theme'] ) : '';
    20 	$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
    21 	$action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
    21 
    22 
    22 	if ( 'update-selected' == $action ) {
    23 	if ( 'update-selected' == $action ) {
    23 		if ( ! current_user_can( 'update_plugins' ) )
    24 		if ( ! current_user_can( 'update_plugins' ) ) {
    24 			wp_die( __( 'Sorry, you are not allowed to update plugins for this site.' ) );
    25 			wp_die( __( 'Sorry, you are not allowed to update plugins for this site.' ) );
       
    26 		}
    25 
    27 
    26 		check_admin_referer( 'bulk-update-plugins' );
    28 		check_admin_referer( 'bulk-update-plugins' );
    27 
    29 
    28 		if ( isset( $_GET['plugins'] ) )
    30 		if ( isset( $_GET['plugins'] ) ) {
    29 			$plugins = explode( ',', stripslashes($_GET['plugins']) );
    31 			$plugins = explode( ',', stripslashes( $_GET['plugins'] ) );
    30 		elseif ( isset( $_POST['checked'] ) )
    32 		} elseif ( isset( $_POST['checked'] ) ) {
    31 			$plugins = (array) $_POST['checked'];
    33 			$plugins = (array) $_POST['checked'];
    32 		else
    34 		} else {
    33 			$plugins = array();
    35 			$plugins = array();
    34 
    36 		}
    35 		$plugins = array_map('urldecode', $plugins);
    37 
    36 
    38 		$plugins = array_map( 'urldecode', $plugins );
    37 		$url = 'update.php?action=update-selected&plugins=' . urlencode(implode(',', $plugins));
    39 
       
    40 		$url   = 'update.php?action=update-selected&plugins=' . urlencode( implode( ',', $plugins ) );
    38 		$nonce = 'bulk-update-plugins';
    41 		$nonce = 'bulk-update-plugins';
    39 
    42 
    40 		wp_enqueue_script( 'updates' );
    43 		wp_enqueue_script( 'updates' );
    41 		iframe_header();
    44 		iframe_header();
    42 
    45 
    44 		$upgrader->bulk_upgrade( $plugins );
    47 		$upgrader->bulk_upgrade( $plugins );
    45 
    48 
    46 		iframe_footer();
    49 		iframe_footer();
    47 
    50 
    48 	} elseif ( 'upgrade-plugin' == $action ) {
    51 	} elseif ( 'upgrade-plugin' == $action ) {
    49 		if ( ! current_user_can('update_plugins') )
    52 		if ( ! current_user_can( 'update_plugins' ) ) {
    50 			wp_die(__('Sorry, you are not allowed to update plugins for this site.'));
    53 			wp_die( __( 'Sorry, you are not allowed to update plugins for this site.' ) );
    51 
    54 		}
    52 		check_admin_referer('upgrade-plugin_' . $plugin);
    55 
    53 
    56 		check_admin_referer( 'upgrade-plugin_' . $plugin );
    54 		$title = __('Update Plugin');
    57 
    55 		$parent_file = 'plugins.php';
    58 		$title        = __( 'Update Plugin' );
       
    59 		$parent_file  = 'plugins.php';
    56 		$submenu_file = 'plugins.php';
    60 		$submenu_file = 'plugins.php';
    57 
    61 
    58 		wp_enqueue_script( 'updates' );
    62 		wp_enqueue_script( 'updates' );
    59 		require_once(ABSPATH . 'wp-admin/admin-header.php');
    63 		require_once( ABSPATH . 'wp-admin/admin-header.php' );
    60 
    64 
    61 		$nonce = 'upgrade-plugin_' . $plugin;
    65 		$nonce = 'upgrade-plugin_' . $plugin;
    62 		$url = 'update.php?action=upgrade-plugin&plugin=' . urlencode( $plugin );
    66 		$url   = 'update.php?action=upgrade-plugin&plugin=' . urlencode( $plugin );
    63 
    67 
    64 		$upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact('title', 'nonce', 'url', 'plugin') ) );
    68 		$upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'plugin' ) ) );
    65 		$upgrader->upgrade($plugin);
    69 		$upgrader->upgrade( $plugin );
    66 
    70 
    67 		include(ABSPATH . 'wp-admin/admin-footer.php');
    71 		include( ABSPATH . 'wp-admin/admin-footer.php' );
    68 
    72 
    69 	} elseif ('activate-plugin' == $action ) {
    73 	} elseif ( 'activate-plugin' == $action ) {
    70 		if ( ! current_user_can('update_plugins') )
    74 		if ( ! current_user_can( 'update_plugins' ) ) {
    71 			wp_die(__('Sorry, you are not allowed to update plugins for this site.'));
    75 			wp_die( __( 'Sorry, you are not allowed to update plugins for this site.' ) );
    72 
    76 		}
    73 		check_admin_referer('activate-plugin_' . $plugin);
    77 
    74 		if ( ! isset($_GET['failure']) && ! isset($_GET['success']) ) {
    78 		check_admin_referer( 'activate-plugin_' . $plugin );
    75 			wp_redirect( admin_url('update.php?action=activate-plugin&failure=true&plugin=' . urlencode( $plugin ) . '&_wpnonce=' . $_GET['_wpnonce']) );
    79 		if ( ! isset( $_GET['failure'] ) && ! isset( $_GET['success'] ) ) {
       
    80 			wp_redirect( admin_url( 'update.php?action=activate-plugin&failure=true&plugin=' . urlencode( $plugin ) . '&_wpnonce=' . $_GET['_wpnonce'] ) );
    76 			activate_plugin( $plugin, '', ! empty( $_GET['networkwide'] ), true );
    81 			activate_plugin( $plugin, '', ! empty( $_GET['networkwide'] ), true );
    77 			wp_redirect( admin_url('update.php?action=activate-plugin&success=true&plugin=' . urlencode( $plugin ) . '&_wpnonce=' . $_GET['_wpnonce']) );
    82 			wp_redirect( admin_url( 'update.php?action=activate-plugin&success=true&plugin=' . urlencode( $plugin ) . '&_wpnonce=' . $_GET['_wpnonce'] ) );
    78 			die();
    83 			die();
    79 		}
    84 		}
    80 		iframe_header( __('Plugin Reactivation'), true );
    85 		iframe_header( __( 'Plugin Reactivation' ), true );
    81 		if ( isset($_GET['success']) )
    86 		if ( isset( $_GET['success'] ) ) {
    82 			echo '<p>' . __('Plugin reactivated successfully.') . '</p>';
    87 			echo '<p>' . __( 'Plugin reactivated successfully.' ) . '</p>';
    83 
    88 		}
    84 		if ( isset($_GET['failure']) ){
    89 
    85 			echo '<p>' . __('Plugin failed to reactivate due to a fatal error.') . '</p>';
    90 		if ( isset( $_GET['failure'] ) ) {
       
    91 			echo '<p>' . __( 'Plugin failed to reactivate due to a fatal error.' ) . '</p>';
    86 
    92 
    87 			error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
    93 			error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
    88 			@ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
    94 			@ini_set( 'display_errors', true ); //Ensure that Fatal errors are displayed.
    89 			wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin );
    95 			wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin );
    90 			include( WP_PLUGIN_DIR . '/' . $plugin );
    96 			include( WP_PLUGIN_DIR . '/' . $plugin );
    91 		}
    97 		}
    92 		iframe_footer();
    98 		iframe_footer();
    93 	} elseif ( 'install-plugin' == $action ) {
    99 	} elseif ( 'install-plugin' == $action ) {
    94 
   100 
    95 		if ( ! current_user_can('install_plugins') )
   101 		if ( ! current_user_can( 'install_plugins' ) ) {
    96 			wp_die( __( 'Sorry, you are not allowed to install plugins on this site.' ) );
   102 			wp_die( __( 'Sorry, you are not allowed to install plugins on this site.' ) );
       
   103 		}
    97 
   104 
    98 		include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
   105 		include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
    99 
   106 
   100 		check_admin_referer( 'install-plugin_' . $plugin );
   107 		check_admin_referer( 'install-plugin_' . $plugin );
   101 		$api = plugins_api( 'plugin_information', array(
   108 		$api = plugins_api(
   102 			'slug' => $plugin,
   109 			'plugin_information',
   103 			'fields' => array(
   110 			array(
   104 				'short_description' => false,
   111 				'slug'   => $plugin,
   105 				'sections' => false,
   112 				'fields' => array(
   106 				'requires' => false,
   113 					'sections' => false,
   107 				'rating' => false,
   114 				),
   108 				'ratings' => false,
   115 			)
   109 				'downloaded' => false,
   116 		);
   110 				'last_updated' => false,
       
   111 				'added' => false,
       
   112 				'tags' => false,
       
   113 				'compatibility' => false,
       
   114 				'homepage' => false,
       
   115 				'donate_link' => false,
       
   116 			),
       
   117 		) );
       
   118 
   117 
   119 		if ( is_wp_error( $api ) ) {
   118 		if ( is_wp_error( $api ) ) {
   120 	 		wp_die( $api );
   119 			wp_die( $api );
   121 		}
   120 		}
   122 
   121 
   123 		$title = __('Plugin Installation');
   122 		$title        = __( 'Plugin Installation' );
   124 		$parent_file = 'plugins.php';
   123 		$parent_file  = 'plugins.php';
   125 		$submenu_file = 'plugin-install.php';
   124 		$submenu_file = 'plugin-install.php';
   126 		require_once(ABSPATH . 'wp-admin/admin-header.php');
   125 		require_once( ABSPATH . 'wp-admin/admin-header.php' );
   127 
   126 
   128 		$title = sprintf( __('Installing Plugin: %s'), $api->name . ' ' . $api->version );
   127 		$title = sprintf( __( 'Installing Plugin: %s' ), $api->name . ' ' . $api->version );
   129 		$nonce = 'install-plugin_' . $plugin;
   128 		$nonce = 'install-plugin_' . $plugin;
   130 		$url = 'update.php?action=install-plugin&plugin=' . urlencode( $plugin );
   129 		$url   = 'update.php?action=install-plugin&plugin=' . urlencode( $plugin );
   131 		if ( isset($_GET['from']) )
   130 		if ( isset( $_GET['from'] ) ) {
   132 			$url .= '&from=' . urlencode(stripslashes($_GET['from']));
   131 			$url .= '&from=' . urlencode( stripslashes( $_GET['from'] ) );
       
   132 		}
   133 
   133 
   134 		$type = 'web'; //Install plugin type, From Web or an Upload.
   134 		$type = 'web'; //Install plugin type, From Web or an Upload.
   135 
   135 
   136 		$upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) );
   136 		$upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact( 'title', 'url', 'nonce', 'plugin', 'api' ) ) );
   137 		$upgrader->install($api->download_link);
   137 		$upgrader->install( $api->download_link );
   138 
   138 
   139 		include(ABSPATH . 'wp-admin/admin-footer.php');
   139 		include( ABSPATH . 'wp-admin/admin-footer.php' );
   140 
   140 
   141 	} elseif ( 'upload-plugin' == $action ) {
   141 	} elseif ( 'upload-plugin' == $action ) {
   142 
   142 
   143 		if ( ! current_user_can( 'upload_plugins' ) ) {
   143 		if ( ! current_user_can( 'upload_plugins' ) ) {
   144 			wp_die( __( 'Sorry, you are not allowed to install plugins on this site.' ) );
   144 			wp_die( __( 'Sorry, you are not allowed to install plugins on this site.' ) );
   145 		}
   145 		}
   146 
   146 
   147 		check_admin_referer('plugin-upload');
   147 		check_admin_referer( 'plugin-upload' );
   148 
   148 
   149 		$file_upload = new File_Upload_Upgrader('pluginzip', 'package');
   149 		$file_upload = new File_Upload_Upgrader( 'pluginzip', 'package' );
   150 
   150 
   151 		$title = __('Upload Plugin');
   151 		$title        = __( 'Upload Plugin' );
   152 		$parent_file = 'plugins.php';
   152 		$parent_file  = 'plugins.php';
   153 		$submenu_file = 'plugin-install.php';
   153 		$submenu_file = 'plugin-install.php';
   154 		require_once(ABSPATH . 'wp-admin/admin-header.php');
   154 		require_once( ABSPATH . 'wp-admin/admin-header.php' );
   155 
   155 
   156 		$title = sprintf( __('Installing Plugin from uploaded file: %s'), esc_html( basename( $file_upload->filename ) ) );
   156 		$title = sprintf( __( 'Installing Plugin from uploaded file: %s' ), esc_html( basename( $file_upload->filename ) ) );
   157 		$nonce = 'plugin-upload';
   157 		$nonce = 'plugin-upload';
   158 		$url = add_query_arg(array('package' => $file_upload->id), 'update.php?action=upload-plugin');
   158 		$url   = add_query_arg( array( 'package' => $file_upload->id ), 'update.php?action=upload-plugin' );
   159 		$type = 'upload'; //Install plugin type, From Web or an Upload.
   159 		$type  = 'upload'; //Install plugin type, From Web or an Upload.
   160 
   160 
   161 		$upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact('type', 'title', 'nonce', 'url') ) );
   161 		$upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact( 'type', 'title', 'nonce', 'url' ) ) );
   162 		$result = $upgrader->install( $file_upload->package );
   162 		$result   = $upgrader->install( $file_upload->package );
   163 
   163 
   164 		if ( $result || is_wp_error($result) )
   164 		if ( $result || is_wp_error( $result ) ) {
   165 			$file_upload->cleanup();
   165 			$file_upload->cleanup();
   166 
   166 		}
   167 		include(ABSPATH . 'wp-admin/admin-footer.php');
   167 
       
   168 		include( ABSPATH . 'wp-admin/admin-footer.php' );
   168 
   169 
   169 	} elseif ( 'upgrade-theme' == $action ) {
   170 	} elseif ( 'upgrade-theme' == $action ) {
   170 
   171 
   171 		if ( ! current_user_can('update_themes') )
   172 		if ( ! current_user_can( 'update_themes' ) ) {
   172 			wp_die(__('Sorry, you are not allowed to update themes for this site.'));
   173 			wp_die( __( 'Sorry, you are not allowed to update themes for this site.' ) );
   173 
   174 		}
   174 		check_admin_referer('upgrade-theme_' . $theme);
   175 
       
   176 		check_admin_referer( 'upgrade-theme_' . $theme );
   175 
   177 
   176 		wp_enqueue_script( 'updates' );
   178 		wp_enqueue_script( 'updates' );
   177 
   179 
   178 		$title = __('Update Theme');
   180 		$title        = __( 'Update Theme' );
   179 		$parent_file = 'themes.php';
   181 		$parent_file  = 'themes.php';
   180 		$submenu_file = 'themes.php';
   182 		$submenu_file = 'themes.php';
   181 		require_once(ABSPATH . 'wp-admin/admin-header.php');
   183 		require_once( ABSPATH . 'wp-admin/admin-header.php' );
   182 
   184 
   183 		$nonce = 'upgrade-theme_' . $theme;
   185 		$nonce = 'upgrade-theme_' . $theme;
   184 		$url = 'update.php?action=upgrade-theme&theme=' . urlencode( $theme );
   186 		$url   = 'update.php?action=upgrade-theme&theme=' . urlencode( $theme );
   185 
   187 
   186 		$upgrader = new Theme_Upgrader( new Theme_Upgrader_Skin( compact('title', 'nonce', 'url', 'theme') ) );
   188 		$upgrader = new Theme_Upgrader( new Theme_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'theme' ) ) );
   187 		$upgrader->upgrade($theme);
   189 		$upgrader->upgrade( $theme );
   188 
   190 
   189 		include(ABSPATH . 'wp-admin/admin-footer.php');
   191 		include( ABSPATH . 'wp-admin/admin-footer.php' );
   190 	} elseif ( 'update-selected-themes' == $action ) {
   192 	} elseif ( 'update-selected-themes' == $action ) {
   191 		if ( ! current_user_can( 'update_themes' ) )
   193 		if ( ! current_user_can( 'update_themes' ) ) {
   192 			wp_die( __( 'Sorry, you are not allowed to update themes for this site.' ) );
   194 			wp_die( __( 'Sorry, you are not allowed to update themes for this site.' ) );
       
   195 		}
   193 
   196 
   194 		check_admin_referer( 'bulk-update-themes' );
   197 		check_admin_referer( 'bulk-update-themes' );
   195 
   198 
   196 		if ( isset( $_GET['themes'] ) )
   199 		if ( isset( $_GET['themes'] ) ) {
   197 			$themes = explode( ',', stripslashes($_GET['themes']) );
   200 			$themes = explode( ',', stripslashes( $_GET['themes'] ) );
   198 		elseif ( isset( $_POST['checked'] ) )
   201 		} elseif ( isset( $_POST['checked'] ) ) {
   199 			$themes = (array) $_POST['checked'];
   202 			$themes = (array) $_POST['checked'];
   200 		else
   203 		} else {
   201 			$themes = array();
   204 			$themes = array();
   202 
   205 		}
   203 		$themes = array_map('urldecode', $themes);
   206 
   204 
   207 		$themes = array_map( 'urldecode', $themes );
   205 		$url = 'update.php?action=update-selected-themes&amp;themes=' . urlencode(implode(',', $themes));
   208 
       
   209 		$url   = 'update.php?action=update-selected-themes&amp;themes=' . urlencode( implode( ',', $themes ) );
   206 		$nonce = 'bulk-update-themes';
   210 		$nonce = 'bulk-update-themes';
   207 
   211 
   208 		wp_enqueue_script( 'updates' );
   212 		wp_enqueue_script( 'updates' );
   209 		iframe_header();
   213 		iframe_header();
   210 
   214 
   212 		$upgrader->bulk_upgrade( $themes );
   216 		$upgrader->bulk_upgrade( $themes );
   213 
   217 
   214 		iframe_footer();
   218 		iframe_footer();
   215 	} elseif ( 'install-theme' == $action ) {
   219 	} elseif ( 'install-theme' == $action ) {
   216 
   220 
   217 		if ( ! current_user_can('install_themes') )
   221 		if ( ! current_user_can( 'install_themes' ) ) {
   218 			wp_die( __( 'Sorry, you are not allowed to install themes on this site.' ) );
   222 			wp_die( __( 'Sorry, you are not allowed to install themes on this site.' ) );
       
   223 		}
   219 
   224 
   220 		include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); //for themes_api..
   225 		include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); //for themes_api..
   221 
   226 
   222 		check_admin_referer( 'install-theme_' . $theme );
   227 		check_admin_referer( 'install-theme_' . $theme );
   223 		$api = themes_api('theme_information', array('slug' => $theme, 'fields' => array('sections' => false, 'tags' => false) ) ); //Save on a bit of bandwidth.
   228 		$api = themes_api(
       
   229 			'theme_information',
       
   230 			array(
       
   231 				'slug'   => $theme,
       
   232 				'fields' => array(
       
   233 					'sections' => false,
       
   234 					'tags'     => false,
       
   235 				),
       
   236 			)
       
   237 		); //Save on a bit of bandwidth.
   224 
   238 
   225 		if ( is_wp_error( $api ) ) {
   239 		if ( is_wp_error( $api ) ) {
   226 			wp_die( $api );
   240 			wp_die( $api );
   227 		}
   241 		}
   228 
   242 
   229 		$title = __('Install Themes');
   243 		$title        = __( 'Install Themes' );
   230 		$parent_file = 'themes.php';
   244 		$parent_file  = 'themes.php';
   231 		$submenu_file = 'themes.php';
   245 		$submenu_file = 'themes.php';
   232 		require_once(ABSPATH . 'wp-admin/admin-header.php');
   246 		require_once( ABSPATH . 'wp-admin/admin-header.php' );
   233 
   247 
   234 		$title = sprintf( __('Installing Theme: %s'), $api->name . ' ' . $api->version );
   248 		$title = sprintf( __( 'Installing Theme: %s' ), $api->name . ' ' . $api->version );
   235 		$nonce = 'install-theme_' . $theme;
   249 		$nonce = 'install-theme_' . $theme;
   236 		$url = 'update.php?action=install-theme&theme=' . urlencode( $theme );
   250 		$url   = 'update.php?action=install-theme&theme=' . urlencode( $theme );
   237 		$type = 'web'; //Install theme type, From Web or an Upload.
   251 		$type  = 'web'; //Install theme type, From Web or an Upload.
   238 
   252 
   239 		$upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) );
   253 		$upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact( 'title', 'url', 'nonce', 'plugin', 'api' ) ) );
   240 		$upgrader->install($api->download_link);
   254 		$upgrader->install( $api->download_link );
   241 
   255 
   242 		include(ABSPATH . 'wp-admin/admin-footer.php');
   256 		include( ABSPATH . 'wp-admin/admin-footer.php' );
   243 
   257 
   244 	} elseif ( 'upload-theme' == $action ) {
   258 	} elseif ( 'upload-theme' == $action ) {
   245 
   259 
   246 		if ( ! current_user_can( 'upload_themes' ) ) {
   260 		if ( ! current_user_can( 'upload_themes' ) ) {
   247 			wp_die( __( 'Sorry, you are not allowed to install themes on this site.' ) );
   261 			wp_die( __( 'Sorry, you are not allowed to install themes on this site.' ) );
   248 		}
   262 		}
   249 
   263 
   250 		check_admin_referer('theme-upload');
   264 		check_admin_referer( 'theme-upload' );
   251 
   265 
   252 		$file_upload = new File_Upload_Upgrader('themezip', 'package');
   266 		$file_upload = new File_Upload_Upgrader( 'themezip', 'package' );
   253 
   267 
   254 		$title = __('Upload Theme');
   268 		$title        = __( 'Upload Theme' );
   255 		$parent_file = 'themes.php';
   269 		$parent_file  = 'themes.php';
   256 		$submenu_file = 'theme-install.php';
   270 		$submenu_file = 'theme-install.php';
   257 
   271 
   258 		require_once(ABSPATH . 'wp-admin/admin-header.php');
   272 		require_once( ABSPATH . 'wp-admin/admin-header.php' );
   259 
   273 
   260 		$title = sprintf( __('Installing Theme from uploaded file: %s'), esc_html( basename( $file_upload->filename ) ) );
   274 		$title = sprintf( __( 'Installing Theme from uploaded file: %s' ), esc_html( basename( $file_upload->filename ) ) );
   261 		$nonce = 'theme-upload';
   275 		$nonce = 'theme-upload';
   262 		$url = add_query_arg(array('package' => $file_upload->id), 'update.php?action=upload-theme');
   276 		$url   = add_query_arg( array( 'package' => $file_upload->id ), 'update.php?action=upload-theme' );
   263 		$type = 'upload'; //Install plugin type, From Web or an Upload.
   277 		$type  = 'upload'; //Install plugin type, From Web or an Upload.
   264 
   278 
   265 		$upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact('type', 'title', 'nonce', 'url') ) );
   279 		$upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact( 'type', 'title', 'nonce', 'url' ) ) );
   266 		$result = $upgrader->install( $file_upload->package );
   280 		$result   = $upgrader->install( $file_upload->package );
   267 
   281 
   268 		if ( $result || is_wp_error($result) )
   282 		if ( $result || is_wp_error( $result ) ) {
   269 			$file_upload->cleanup();
   283 			$file_upload->cleanup();
   270 
   284 		}
   271 		include(ABSPATH . 'wp-admin/admin-footer.php');
   285 
       
   286 		include( ABSPATH . 'wp-admin/admin-footer.php' );
   272 
   287 
   273 	} else {
   288 	} else {
   274 		/**
   289 		/**
   275 		 * Fires when a custom plugin or theme update request is received.
   290 		 * Fires when a custom plugin or theme update request is received.
   276 		 *
   291 		 *