Tribe__Assets::register_in_wp( array|object|null $assets = null )
Register the Assets on the correct hooks.
Contents
Parameters
- $assets
-
(array|object|null) (Optional) Array of asset objects, single asset object, or null.
Default value: null
Return
(void)
Source
File: src/Tribe/Assets.php
public function register_in_wp( $assets = null ) {
if ( is_null( $assets ) ) {
$assets = $this->assets;
}
if ( ! is_array( $assets ) ) {
$assets = array( $assets );
}
uasort( $assets, array( $this, 'order_by_priority' ) );
foreach ( $assets as $asset ) {
if ( 'js' === $asset->type ) {
wp_register_script( $asset->slug, $asset->url, $asset->deps, $asset->version, $asset->in_footer );
} else {
wp_register_style( $asset->slug, $asset->url, $asset->deps, $asset->version, $asset->media );
}
// Register that this asset is actually registered on the WP methods
$asset->is_registered = true;
// If we don't have an action we don't even register the action to enqueue
if ( empty( $asset->action ) ) {
continue;
}
// Now add an action to enqueue the registered assets
foreach ( (array) $asset->action as $action ) {
// Enqueue the registered assets at the appropriate time
if ( did_action( $action ) > 0 ) {
$this->enqueue();
} else {
add_action( $action, array( $this, 'enqueue' ), $asset->priority );
}
}
}
}
Changelog
| Version | Description |
|---|---|
| 4.3 | Introduced. |