core_upgrade_preamble()

最后更新于:2021-11-25 22:20:20

core_upgrade_preamble()

Display upgrade GeChiUI for downloading latest or upgrading automatically form.

源文件

文件: gc-admin/update-core.php

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

	$updates = get_core_updates();

	// Include an unmodified $gc_version.
	require ABSPATH . GCINC . '/version.php';

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

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

		echo '<div class="notice notice-warning inline"><p>';
		printf(
			/* translators: 1: Documentation on GeChiUI backups, 2: Documentation on updating GeChiUI. */
			__( '<strong>Important:</strong> Before updating, please <a href="https://docs.gechiui.com/functions/core_upgrade_preamble/%1$s">back up your database and files</a>. For help with updates, visit the <a href="https://docs.gechiui.com/functions/core_upgrade_preamble/%2$s">Updating GeChiUI</a> documentation page.' ),
			__( 'https://gechiui.org/support/article/gechiui-backups/' ),
			__( 'https://gechiui.org/support/article/updating-gechiui/' )
		);
		echo '</p></div>';
	} elseif ( $is_development_version ) {
		echo '<h2 class="response">' . __( 'You are using a development version of GeChiUI.' ) . '</h2>';
	} else {
		echo '<h2 class="response">' . __( 'You have the latest version of GeChiUI.' ) . '</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( '-', $gc_version );
		echo '<p>' . sprintf(
			/* translators: 1: URL to About screen, 2: GeChiUI version. */
			__( '<a href="https://docs.gechiui.com/functions/core_upgrade_preamble/%1$s">Learn more about GeChiUI %2$s</a>.' ),
			esc_url( self_admin_url( 'about.php' ) ),
			$normalized_version
		) . '</p>';
	}

	dismissed_updates();
}