ExcludeAssets
in package
Use this class to exclude JavaScript and Stylesheets from caching plugins.
Initialize this class in your init
action!
Tags
Table of Contents
Constants
- EXCLUDE_STYLE_TAG_FROM_RUCSS_PROCESS_ATTRIBUTE = 'skip-rucss'
Properties
- $handles : mixed
- Handles to block.
- $pluginReceiver : mixed
Methods
- __construct() : mixed
- C'tor.
- byHandle() : mixed
- Exclude a given handle.
- getAllUrlPath() : mixed
- Get all URL path without query arguments and leading slash.
- getAllUrls() : mixed
- Get all (full) URLs of our dependencies.
- getDependencies() : array<string|int, _WP_Dependency>
- Get `_WP_Dependency` for all available assets.
- getHandles() : mixed
- Getter.
- getInlineScripts() : array<string|int, string>
- Get a list of to excluding inline scripts. E.g. when excluding a JavaScript which gets an additional `wp_localize_script`, this method will return `['var realCookieBanner =']`.
- getUrlPath() : mixed
- Get only the URL path without query arguments and leading slash.
- hasFailureSupportPluginActive() : mixed
- Checks if the current WordPress instance has a plugin active which does in general support the exclusion of assets, but doing this will result in a defect page or is not supported programmatically atm.
- init() : mixed
- Initialize the hook for active cache plugins and pass down the `WP_Dependency` to the abstract implementation.
Constants
EXCLUDE_STYLE_TAG_FROM_RUCSS_PROCESS_ATTRIBUTE
public
mixed
EXCLUDE_STYLE_TAG_FROM_RUCSS_PROCESS_ATTRIBUTE
= 'skip-rucss'
Properties
$handles
Handles to block.
private
mixed
$handles
= ['js' => [], 'css' => []]
$pluginReceiver
private
mixed
$pluginReceiver
Methods
__construct()
C'tor.
public
__construct(PluginReceiver $pluginReceiver) : mixed
Parameters
- $pluginReceiver : PluginReceiver
Tags
byHandle()
Exclude a given handle.
public
byHandle(string $type, string|array<string|int, string> $handles) : mixed
Parameters
- $type : string
-
Can be
css
orjs
- $handles : string|array<string|int, string>
-
Registered handle via
wp_enqueue_script
getAllUrlPath()
Get all URL path without query arguments and leading slash.
public
getAllUrlPath(string $type) : mixed
Parameters
- $type : string
-
Can be
css
orjs
getAllUrls()
Get all (full) URLs of our dependencies.
public
getAllUrls(string $type) : mixed
Parameters
- $type : string
-
Can be
css
orjs
getDependencies()
Get `_WP_Dependency` for all available assets.
public
getDependencies(string $type) : array<string|int, _WP_Dependency>
Parameters
- $type : string
-
Can be
css
orjs
Return values
array<string|int, _WP_Dependency>getHandles()
Getter.
public
getHandles() : mixed
Tags
getInlineScripts()
Get a list of to excluding inline scripts. E.g. when excluding a JavaScript which gets an additional `wp_localize_script`, this method will return `['var realCookieBanner =']`.
public
getInlineScripts(string $type) : array<string|int, string>
Parameters
- $type : string
-
Can be
css
orjs
Return values
array<string|int, string>getUrlPath()
Get only the URL path without query arguments and leading slash.
public
getUrlPath(_WP_Dependency $dep) : mixed
Parameters
- $dep : _WP_Dependency
hasFailureSupportPluginActive()
Checks if the current WordPress instance has a plugin active which does in general support the exclusion of assets, but doing this will result in a defect page or is not supported programmatically atm.
public
hasFailureSupportPluginActive() : mixed
init()
Initialize the hook for active cache plugins and pass down the `WP_Dependency` to the abstract implementation.
public
init() : mixed