wpseek.com
A WordPress-centric search engine for devs and theme authors
do_core_upgrade › WordPress Function
Since2.7.0
Deprecatedn/a
› do_core_upgrade ( $reinstall = false )
Parameters: |
|
Defined at: |
|
Codex: |
Upgrades WordPress core display.
Related Functions: find_core_update, core_upgrade_preamble, dismiss_core_update, list_core_update, do_dismiss_core_update
Source
function do_core_upgrade( $reinstall = false ) { global $wp_filesystem; require_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 WordPress' ); ?></h1> <?php $credentials = request_filesystem_credentials( $url, '', false, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership ); if ( false === $credentials ) { 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->has_errors() ) { 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 ); if ( 'up_to_date' !== $result->get_error_code() && 'locked' !== $result->get_error_code() ) { show_message( __( 'Installation failed.' ) ); } echo '</div>'; return; } show_message( __( 'WordPress updated successfully.' ) ); show_message( '<span class="hide-if-no-js">' . sprintf( /* translators: 1: WordPress version, 2: URL to About screen. */ __( 'Welcome to WordPress %1$s. You will be redirected to the About WordPress 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( /* translators: 1: WordPress version, 2: URL to About screen. */ __( 'Welcome to WordPress %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 esc_url( self_admin_url( 'about.php?updated' ) ); ?>'; </script> <?php }