[0]; if ( isset($handle[1]) ) $this->args[$handle[0]] = $handle[1]; } } } /** * Dequeue an item or items. * * Decodes handles and arguments, then dequeues handles * and removes arguments from the class property $args. * * @access public * @since 2.1.0 * * @param mixed $handles Item handle and argument (string) or item handles and arguments (array of strings). */ public function dequeue( $handles ) { foreach ( (array) $handles as $handle ) { $handle = explode('?', $handle); $key = array_search($handle[0], $this->queue); if ( false !== $key ) { unset($this->queue[$key]); unset($this->args[$handle[0]]); } } } /** * 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. * * @access public * @since 2.1.0 * * @param string $handle Name of the item. Should be unique. * @param string $list Property name of list array. * @return bool Found, or object Item data. */ public function query( $handle, $list = 'registered' ) { switch ( $list ) { case 'registered' : case 'scripts': // back compat if ( isset( $this->registered[ $handle ] ) ) return $this->registered[ $handle ]; return false; case 'enqueued' : case 'queue' : if ( in_array( $handle, $this->queue ) ) { return true; } return $this->recurse_deps( $this->queue, $handle ); case 'to_do' : case 'to_print': // back compat return in_array( $handle, $this->to_do ); case 'done' : case 'printed': // back compat return in_array( $handle, $this->done ); } return false; } /** * Set item group, unless already in a lower group. * * @access public * @since 2.8.0 * * @param string $handle Name of the item. Should be unique. * @param bool $recursion Internal flag that calling function was called recursively. * @param mixed $group Group level. * @return bool Not already in the group or a lower group */ public function set_group( $handle, $recursion, $group ) { $group = (int) $group; if ( $recursion ) $group = min($this->group, $group); else $this->group = $group; if ( isset($this->groups[$handle]) && $this->groups[$handle] <= $group ) return false; $this->groups[$handle] = $group; return true; } } // WP_Dependencies /** * Class _WP_Dependency * * Helper class to register a handle and associated data. * * @access private * @since 2.6.0 */ class _WP_Dependency { /** * The handle name. * * @access public * @since 2.6.0 * @var null */ public $handle; /** * The handle source. * * @access public * @since 2.6.0 * @var null */ public $src; /** * An array of handle dependencies. * * @access public * @since 2.6.0 * @var array */ public $deps = array(); /** * The handle version. * * Used for cache-busting. * * @access public * @since 2.6.0 * @var bool|string */ public $ver = false; /** * Additional arguments for the handle. * * @access public * @since 2.6.0 * @var null */ public $args = null; // Custom property, such as $in_footer or $media. /** * Extra data to supply to the handle. * * @access public * @since 2.6.0 * @var array */ public $extra = array(); /** * Setup dependencies. * * @since 2.6.0 */ 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(); } /** * Add handle data. * * @access public * @since 2.6.0 * * @param string $name The data key to add. * @param mixed $data The data value to add. * @return bool False if not scalar, true otherwise. */ public function add_data( $name, $data ) { if ( !is_scalar($name) ) return false; $this->extra[$name] = $data; return true; } } // _WP_Dependencies