WP_Script_Modules::get_sorted_dependenciesprivateWP 6.9.0

Sorts the given script module identifiers based on their dependencies.

It will return a list of script module identifiers sorted in the order they should be printed, so that dependencies are printed before the script modules that depend on them.

Method of the class: WP_Script_Modules{}

No Hooks.

Returns

String[]. Sorted list of script module identifiers.

Usage

$result = WP_Script_Modules::get_sorted_dependencies( $ids, $import_types, fooo ) ): array;
$ids(string[]) (required)
The identifiers of the script modules to sort.
$import_types(string[])
Import types of dependencies to retrieve: 'static', 'dynamic', or both.
Default: both
fooo )(required)
.

Changelog

Since 6.9.0 Introduced.

WP_Script_Modules::get_sorted_dependencies() code WP 6.9.1

private function get_sorted_dependencies( array $ids, array $import_types = array( 'static', 'dynamic' ) ): array {
	$sorted = array();

	foreach ( $ids as $id ) {
		$this->sort_item_dependencies( $id, $import_types, $sorted );
	}

	return array_unique( $sorted );
}