assets.php
Register styles and scripts. Enqueue child theme sytylesheet.
- This method of handling of asset path and uri is the pattern to use going forward.
- The child theme stylesheet (style.css) is re-enqueued to ensure it is loaded after the parent theme styles, and thus can override them.
- The asset must NOT start with a leading slash. It is relative to the assets directory.
Tags
Table of Contents
Functions
- register_styles() : void
- Register styles.
- enqueue_assets() : void
- Enqueue the scripts and styles.
- requeue_child_assets() : void
- Dequeue and enqueue the child theme styles.
- get_asset_path() : string
- Return the asset filepath.
- get_asset_uri() : string
- Return the asset URI.
- get_asset_version() : string
- Return the version.
Functions
register_styles()
Register styles.
register_styles() : void
- The asset must NOT start with a leading slash. It is relative to the assets directory.
Tags
enqueue_assets()
Enqueue the scripts and styles.
enqueue_assets() : void
Tags
requeue_child_assets()
Dequeue and enqueue the child theme styles.
requeue_child_assets() : void
- This is necessary to ensure the child theme stylesheet is enqueued after the parent theme styles, and thus can override them.
Tags
get_asset_path()
Return the asset filepath.
get_asset_path(string $asset) : string
Parameters
- $asset : string
-
The target asset - no leading slash.
Tags
Return values
string —The resource filesystem path.
get_asset_uri()
Return the asset URI.
get_asset_uri(string $asset) : string
Parameters
- $asset : string
-
The target asset - no leading slash.
Tags
Return values
string —The resource URL.
get_asset_version()
Return the version.
get_asset_version(string $asset) : string
Parameters
- $asset : string
-
The fully qualified server file path of the target asset.
Tags
Return values
string —The resource version.