WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WP_Site_Health::get_test_wordpress_version() public WP 5.2.0

Tests for WordPress version and outputs it.

Gives various results depending on what kind of updates are available, if any, to encourage the user to install security updates as a priority.

Это метод класса: WP_Site_Health{}

Хуков нет.

Возвращает

Массив. The test result.

Использование

$WP_Site_Health = new WP_Site_Health();
$WP_Site_Health->get_test_wordpress_version();

Список изменений

С версии 5.2.0 Введена.

Код WP_Site_Health::get_test_wordpress_version() WP 5.5.1

wp-admin/includes/class-wp-site-health.php
<?php
public function get_test_wordpress_version() {
	$result = array(
		'label'       => '',
		'status'      => '',
		'badge'       => array(
			'label' => __( 'Performance' ),
			'color' => 'blue',
		),
		'description' => '',
		'actions'     => '',
		'test'        => 'wordpress_version',
	);

	$core_current_version = get_bloginfo( 'version' );
	$core_updates         = get_core_updates();

	if ( ! is_array( $core_updates ) ) {
		$result['status'] = 'recommended';

		$result['label'] = sprintf(
			/* translators: %s: Your current version of WordPress. */
			__( 'WordPress version %s' ),
			$core_current_version
		);

		$result['description'] = sprintf(
			'<p>%s</p>',
			__( 'We were unable to check if any new versions of WordPress are available.' )
		);

		$result['actions'] = sprintf(
			'<a href="%s">%s</a>',
			esc_url( admin_url( 'update-core.php?force-check=1' ) ),
			__( 'Check for updates manually' )
		);
	} else {
		foreach ( $core_updates as $core => $update ) {
			if ( 'upgrade' === $update->response ) {
				$current_version = explode( '.', $core_current_version );
				$new_version     = explode( '.', $update->version );

				$current_major = $current_version[0] . '.' . $current_version[1];
				$new_major     = $new_version[0] . '.' . $new_version[1];

				$result['label'] = sprintf(
					/* translators: %s: The latest version of WordPress available. */
					__( 'WordPress update available (%s)' ),
					$update->version
				);

				$result['actions'] = sprintf(
					'<a href="%s">%s</a>',
					esc_url( admin_url( 'update-core.php' ) ),
					__( 'Install the latest version of WordPress' )
				);

				if ( $current_major !== $new_major ) {
					// This is a major version mismatch.
					$result['status']      = 'recommended';
					$result['description'] = sprintf(
						'<p>%s</p>',
						__( 'A new version of WordPress is available.' )
					);
				} else {
					// This is a minor version, sometimes considered more critical.
					$result['status']         = 'critical';
					$result['badge']['label'] = __( 'Security' );
					$result['description']    = sprintf(
						'<p>%s</p>',
						__( 'A new minor update is available for your site. Because minor updates often address security, it&#8217;s important to install them.' )
					);
				}
			} else {
				$result['status'] = 'good';
				$result['label']  = sprintf(
					/* translators: %s: The current version of WordPress installed on this site. */
					__( 'Your version of WordPress (%s) is up to date' ),
					$core_current_version
				);

				$result['description'] = sprintf(
					'<p>%s</p>',
					__( 'You are currently running the latest version of WordPress available, keep it up!' )
				);
			}
		}
	}

	return $result;
}