* @since 2.6.8
* @var array
*/
- var $registered = array();
+ public $registered = array();
/**
* An array of queued _WP_Dependency handle objects.
* @since 2.6.8
* @var array
*/
- var $queue = array();
+ public $queue = array();
/**
* An array of _WP_Dependency handle objects to queue.
* @since 2.6.0
* @var array
*/
- var $to_do = array();
+ public $to_do = array();
/**
* An array of _WP_Dependency handle objects already queued.
* @since 2.6.0
* @var array
*/
- var $done = array();
+ public $done = array();
/**
* An array of additional arguments passed when a handle is registered.
* @since 2.6.0
* @var array
*/
- var $args = array();
+ public $args = array();
/**
* An array of handle groups to enqueue.
* @since 2.8.0
* @var array
*/
- var $groups = array();
+ public $groups = array();
/**
* A handle group to enqueue.
* @since 2.8.0
* @var int
*/
- var $group = 0;
+ public $group = 0;
/**
* Process the items and dependencies.
* @return array Handles of items that have been processed.
*/
public function do_items( $handles = false, $group = false ) {
- /**
+ /*
* If nothing is passed, print the queue. If a string is passed,
* print that item. If an array is passed, print those items.
*/
foreach( $this->to_do as $key => $handle ) {
if ( !in_array($handle, $this->done, true) && isset($this->registered[$handle]) ) {
- /**
+ /*
* A single item may alias a set of items, by having dependencies,
* but no source. Queuing the item queues the dependencies.
*
* <code>add( 'scriptaculous', false, array( 'scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls' ) );</code>
*
* The src property is false.
- **/
+ */
if ( ! $this->registered[$handle]->src ) {
$this->done[] = $handle;
continue;
}
- /**
+ /*
* Attempt to process the item. If successful,
* add the handle to the done array.
*
}
}
+ /**
+ * Recursively search the passed dependency tree for $handle
+ *
+ * @since 4.0.0
+ *
+ * @param array $queue An array of queued _WP_Dependency handle objects.
+ * @param string $handle Name of the item. Should be unique.
+ * @return boolean Whether the handle is found after recursively searching the dependency tree.
+ */
+ protected function recurse_deps( $queue, $handle ) {
+ foreach ( $queue as $queued ) {
+ if ( ! isset( $this->registered[ $queued ] ) ) {
+ continue;
+ }
+
+ if ( in_array( $handle, $this->registered[ $queued ]->deps ) ) {
+ return true;
+ } elseif ( $this->recurse_deps( $this->registered[ $queued ]->deps, $handle ) ) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
/**
* Query list for an item.
*
case 'enqueued' :
case 'queue' :
- return in_array( $handle, $this->queue );
+ if ( in_array( $handle, $this->queue ) ) {
+ return true;
+ }
+ return $this->recurse_deps( $this->queue, $handle );
case 'to_do' :
case 'to_print': // back compat
* @since 2.6.0
* @var null
*/
- var $handle;
+ public $handle;
/**
* The handle source.
* @since 2.6.0
* @var null
*/
- var $src;
+ public $src;
/**
* An array of handle dependencies.
* @since 2.6.0
* @var array
*/
- var $deps = array();
+ public $deps = array();
/**
* The handle version.
* @since 2.6.0
* @var bool|string
*/
- var $ver = false;
+ public $ver = false;
/**
* Additional arguments for the handle.
* @since 2.6.0
* @var null
*/
- var $args = null; // Custom property, such as $in_footer or $media.
+ public $args = null; // Custom property, such as $in_footer or $media.
/**
* Extra data to supply to the handle.
* @since 2.6.0
* @var array
*/
- var $extra = array();
+ public $extra = array();
/**
* Setup dependencies.
*
* @since 2.6.0
*/
- function __construct() {
+ public function __construct() {
@list( $this->handle, $this->src, $this->deps, $this->ver, $this->args ) = func_get_args();
if ( ! is_array($this->deps) )
$this->deps = array();
* @param mixed $data The data value to add.
* @return bool False if not scalar, true otherwise.
*/
- function add_data( $name, $data ) {
+ public function add_data( $name, $data ) {
if ( !is_scalar($name) )
return false;
$this->extra[$name] = $data;