WP_Script_Modules::get_highest_fetchpriorityprivateWP 6.9.0

Gets the highest fetch priority for the provided script IDs.

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

Хуков нет.

Возвращает

'auto'|'low'|'high'. Highest fetch priority for the provided script module IDs.

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

// private - только в коде основоного (родительского) класса
$result = $this->get_highest_fetchpriority( $ids ): string;
$ids(string[]) (обязательный)
Script module IDs.

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

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

Код WP_Script_Modules::get_highest_fetchpriority() WP 6.9

private function get_highest_fetchpriority( array $ids ): string {
	static $high_priority_index = null;
	if ( null === $high_priority_index ) {
		$high_priority_index = count( $this->priorities ) - 1;
	}

	$highest_priority_index = 0;
	foreach ( $ids as $id ) {
		if ( isset( $this->registered[ $id ] ) ) {
			$highest_priority_index = (int) max(
				$highest_priority_index,
				(int) array_search( $this->registered[ $id ]['fetchpriority'], $this->priorities, true )
			);
			if ( $high_priority_index === $highest_priority_index ) {
				break;
			}
		}
	}

	return $this->priorities[ $highest_priority_index ];
}