core_upgrade_preamble

函数
core_upgrade_preamble ( No parameters )

WordPress中的core_upgrade_preamble钩子是用来修改显示在WordPress升级页面顶部的文本。这个钩子可以用来在升级页面的前言中添加自定义文本或其他内容。

显示升级WordPress以下载最新或自动升级的表格。

function core_upgrade_preamble() {
	global $required_php_version, $required_mysql_version;

	$updates = get_core_updates();

	// Include an unmodified $wp_version.
	require ABSPATH . WPINC . '/version.php';

	$is_development_version = preg_match( '/alpha|beta|RC/', $wp_version );

	if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) {
		echo '<h2 class="response">';
		_e( 'An updated version of WordPress is available.' );
		echo '</h2>';

		echo '<div class="notice notice-warning inline"><p>';
		printf(
			/* translators: 1: Documentation on WordPress backups, 2: Documentation on updating WordPress. */
			__( '<strong>Important:</strong> Before updating, please <a href="%1$s">back up your database and files</a>. For help with updates, visit the <a href="%2$s">Updating WordPress</a> documentation page.' ),
			__( 'https://wordpress.org/support/article/wordpress-backups/' ),
			__( 'https://wordpress.org/support/article/updating-wordpress/' )
		);
		echo '</p></div>';
	} elseif ( $is_development_version ) {
		echo '<h2 class="response">' . __( 'You are using a development version of WordPress.' ) . '</h2>';
	} else {
		echo '<h2 class="response">' . __( 'You have the latest version of WordPress.' ) . '</h2>';
	}

	echo '<ul class="core-updates">';
	foreach ( (array) $updates as $update ) {
		echo '<li>';
		list_core_update( $update );
		echo '</li>';
	}
	echo '</ul>';

	// Don't show the maintenance mode notice when we are only showing a single re-install option.
	if ( $updates && ( count( $updates ) > 1 || 'latest' !== $updates[0]->response ) ) {
		echo '<p>' . __( 'While your site is being updated, it will be in maintenance mode. As soon as your updates are complete, this mode will be deactivated.' ) . '</p>';
	} elseif ( ! $updates ) {
		list( $normalized_version ) = explode( '-', $wp_version );
		echo '<p>' . sprintf(
			/* translators: 1: URL to About screen, 2: WordPress version. */
			__( '<a href="%1$s">Learn more about WordPress %2$s</a>.' ),
			esc_url( self_admin_url( 'about.php' ) ),
			$normalized_version
		) . '</p>';
	}

	dismissed_updates();
}

常见问题

FAQs
查看更多 >