WPSEO_Admin_Init::get_latest_major_wordpress_version()privateYoast 1.0

Gets the latest released major WordPress version from the WordPress stable-check api.

Метод класса: WPSEO_Admin_Init{}

Хуков нет.

Возвращает

float|int. The latest released major WordPress version. 0 when the stable-check API doesn't respond.

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

// private - только в коде основоного (родительского) класса
$result = $this->get_latest_major_wordpress_version();

Код WPSEO_Admin_Init::get_latest_major_wordpress_version() Yoast 24.0

private function get_latest_major_wordpress_version() {
	$core_updates = get_core_updates( [ 'dismissed' => true ] );

	if ( $core_updates === false ) {
		return 0;
	}

	$wp_version_latest = get_bloginfo( 'version' );
	foreach ( $core_updates as $update ) {
		if ( $update->response === 'upgrade' && version_compare( $update->version, $wp_version_latest, '>' ) ) {
			$wp_version_latest = $update->version;
		}
	}

	// Strip the patch version and convert to a float.
	return (float) $wp_version_latest;
}