-
+ 7E582A66F9A4C19CB30A1B1C62C2D3E546A4022BB66712D13DD21A4C54103E6868F07D538B4688868DB221DB18FD654F7F7773C0B2EAD0CB5FA8E19F2F0DF9C3
mp-wp/wp-admin/update.php
(0 . 0)(1 . 166)
58280 <?php
58281 /**
58282 * Update Plugin/Theme administration panel.
58283 *
58284 * @package WordPress
58285 * @subpackage Administration
58286 */
58287
58288 /** WordPress Administration Bootstrap */
58289 require_once('admin.php');
58290
58291 if ( ! current_user_can('update_plugins') )
58292 wp_die(__('You do not have sufficient permissions to update plugins for this blog.'));
58293
58294 /**
58295 * Plugin upgrade display.
58296 *
58297 * @since 2.5
58298 *
58299 * @param string $plugin Plugin
58300 */
58301 function do_plugin_upgrade($plugin) {
58302 global $wp_filesystem;
58303
58304 $url = wp_nonce_url("update.php?action=upgrade-plugin&plugin=$plugin", "upgrade-plugin_$plugin");
58305 if ( false === ($credentials = request_filesystem_credentials($url)) )
58306 return;
58307
58308 if ( ! WP_Filesystem($credentials) ) {
58309 $error = true;
58310 if ( is_object($wp_filesystem) && $wp_filesystem->errors->get_error_code() )
58311 $error = $wp_filesystem->errors;
58312 request_filesystem_credentials($url, '', $error); //Failed to connect, Error and request again
58313 return;
58314 }
58315
58316 echo '<div class="wrap">';
58317 echo '<h2>' . __('Upgrade Plugin') . '</h2>';
58318 if ( $wp_filesystem->errors->get_error_code() ) {
58319 foreach ( $wp_filesystem->errors->get_error_messages() as $message )
58320 show_message($message);
58321 echo '</div>';
58322 return;
58323 }
58324
58325 $was_activated = is_plugin_active($plugin); //Check now, It'll be deactivated by the next line if it is
58326
58327 $result = wp_update_plugin($plugin, 'show_message');
58328
58329 if ( is_wp_error($result) ) {
58330 show_message($result);
58331 show_message( __('Plugin upgrade Failed') );
58332 } else {
58333 $plugin_file = $result;
58334 show_message( __('Plugin upgraded successfully') );
58335 if( $result && $was_activated ){
58336 show_message(__('Attempting reactivation of the plugin'));
58337 echo '<iframe style="border:0;overflow:hidden" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) .'"></iframe>';
58338 }
58339 $update_actions = array(
58340 'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . attribute_escape(__('Activate this plugin')) . '" target="_parent">' . __('Activate Plugin') . '</a>',
58341 'plugins_page' => '<a href="' . admin_url('plugins.php') . '" title="' . attribute_escape(__('Goto plugins page')) . '" target="_parent">' . __('Return to Plugins page') . '</a>'
58342 );
58343 if ( $was_activated )
58344 unset( $update_actions['activate_plugin'] );
58345
58346 $update_actions = apply_filters('update_plugin_complete_actions', $update_actions, $plugin_file);
58347 if ( ! empty($update_actions) )
58348 show_message('<strong>' . __('Actions:') . '</strong> ' . implode(' | ', (array)$update_actions));
58349 }
58350 echo '</div>';
58351 }
58352
58353 /**
58354 * Theme upgrade display.
58355 *
58356 * @since 2.5
58357 *
58358 * @param string $plugin Plugin
58359 */
58360 function do_theme_upgrade($theme) {
58361 global $wp_filesystem;
58362
58363 $url = wp_nonce_url('update.php?action=upgrade-theme&theme=' . urlencode($theme), 'upgrade-plugin_' . urlencode($theme));
58364 if ( false === ($credentials = request_filesystem_credentials($url)) )
58365 return;
58366
58367 if ( ! WP_Filesystem($credentials) ) {
58368 $error = true;
58369 if ( is_object($wp_filesystem) && $wp_filesystem->errors->get_error_code() )
58370 $error = $wp_filesystem->errors;
58371 request_filesystem_credentials($url, '', $error); //Failed to connect, Error and request again
58372 return;
58373 }
58374
58375 echo '<div class="wrap">';
58376 echo '<h2>' . __('Upgrade Theme') . '</h2>';
58377 if ( $wp_filesystem->errors->get_error_code() ) {
58378 foreach ( $wp_filesystem->errors->get_error_messages() as $message )
58379 show_message($message);
58380 echo '</div>';
58381 return;
58382 }
58383
58384 //TODO: Is theme currently active?
58385 $was_current = false; //is_plugin_active($plugin); //Check now, It'll be deactivated by the next line if it is
58386
58387 $result = wp_update_theme($theme, 'show_message');
58388
58389 if ( is_wp_error($result) ) {
58390 show_message($result);
58391 show_message( __('Installation Failed') );
58392 } else {
58393 //Result is the new plugin file relative to WP_PLUGIN_DIR
58394 show_message( __('Theme upgraded successfully') );
58395 if( $result && $was_current ){
58396 show_message(__('Setting theme as Current'));
58397 //TODO: Actually set it as active again.
58398 //echo '<iframe style="border:0" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&plugin=' . $result, 'activate-plugin_' . $result) .'"></iframe>';
58399 }
58400 }
58401 echo '</div>';
58402 }
58403
58404 if ( isset($_GET['action']) ) {
58405 $plugin = isset($_GET['plugin']) ? trim($_GET['plugin']) : '';
58406 $theme = isset($_REQUEST['theme']) ? urldecode($_REQUEST['theme']) : '';
58407 $action = isset($_GET['action']) ? $_GET['action'] : '';
58408
58409 if ( 'upgrade-plugin' == $action ) {
58410 check_admin_referer('upgrade-plugin_' . $plugin);
58411 $title = __('Upgrade Plugin');
58412 $parent_file = 'plugins.php';
58413 require_once('admin-header.php');
58414 do_plugin_upgrade($plugin);
58415 include('admin-footer.php');
58416 } elseif ('activate-plugin' == $action ) {
58417 check_admin_referer('activate-plugin_' . $plugin);
58418 if( ! isset($_GET['failure']) && ! isset($_GET['success']) ) {
58419 wp_redirect( 'update.php?action=activate-plugin&failure=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce'] );
58420 activate_plugin($plugin);
58421 wp_redirect( 'update.php?action=activate-plugin&success=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce'] );
58422 die();
58423 }
58424 iframe_header( __('Plugin Reactivation'), true );
58425 if( isset($_GET['success']) )
58426 echo '<p>' . __('Plugin reactivated successfully.') . '</p>';
58427
58428 if( isset($_GET['failure']) ){
58429 echo '<p>' . __('Plugin failed to reactivate due to a fatal error.') . '</p>';
58430 error_reporting( E_ALL ^ E_NOTICE );
58431 @ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
58432 include(WP_PLUGIN_DIR . '/' . $plugin);
58433 }
58434 iframe_footer();
58435 } elseif ( 'upgrade-theme' == $action ) {
58436 check_admin_referer('upgrade-theme_' . $theme);
58437 $title = __('Upgrade Theme');
58438 $parent_file = 'themes.php';
58439 require_once('admin-header.php');
58440 do_theme_upgrade($theme);
58441 include('admin-footer.php');
58442 }
58443 }
58444
58445 ?>