Advertisements

do_core_upgrade

Definition:
function do_core_upgrade( $reinstall = false ) {}

Upgrade WordPress core display.

Parameters

  • $reinstall

Source code

function do_core_upgrade( $reinstall = false ) {

	global $wp_filesystem;



	if ( $reinstall )

		$url = 'update-core.php?action=do-core-reinstall';

	else

		$url = 'update-core.php?action=do-core-upgrade';

	$url = wp_nonce_url($url, 'upgrade-core');

	if ( false === ($credentials = request_filesystem_credentials($url, '', false, ABSPATH)) )

		return;



	$version = isset( $_POST['version'] )? $_POST['version'] : false;

	$locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';

	$update = find_core_update( $version, $locale );

	if ( !$update )

		return;





	if ( ! WP_Filesystem($credentials, ABSPATH) ) {

		request_filesystem_credentials($url, '', true, ABSPATH); //Failed to connect, Error and request again

		return;

	}

?>

	<div class="wrap">

	<?php screen_icon('tools'); ?>

	<h2><?php _e('Update WordPress'); ?></h2>

<?php

	if ( $wp_filesystem->errors->get_error_code() ) {

		foreach ( $wp_filesystem->errors->get_error_messages() as $message )

			show_message($message);

		echo '</div>';

		return;

	}



	if ( $reinstall )

		$update->response = 'reinstall';



	$result = wp_update_core($update, 'show_message');



	if ( is_wp_error($result) ) {

		show_message($result);

		if ('up_to_date' != $result->get_error_code() )

			show_message( __('Installation Failed') );

	} else {

		show_message( __('WordPress updated successfully') );

		show_message( '<a href="' . esc_url( self_admin_url() ) . '">' . __('Go to Dashboard') . '</a>' );

	}

	echo '</div>';

}

950

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: