do_core_upgrade( bool $reinstall = false )
Upgrade ClassicPress core display.
Parameters
- $reinstall
-
(Optional)
Default value: false
Source
File: wp-admin/update-core.php
function do_core_upgrade( $reinstall = false ) {
global $wp_filesystem;
include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
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');
$version = isset( $_POST['version'] )? $_POST['version'] : false;
$locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
$update = find_core_update( $version, $locale );
if ( !$update )
return;
// Allow relaxed file ownership writes for User-initiated upgrades when the API specifies
// that it's safe to do so. This only happens when there are no new files to create.
$allow_relaxed_file_ownership = ! $reinstall && isset( $update->new_files ) && ! $update->new_files;
?>
<div class="wrap">
<h1><?php _e( 'Update ClassicPress' ); ?></h1>
<?php
if ( false === ( $credentials = request_filesystem_credentials( $url, '', false, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership ) ) ) {
echo '</div>';
return;
}
if ( ! WP_Filesystem( $credentials, ABSPATH, $allow_relaxed_file_ownership ) ) {
// Failed to connect, Error and request again
request_filesystem_credentials( $url, '', true, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership );
echo '</div>';
return;
}
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';
add_filter( 'update_feedback', 'show_message' );
$upgrader = new Core_Upgrader();
$result = $upgrader->upgrade( $update, array(
'allow_relaxed_file_ownership' => $allow_relaxed_file_ownership
) );
if ( is_wp_error( $result ) ) {
show_message( $result );
switch ( $result->get_error_code() ) {
case 'up_to_date':
// ClassicPress is already up to date, no need to show a different message
break;
case 'locked':
// Show a bit more info for this fairly common error
show_message( __(
'It\'s possible that an update started, but the server encountered a temporary issue and could not continue.'
) );
show_message( __(
'Or, you may have clicked the update button multiple times.'
) );
show_message( __(
'Please wait <strong>15 minutes</strong> and try again.'
) );
show_message( sprintf(
/* translators: URL to support forum */
__( 'If you see this message after waiting 15 minutes and trying the update again, please make a post on our <a href="%s">support forum</a>.' ),
'https://forums.classicpress.net/c/support/'
) );
break;
default:
// Show a generic failure message
show_message( __( 'Installation Failed' ) );
break;
}
echo '</div>';
return;
}
show_message( __( 'ClassicPress updated successfully' ) );
show_message( '<span class="hide-if-no-js">' . sprintf( __( 'Welcome to ClassicPress %1$s. You will be redirected to the About ClassicPress screen. If not, click <a href="%2$s">here</a>.' ), $result, esc_url( self_admin_url( 'about.php?updated' ) ) ) . '</span>' );
show_message( '<span class="hide-if-js">' . sprintf( __( 'Welcome to ClassicPress %1$s. <a href="%2$s">Learn more</a>.' ), $result, esc_url( self_admin_url( 'about.php?updated' ) ) ) . '</span>' );
?>
</div>
<script type="text/javascript">
window.location = '<?php echo self_admin_url( 'about.php?updated' ); ?>';
</script>
<?php
}
Changelog
Version | Description |
---|---|
2.7.0 | Introduced. |