]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/class.wp-dependencies.php
WordPress 4.0
[autoinstalls/wordpress.git] / wp-includes / class.wp-dependencies.php
index 158d3e03e79ff3dd1badbffba42dfc2b63d75da7..c1bac65ba18ed720cabd5eaaef079ef0281e3131 100644 (file)
@@ -18,7 +18,7 @@ class WP_Dependencies {
         * @since 2.6.8
         * @var array
         */
         * @since 2.6.8
         * @var array
         */
-       var $registered = array();
+       public $registered = array();
 
        /**
         * An array of queued _WP_Dependency handle objects.
 
        /**
         * An array of queued _WP_Dependency handle objects.
@@ -27,7 +27,7 @@ class WP_Dependencies {
         * @since 2.6.8
         * @var array
         */
         * @since 2.6.8
         * @var array
         */
-       var $queue = array();
+       public $queue = array();
 
        /**
         * An array of _WP_Dependency handle objects to queue.
 
        /**
         * An array of _WP_Dependency handle objects to queue.
@@ -36,7 +36,7 @@ class WP_Dependencies {
         * @since 2.6.0
         * @var array
         */
         * @since 2.6.0
         * @var array
         */
-       var $to_do = array();
+       public $to_do = array();
 
        /**
         * An array of _WP_Dependency handle objects already queued.
 
        /**
         * An array of _WP_Dependency handle objects already queued.
@@ -45,7 +45,7 @@ class WP_Dependencies {
         * @since 2.6.0
         * @var array
         */
         * @since 2.6.0
         * @var array
         */
-       var $done = array();
+       public $done = array();
 
        /**
         * An array of additional arguments passed when a handle is registered.
 
        /**
         * An array of additional arguments passed when a handle is registered.
@@ -56,7 +56,7 @@ class WP_Dependencies {
         * @since 2.6.0
         * @var array
         */
         * @since 2.6.0
         * @var array
         */
-       var $args = array();
+       public $args = array();
 
        /**
         * An array of handle groups to enqueue.
 
        /**
         * An array of handle groups to enqueue.
@@ -65,7 +65,7 @@ class WP_Dependencies {
         * @since 2.8.0
         * @var array
         */
         * @since 2.8.0
         * @var array
         */
-       var $groups = array();
+       public $groups = array();
 
        /**
         * A handle group to enqueue.
 
        /**
         * A handle group to enqueue.
@@ -74,7 +74,7 @@ class WP_Dependencies {
         * @since 2.8.0
         * @var int
         */
         * @since 2.8.0
         * @var int
         */
-       var $group = 0;
+       public $group = 0;
 
        /**
         * Process the items and dependencies.
 
        /**
         * Process the items and dependencies.
@@ -324,6 +324,31 @@ class WP_Dependencies {
                }
        }
 
                }
        }
 
+       /**
+        * 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.
         *
        /**
         * Query list for an item.
         *
@@ -344,7 +369,10 @@ class WP_Dependencies {
 
                        case 'enqueued' :
                        case 'queue' :
 
                        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
 
                        case 'to_do' :
                        case 'to_print': // back compat
@@ -401,7 +429,7 @@ class _WP_Dependency {
         * @since 2.6.0
         * @var null
         */
         * @since 2.6.0
         * @var null
         */
-       var $handle;
+       public $handle;
 
        /**
         * The handle source.
 
        /**
         * The handle source.
@@ -410,7 +438,7 @@ class _WP_Dependency {
         * @since 2.6.0
         * @var null
         */
         * @since 2.6.0
         * @var null
         */
-       var $src;
+       public $src;
 
        /**
         * An array of handle dependencies.
 
        /**
         * An array of handle dependencies.
@@ -419,7 +447,7 @@ class _WP_Dependency {
         * @since 2.6.0
         * @var array
         */
         * @since 2.6.0
         * @var array
         */
-       var $deps = array();
+       public $deps = array();
 
        /**
         * The handle version.
 
        /**
         * The handle version.
@@ -430,7 +458,7 @@ class _WP_Dependency {
         * @since 2.6.0
         * @var bool|string
         */
         * @since 2.6.0
         * @var bool|string
         */
-       var $ver = false;
+       public $ver = false;
 
        /**
         * Additional arguments for the handle.
 
        /**
         * Additional arguments for the handle.
@@ -439,7 +467,7 @@ class _WP_Dependency {
         * @since 2.6.0
         * @var null
         */
         * @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.
 
        /**
         * Extra data to supply to the handle.
@@ -448,14 +476,14 @@ class _WP_Dependency {
         * @since 2.6.0
         * @var array
         */
         * @since 2.6.0
         * @var array
         */
-       var $extra = array();
+       public $extra = array();
 
        /**
         * Setup dependencies.
         *
         * @since 2.6.0
         */
 
        /**
         * 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();
                @list( $this->handle, $this->src, $this->deps, $this->ver, $this->args ) = func_get_args();
                if ( ! is_array($this->deps) )
                        $this->deps = array();
@@ -471,7 +499,7 @@ class _WP_Dependency {
         * @param mixed  $data The data value to add.
         * @return bool False if not scalar, true otherwise.
         */
         * @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;
                if ( !is_scalar($name) )
                        return false;
                $this->extra[$name] = $data;