home *** CD-ROM | disk | FTP | other *** search
/ HTML Examples / WP.iso / wordpress / wp-includes / class-wp-dependency.php < prev    next >
Encoding:
PHP Script  |  2017-07-26  |  1.5 KB  |  98 lines

  1. <?php
  2. /**
  3.  * Dependencies API: _WP_Dependency class
  4.  *
  5.  * @since 4.7.0
  6.  *
  7.  * @package WordPress
  8.  * @subpackage Dependencies
  9.  */
  10.  
  11. /**
  12.  * Class _WP_Dependency
  13.  *
  14.  * Helper class to register a handle and associated data.
  15.  *
  16.  * @access private
  17.  * @since 2.6.0
  18.  */
  19. class _WP_Dependency {
  20.     /**
  21.      * The handle name.
  22.      *
  23.      * @since 2.6.0
  24.      * @var null
  25.      */
  26.     public $handle;
  27.  
  28.     /**
  29.      * The handle source.
  30.      *
  31.      * @since 2.6.0
  32.      * @var null
  33.      */
  34.     public $src;
  35.  
  36.     /**
  37.      * An array of handle dependencies.
  38.      *
  39.      * @since 2.6.0
  40.      * @var array
  41.      */
  42.     public $deps = array();
  43.  
  44.     /**
  45.      * The handle version.
  46.      *
  47.      * Used for cache-busting.
  48.      *
  49.      * @since 2.6.0
  50.      * @var bool|string
  51.      */
  52.     public $ver = false;
  53.  
  54.     /**
  55.      * Additional arguments for the handle.
  56.      *
  57.      * @since 2.6.0
  58.      * @var null
  59.      */
  60.     public $args = null;  // Custom property, such as $in_footer or $media.
  61.  
  62.     /**
  63.      * Extra data to supply to the handle.
  64.      *
  65.      * @since 2.6.0
  66.      * @var array
  67.      */
  68.     public $extra = array();
  69.  
  70.     /**
  71.      * Setup dependencies.
  72.      *
  73.      * @since 2.6.0
  74.      */
  75.     public function __construct() {
  76.         @list( $this->handle, $this->src, $this->deps, $this->ver, $this->args ) = func_get_args();
  77.         if ( ! is_array($this->deps) )
  78.             $this->deps = array();
  79.     }
  80.  
  81.     /**
  82.      * Add handle data.
  83.      *
  84.      * @since 2.6.0
  85.      *
  86.      * @param string $name The data key to add.
  87.      * @param mixed  $data The data value to add.
  88.      * @return bool False if not scalar, true otherwise.
  89.      */
  90.     public function add_data( $name, $data ) {
  91.         if ( !is_scalar($name) )
  92.             return false;
  93.         $this->extra[$name] = $data;
  94.         return true;
  95.     }
  96.  
  97. }
  98.