tribe_asset( object|string $origin, string $slug, string $file, array|callable $deps = array(), string|string[]|null $action = null, array $arguments = array() )
Registers an asset.
Contents
Parameters
- $origin
-
(object|string) (Required) The origin of the asset, either a class or a string.
- $slug
-
(string) (Required) The handle of the asset.
- $file
-
(string) (Required) The file of the asset.
- $deps
-
(<span class="array">array|callable) (Optional) The dependencies of the asset; either an array of dependencies or a callable that returns an array of dependencies.
Default value: array()
- $action
-
(string|string[]|null) (Optional) The action(s) to enqueue the asset on; either a string or an array of strings.
Default value: null
- $arguments
-
(array) (Optional) The arguments to pass to the asset.
- 'type'
(string) The type of the asset. - 'media'
(string) The media type of the asset. - 'conditionals'
(string|array) The conditionals to use for the asset. - 'groups'
(string|array) The groups to add the asset to. - 'print_before'
(string|array) The print_before to use for the asset. - 'print_after'
(string|array) The print_after to use for the asset. - 'localize'
(array) The localization data for the asset. One or more of the following:- 'name'
(string) The name of the localization data. - 'data'
(array|callable) The data to use for the localization.
- 'name'
- 'translations'
(array) The translations to use for the asset.- 'domain'
(string) The domain to use for the translations. - 'path'
(string) The path to use for the translations.
- 'domain'
- 'after_enqueue'
(bool) Whether to call a callback after enqueuing the asset. - 'in_footer'
(bool) Whether to enqueue the asset in the footer. - 'module'
(bool) Whether to set the asset as a module. - 'defer'
(bool) Whether to set the asset as deferred. - 'async'
(bool) Whether to set the asset as asynchronous. - 'print'
(bool) Whether to print the asset.
Default value: array()
- 'type'
Return
(TECCommonStellarWPAssetsAsset|false) The asset that was registered or false on error.
Source
File: src/functions/template-tags/general.php
function tribe_asset( $origin, $slug, $file, $deps = array(), $action = null, $arguments = array() ) {
return tribe( 'assets' )->register( $origin, $slug, $file, $deps, $action, $arguments );
}
Changelog
| Version | Description |
|---|---|
| 5.3.0 | Replaced the function internals with calls to the stellarwp/assets library. |
| 4.3 | Introduced. |