WP_Script_Modules::get_dependents( string $id ): string[]

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness. Use WP_Scripts::get_dependents() instead.

Gets all dependents of a script module.

Description

This is not recursive.

See also

Parameters

$idstringrequired
The script ID.

Return

string[] Script module IDs.

Source

private function get_dependents( string $id ): array {
	// Check if dependents map for the handle in question is present. If so, use it.
	if ( isset( $this->dependents_map[ $id ] ) ) {
		return $this->dependents_map[ $id ];
	}

	$dependents = array();

	// Iterate over all registered scripts, finding dependents of the script passed to this method.
	foreach ( $this->registered as $registered_id => $args ) {
		if ( in_array( $id, wp_list_pluck( $args['dependencies'], 'id' ), true ) ) {
			$dependents[] = $registered_id;
		}
	}

	// Add the module's dependents to the map to ease future lookups.
	$this->dependents_map[ $id ] = $dependents;

	return $dependents;
}

Changelog

VersionDescription
6.9.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.