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

WP_Site_Health::get_test_utf8mb4_support() public WP 5.2.0

Test if the database server is capable of using utf8mb4.

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

Хуков нет.

Возвращает

Массив. The test results.

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

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

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

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

Код WP_Site_Health::get_test_utf8mb4_support() WP 5.5.1

wp-admin/includes/class-wp-site-health.php
<?php
public function get_test_utf8mb4_support() {
	global $wpdb;

	if ( ! $this->mysql_server_version ) {
		$this->prepare_sql_data();
	}

	$result = array(
		'label'       => __( 'UTF8MB4 is supported' ),
		'status'      => 'good',
		'badge'       => array(
			'label' => __( 'Performance' ),
			'color' => 'blue',
		),
		'description' => sprintf(
			'<p>%s</p>',
			__( 'UTF8MB4 is the character set WordPress prefers for database storage because it safely supports the widest set of characters and encodings, including Emoji, enabling better support for non-English languages.' )
		),
		'actions'     => '',
		'test'        => 'utf8mb4_support',
	);

	if ( ! $this->is_mariadb ) {
		if ( version_compare( $this->mysql_server_version, '5.5.3', '<' ) ) {
			$result['status'] = 'recommended';

			$result['label'] = __( 'utf8mb4 requires a MySQL update' );

			$result['description'] .= sprintf(
				'<p>%s</p>',
				sprintf(
					/* translators: %s: Version number. */
					__( 'WordPress&#8217; utf8mb4 support requires MySQL version %s or greater. Please contact your server administrator.' ),
					'5.5.3'
				)
			);
		} else {
			$result['description'] .= sprintf(
				'<p>%s</p>',
				__( 'Your MySQL version supports utf8mb4.' )
			);
		}
	} else { // MariaDB introduced utf8mb4 support in 5.5.0.
		if ( version_compare( $this->mysql_server_version, '5.5.0', '<' ) ) {
			$result['status'] = 'recommended';

			$result['label'] = __( 'utf8mb4 requires a MariaDB update' );

			$result['description'] .= sprintf(
				'<p>%s</p>',
				sprintf(
					/* translators: %s: Version number. */
					__( 'WordPress&#8217; utf8mb4 support requires MariaDB version %s or greater. Please contact your server administrator.' ),
					'5.5.0'
				)
			);
		} else {
			$result['description'] .= sprintf(
				'<p>%s</p>',
				__( 'Your MariaDB version supports utf8mb4.' )
			);
		}
	}

	if ( $wpdb->use_mysqli ) {
		// phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysqli_get_client_info
		$mysql_client_version = mysqli_get_client_info();
	} else {
		// phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysql_get_client_info,PHPCompatibility.Extensions.RemovedExtensions.mysql_DeprecatedRemoved
		$mysql_client_version = mysql_get_client_info();
	}

	/*
	 * libmysql has supported utf8mb4 since 5.5.3, same as the MySQL server.
	 * mysqlnd has supported utf8mb4 since 5.0.9.
	 */
	if ( false !== strpos( $mysql_client_version, 'mysqlnd' ) ) {
		$mysql_client_version = preg_replace( '/^\D+([\d.]+).*/', '$1', $mysql_client_version );
		if ( version_compare( $mysql_client_version, '5.0.9', '<' ) ) {
			$result['status'] = 'recommended';

			$result['label'] = __( 'utf8mb4 requires a newer client library' );

			$result['description'] .= sprintf(
				'<p>%s</p>',
				sprintf(
					/* translators: 1: Name of the library, 2: Number of version. */
					__( 'WordPress&#8217; utf8mb4 support requires MySQL client library (%1$s) version %2$s or newer. Please contact your server administrator.' ),
					'mysqlnd',
					'5.0.9'
				)
			);
		}
	} else {
		if ( version_compare( $mysql_client_version, '5.5.3', '<' ) ) {
			$result['status'] = 'recommended';

			$result['label'] = __( 'utf8mb4 requires a newer client library' );

			$result['description'] .= sprintf(
				'<p>%s</p>',
				sprintf(
					/* translators: 1: Name of the library, 2: Number of version. */
					__( 'WordPress&#8217; utf8mb4 support requires MySQL client library (%1$s) version %2$s or newer. Please contact your server administrator.' ),
					'libmysql',
					'5.5.3'
				)
			);
		}
	}

	return $result;
}