WP_Script_Modules::get_dependencies()
Retrieves all the dependencies for the given script module identifiers, filtered by import types.
It will consolidate an array containing a set of unique dependencies based on the requested import types: 'static', 'dynamic', or both. This method is recursive and also retrieves dependencies of the dependencies.
Метод класса: WP_Script_Modules{}
Хуков нет.
Возвращает
Массив[]
. List of dependencies, keyed by script module identifier.
Использование
$result = WP_Script_Modules::get_dependencies( $ids, $import_types, fooo ) );
- $ids(string[]) (обязательный)
- The identifiers of the script modules for which to gather dependencies.
- $import_types(string[])
- Import types of dependencies to retrieve: 'static', 'dynamic', or both.
По умолчанию: both - fooo ) (обязательный)
- -
Список изменений
С версии 6.5.0 | Введена. |
Код WP_Script_Modules::get_dependencies() WP Script Modules::get dependencies WP 6.6.2
private function get_dependencies( array $ids, array $import_types = array( 'static', 'dynamic' ) ) { return array_reduce( $ids, function ( $dependency_script_modules, $id ) use ( $import_types ) { $dependencies = array(); foreach ( $this->registered[ $id ]['dependencies'] as $dependency ) { if ( in_array( $dependency['import'], $import_types, true ) && isset( $this->registered[ $dependency['id'] ] ) && ! isset( $dependency_script_modules[ $dependency['id'] ] ) ) { $dependencies[ $dependency['id'] ] = $this->registered[ $dependency['id'] ]; } } return array_merge( $dependency_script_modules, $dependencies, $this->get_dependencies( array_keys( $dependencies ), $import_types ) ); }, array() ); }