[ Index ]

PHP Cross Reference of WordPress

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  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       * Translation textdomain set for this dependency.
  72       *
  73       * @since 5.0.0
  74       * @var string
  75       */
  76      public $textdomain;
  77  
  78      /**
  79       * Translation path set for this dependency.
  80       *
  81       * @since 5.0.0
  82       * @var string
  83       */
  84      public $translations_path;
  85  
  86      /**
  87       * Setup dependencies.
  88       *
  89       * @since 2.6.0
  90       * @since 5.3.0 Formalized the existing `...$args` parameter by adding it
  91       *              to the function signature.
  92       *
  93       * @param ...$args Dependency information.
  94       */
  95  	public function __construct( ...$args ) {
  96          list( $this->handle, $this->src, $this->deps, $this->ver, $this->args ) = $args;
  97          if ( ! is_array( $this->deps ) ) {
  98              $this->deps = array();
  99          }
 100      }
 101  
 102      /**
 103       * Add handle data.
 104       *
 105       * @since 2.6.0
 106       *
 107       * @param string $name The data key to add.
 108       * @param mixed  $data The data value to add.
 109       * @return bool False if not scalar, true otherwise.
 110       */
 111  	public function add_data( $name, $data ) {
 112          if ( ! is_scalar( $name ) ) {
 113              return false;
 114          }
 115          $this->extra[ $name ] = $data;
 116          return true;
 117      }
 118  
 119      /**
 120       * Sets the translation domain for this dependency.
 121       *
 122       * @since 5.0.0
 123       *
 124       * @param string $domain The translation textdomain.
 125       * @param string $path   Optional. The full file path to the directory containing translation files.
 126       *
 127       * @return bool False if $domain is not a string, true otherwise.
 128       */
 129  	public function set_translations( $domain, $path = null ) {
 130          if ( ! is_string( $domain ) ) {
 131              return false;
 132          }
 133          $this->textdomain        = $domain;
 134          $this->translations_path = $path;
 135          return true;
 136      }
 137  }


Generated: Mon Dec 9 01:00:03 2019 Cross-referenced by PHPXref 0.7.1