[ 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       *
  91       * @param ...$args Dependency information.
  92       */
  93  	public function __construct( ...$args ) {
  94          list( $this->handle, $this->src, $this->deps, $this->ver, $this->args ) = $args;
  95          if ( ! is_array( $this->deps ) ) {
  96              $this->deps = array();
  97          }
  98      }
  99  
 100      /**
 101       * Add handle data.
 102       *
 103       * @since 2.6.0
 104       *
 105       * @param string $name The data key to add.
 106       * @param mixed  $data The data value to add.
 107       * @return bool False if not scalar, true otherwise.
 108       */
 109  	public function add_data( $name, $data ) {
 110          if ( ! is_scalar( $name ) ) {
 111              return false;
 112          }
 113          $this->extra[ $name ] = $data;
 114          return true;
 115      }
 116  
 117      /**
 118       * Sets the translation domain for this dependency.
 119       *
 120       * @since 5.0.0
 121       *
 122       * @param string $domain The translation textdomain.
 123       * @param string $path   Optional. The full file path to the directory containing translation files.
 124       *
 125       * @return bool False if $domain is not a string, true otherwise.
 126       */
 127  	public function set_translations( $domain, $path = null ) {
 128          if ( ! is_string( $domain ) ) {
 129              return false;
 130          }
 131          $this->textdomain        = $domain;
 132          $this->translations_path = $path;
 133          return true;
 134      }
 135  }


Generated: Mon Sep 23 01:00:03 2019 Cross-referenced by PHPXref 0.7.1