Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Class Reference/WP Dependencies


WP_Dependencies is a class defined in wp-includes/class.wp-dependencies.php that helps process items in an order defined by dependencies (a dependent item is processed later than a dependency). It's an abstract class in that it's intended to be extended, rather than used directly. WP_Dependencies is the base for WP_Scripts and WP_Styles, and is a collection of _WP_Dependencys.


An item goes through various stages of processing as various methods are called:

  1. registered: add()
  2. enqueued: enqueue()
  3. to_do: all_deps()
  4. done: do_items()

The query() method can be used to determine whether a given item is in a given stage.


Separate processing runs can be identified by different groups (identified by integers). For example, items output in the document <head> might go in one group, while items output in the footer may go in another. An enqueued item that was processed in a group associated with an earlier run is skipped in later runs. The base WP_Dependencies doesn't create groups on its own; child classes must do this.

Methods and Properties


registered items. An item must be registered before it can be processed.
items to process during the next run. Not necessarily in order.
items to process during the next run, in processing order.
items that have already been processed.
query string arguments for the items.
(internal) records earliest group each item was processed in.
(internal) current group.


do_item( $handle ) 
Process an item. Must be overriden by children. Return TRUE if item was successfully processed.
do_items( $handles = false, $group = false ) 
process items in $handles (defaults to $queue).
all_deps( $handles, $recursion = false, $group = false ) 
Recursively builds array of items to process taking dependencies into account. Does NOT catch infinite loops.
add( $handle, $src, $deps = array(), $ver = false, $args = null ) 
Adds the item only if no item of that name already exists
add_data( $handle, $key, $value ) 
Adds extra data if an item with the given handle has already been added.
get_data( $handle, $key ) 
Gets data associated with a certain handle.
remove ( $handles ) 
Unregister items.
enqueue ( $handles ) 
Add item to the processing queue.
dequeue ( $handles ) 
Remove item from the processing queue.
query ( $handle, $list = 'registered' ) 
Check whether given item is in the given stage (registered, enqueued/queue, to_do, done).
set_group ( $handle, $recursion, $group ) 
set the group for the given handle and (if not recursing) the current run.


Change Log

Since 2.6.

Source File

WP_Dependencies is located in wp-includes/class.wp-dependencies.php.

See also index of Class Reference and index of Function Reference.