GC_Dependencies::add()

最后更新于:2021-11-27 14:05:34

GC_Dependencies::add( string$handle, string|bool$src, string[]$deps=array(), string|bool|null$ver=false, mixed$args=null)

Register an item.

参数

$handle

(string) (Required) Name of the item. Should be unique.

$src

(string|bool) (Required) Full URL of the item, or path of the item relative to the GeChiUI root directory. If source is set to false, item is an alias of other items it depends on.

$deps

(string[]) (Optional) An array of registered item handles this item depends on.

Default value: array()

$ver

(string|bool|null) (Optional) String specifying item version number, if it has one, which is added to the URL as a query string for cache busting purposes. If version is set to false, a version number is automatically added equal to current installed GeChiUI version. If set to null, no version is added.

Default value: false

$args

(mixed) (Optional) Custom property of the item. NOT the class property $args. Examples: $media, $in_footer.

Default value: null

响应

(bool) Whether the item has been registered. True on success, false on failure.

源文件

文件: gc-includes/class.gc-dependencies.php

	public function add( $handle, $src, $deps = array(), $ver = false, $args = null ) {
		if ( isset( $this->registered[ $handle ] ) ) {
			return false;
		}
		$this->registered[ $handle ] = new _GC_Dependency( $handle, $src, $deps, $ver, $args );
		return true;
	}