do_core_upgrade
函数
do_core_upgrade ( $reinstall = false )
- 参数
-
-
(bool)
$reinstall- Required: 否
- Default: false
-
(bool)
- 定义位置
-
-
wp-admin/update-core.php
, line 828
-
wp-admin/update-core.php
- 引入
- 2.7.0
- 弃用
- –
Upgrade WordPress core display.
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; ?>'; 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 ''; return; } if ( $wp_filesystem->errors->has_errors() ) { foreach ( $wp_filesystem->errors->get_error_messages() as $message ) { show_message( $message ); } echo '
‘;
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 ‘
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。