[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/ -> class-wp-dependency.php (source)

   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  #[AllowDynamicProperties]
  20  class _WP_Dependency {
  21      /**
  22       * The handle name.
  23       *
  24       * @since 2.6.0
  25       * @var string
  26       */
  27      public $handle;
  28  
  29      /**
  30       * The handle source.
  31       *
  32       * If source is set to false, the item is an alias of other items it depends on.
  33       *
  34       * @since 2.6.0
  35       * @var string|false
  36       */
  37      public $src;
  38  
  39      /**
  40       * An array of handle dependencies.
  41       *
  42       * @since 2.6.0
  43       * @var string[]
  44       */
  45      public $deps = array();
  46  
  47      /**
  48       * The handle version.
  49       *
  50       * Used for cache-busting.
  51       *
  52       * @since 2.6.0
  53       * @var bool|string
  54       */
  55      public $ver = false;
  56  
  57      /**
  58       * Additional arguments for the handle.
  59       *
  60       * @since 2.6.0
  61       * @var array
  62       */
  63      public $args = null;  // Custom property, such as $in_footer or $media.
  64  
  65      /**
  66       * Extra data to supply to the handle.
  67       *
  68       * @since 2.6.0
  69       * @var array
  70       */
  71      public $extra = array();
  72  
  73      /**
  74       * Translation textdomain set for this dependency.
  75       *
  76       * @since 5.0.0
  77       * @var string
  78       */
  79      public $textdomain;
  80  
  81      /**
  82       * Translation path set for this dependency.
  83       *
  84       * @since 5.0.0
  85       * @var string
  86       */
  87      public $translations_path;
  88  
  89      /**
  90       * Setup dependencies.
  91       *
  92       * @since 2.6.0
  93       * @since 5.3.0 Formalized the existing `...$args` parameter by adding it
  94       *              to the function signature.
  95       *
  96       * @param mixed ...$args Dependency information.
  97       */
  98  	public function __construct( ...$args ) {
  99          list( $this->handle, $this->src, $this->deps, $this->ver, $this->args ) = $args;
 100          if ( ! is_array( $this->deps ) ) {
 101              $this->deps = array();
 102          }
 103      }
 104  
 105      /**
 106       * Add handle data.
 107       *
 108       * @since 2.6.0
 109       *
 110       * @param string $name The data key to add.
 111       * @param mixed  $data The data value to add.
 112       * @return bool False if not scalar, true otherwise.
 113       */
 114  	public function add_data( $name, $data ) {
 115          if ( ! is_scalar( $name ) ) {
 116              return false;
 117          }
 118          $this->extra[ $name ] = $data;
 119          return true;
 120      }
 121  
 122      /**
 123       * Sets the translation domain for this dependency.
 124       *
 125       * @since 5.0.0
 126       *
 127       * @param string $domain The translation textdomain.
 128       * @param string $path   Optional. The full file path to the directory containing translation files.
 129       * @return bool False if $domain is not a string, true otherwise.
 130       */
 131  	public function set_translations( $domain, $path = '' ) {
 132          if ( ! is_string( $domain ) ) {
 133              return false;
 134          }
 135          $this->textdomain        = $domain;
 136          $this->translations_path = $path;
 137          return true;
 138      }
 139  }


Generated : Fri Apr 19 08:20:01 2024 Cross-referenced by PHPXref