class-wp-dependency.php 1.5 KB

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