core_auto_updates_settings
函数
core_auto_updates_settings ( No parameters )
- 定义位置
-
-
wp-admin/update-core.php
, line 307
-
wp-admin/update-core.php
- 引入
- 5.6.0
- 弃用
- –
显示WordPress的自动更新设置。
function core_auto_updates_settings() {
if ( isset( $_GET['core-major-auto-updates-saved'] ) ) {
if ( 'enabled' === $_GET['core-major-auto-updates-saved'] ) {
$notice_text = __( 'Automatic updates for all WordPress versions have been enabled. Thank you!' );
echo '' . $notice_text . '';
} elseif ( 'disabled' === $_GET['core-major-auto-updates-saved'] ) {
$notice_text = __( 'WordPress will only receive automatic security and maintenance releases from now on.' );
echo '' . $notice_text . '';
}
}
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
$updater = new WP_Automatic_Updater();
// Defaults:
$upgrade_dev = get_site_option( 'auto_update_core_dev', 'enabled' ) === 'enabled';
$upgrade_minor = get_site_option( 'auto_update_core_minor', 'enabled' ) === 'enabled';
$upgrade_major = get_site_option( 'auto_update_core_major', 'unset' ) === 'enabled';
$can_set_update_option = true;
// WP_AUTO_UPDATE_CORE = true (all), 'beta', 'rc', 'development', 'branch-development', 'minor', false.
if ( defined( 'WP_AUTO_UPDATE_CORE' ) ) {
if ( false === WP_AUTO_UPDATE_CORE ) {
// Defaults to turned off, unless a filter allows it.
$upgrade_dev = false;
$upgrade_minor = false;
$upgrade_major = false;
} elseif ( true === WP_AUTO_UPDATE_CORE
|| in_array( WP_AUTO_UPDATE_CORE, array( 'beta', 'rc', 'development', 'branch-development' ), true )
) {
// ALL updates for core.
$upgrade_dev = true;
$upgrade_minor = true;
$upgrade_major = true;
} elseif ( 'minor' === WP_AUTO_UPDATE_CORE ) {
// Only minor updates for core.
$upgrade_dev = false;
$upgrade_minor = true;
$upgrade_major = false;
}
// The UI is overridden by the `WP_AUTO_UPDATE_CORE` constant.
$can_set_update_option = false;
}
if ( $updater->is_disabled() ) {
$upgrade_dev = false;
$upgrade_minor = false;
$upgrade_major = false;
/*
* The UI is overridden by the `AUTOMATIC_UPDATER_DISABLED` constant
* or the `automatic_updater_disabled` filter,
* or by `wp_is_file_mod_allowed( 'automatic_updater' )`.
* See `WP_Automatic_Updater::is_disabled()`.
*/
$can_set_update_option = false;
}
// Is the UI overridden by a plugin using the `allow_major_auto_core_updates` filter?
if ( has_filter( 'allow_major_auto_core_updates' ) ) {
$can_set_update_option = false;
}
/** This filter is documented in wp-admin/includes/class-core-upgrader.php */
$upgrade_dev = apply_filters( 'allow_dev_auto_core_updates', $upgrade_dev );
/** This filter is documented in wp-admin/includes/class-core-upgrader.php */
$upgrade_minor = apply_filters( 'allow_minor_auto_core_updates', $upgrade_minor );
/** This filter is documented in wp-admin/includes/class-core-upgrader.php */
$upgrade_major = apply_filters( 'allow_major_auto_core_updates', $upgrade_major );
$auto_update_settings = array(
'dev' => $upgrade_dev,
'minor' => $upgrade_minor,
'major' => $upgrade_major,
);
if ( $upgrade_major ) {
$wp_version = get_bloginfo( 'version' );
$updates = get_core_updates();
if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) {
echo '' . wp_get_auto_update_message() . '';
}
}
$action_url = self_admin_url( 'update-core.php?action=core-major-auto-updates-settings' );
?>
is_vcs_checkout( ABSPATH ) ) {
_e( 'This site appears to be under version control. Automatic updates are disabled.' );
} elseif ( $upgrade_major ) {
_e( 'This site is automatically kept up to date with each new version of WordPress.' );
if ( $can_set_update_option ) {
echo '';
printf(
'%s',
wp_nonce_url( add_query_arg( 'value', 'disable', $action_url ), 'core-major-auto-updates-nonce' ),
__( 'Switch to automatic updates for maintenance and security releases only.' )
);
}
} elseif ( $upgrade_minor ) {
_e( 'This site is automatically kept up to date with maintenance and security releases of WordPress only.' );
if ( $can_set_update_option ) {
echo '';
printf(
'%s',
wp_nonce_url( add_query_arg( 'value', 'enable', $action_url ), 'core-major-auto-updates-nonce' ),
__( 'Enable automatic updates for all new versions of WordPress.' )
);
}
} else {
_e( 'This site will not receive automatic updates for new versions of WordPress.' );
}
?>
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。