pfeifferNet

assets.php

Manage child theme scripts and styles.

  • The child theme stylesheet (style.css) is requeued to ensure it is loaded after the parent theme styles.
Tags
since
5.9.0
6.8.0

Improve asset enqueueing and conditional loading.

6.8.0

Improve recipe detection by looking for the WPRM recipe block.

copyright

2024 Keith Pfeiffer

Table of Contents

Functions

register_scripts()  : void
Register scripts.
register_styles()  : void
Register styles.
enqueue_assets()  : void
Enqueue the scripts and styles.
requeue_child_assets()  : void
Dequeue then requeue the child theme styles.
get_asset_path()  : string
Return the asset path.
get_asset_uri()  : string
Return the asset URI.
get_asset_url()  : string
Return the asset URL (with version).
get_asset_version()  : string
Return the version.
get_style_tag()  : string
Create a stylesheet link tag.

Functions

register_scripts()

Register scripts.

register_scripts() : void
  • The asset must start with a leading slash. It is relative to the assets directory.
Tags
since
5.9.0
6.0.0

Change asset path, uri and version handling.

register_styles()

Register styles.

register_styles() : void
  • The asset must start with a leading slash. It is relative to the assets directory.
Tags
since
5.9.0
6.0.0

Change asset path, uri and version handling.

enqueue_assets()

Enqueue the scripts and styles.

enqueue_assets() : void
Tags
since
5.9.0
6.8.0

Improve recipe detection by looking for the WPRM recipe block.

6.8.0

Improve conditional block assets loading.

uses
Lightbox::enqueue_assets()
GenerateBlocks_Block_Accordion::enqueue_assets()

requeue_child_assets()

Dequeue then requeue the child theme styles.

requeue_child_assets() : void
  • This is to ensure the child theme stylesheet is enqueued after the parent theme styles.
Tags
since
6.8.0

get_asset_path()

Return the asset path.

get_asset_path(string $asset) : string
Parameters
$asset : string

The target asset.

Tags
since
6.0.0
Return values
string

The fully qualified filesystem path to the asset.

get_asset_uri()

Return the asset URI.

get_asset_uri(string $asset) : string
Parameters
$asset : string

The target asset.

Tags
since
6.0.0
Return values
string

The resource URI.

get_asset_url()

Return the asset URL (with version).

get_asset_url(string $asset) : string
Parameters
$asset : string

The target asset.

Tags
since
5.9.0
6.2.0

Simplify variables and url construction.

Return values
string

The resource URL including version info.

get_asset_version()

Return the version.

get_asset_version(string $asset_path) : string
Parameters
$asset_path : string

The fully qualified asset path.

Tags
since
5.9.0
6.0.0

Parameter changed to require the full path.

Return values
string

The resource version.

get_style_tag()

Create a stylesheet link tag.

get_style_tag(string $asset) : string
  • Allow direct loading of stylesheets where wp_enqueue is not used.
Parameters
$asset : string

The path of the stylesheet.

Tags
since
5.9.0
Return values
string

The link tag markup.


        
On this page

Search results