includes/Assets/class-asset-manager.php
Asset Manager functionality.
Class Asset_Manager
Class Asset_Manager
class Asset_ManagerConstants
| Constant | Visibility | Value | Line |
|---|---|---|---|
TRANSIENT_PREFIX | public | \'wppo_page_assets_\' | 35 |
Properties
| Property | Visibility | Type | Default | Line |
|---|---|---|---|---|
$protected_scripts | private static | array | array( \'jquery\', \'jquery-core\', \'jquery-migrate\', \'wp-i18n\', \'wp-hooks\', \'wp-api-fetch\', \'wp-url\', \'wp-polyfill\', \'admin-bar\', \'heartbeat\', ) | 43 |
$protected_styles | private static | array | array( \'admin-bar\', \'dashicons\', \'wp-block-library\', ) | 62 |
$size_cache | private static | array | array() | 77 |
public __construct()
public function __construct()Constructor.
public dequeue_selected_assets()
public function dequeue_selected_assets(): voidDequeue and deregister assets that the admin has disabled for this post.
Return: void.
public capture_page_assets()
public function capture_page_assets(): voidCapture all enqueued scripts and styles on the current page.
Return: void.
publicstatic resolve_asset_size()
public static function resolve_asset_size($src)Resolve the on-disk size of an enqueued asset source. Parameter Type Default Description $srcstring— The registered asset `src` (URL or path).
Return: int|null — Local file size in bytes, or null when unknown.
publicstatic get_asset_suggestions()
public static function get_asset_suggestions($assets, =51200 $threshold)Suggest heavy, non-protected assets worth reviewing for this page. Parameter Type Default Description $assetsarray— Captured page assets (`scripts`/`styles` lists). $threshold=51200— Minimum size in bytes for a suggestion. Defaults to 50 KB.
Return: array — List of `array( \’type\’ => \’script\’|\’style\’, \’handle\’ => string, \’size\’ => int )`.
publicstatic get_page_assets()
public static function get_page_assets($post_id)Get captured assets for a specific post. Parameter Type Default Description $post_idint— The post ID to get assets for.
Return: array|false — The captured assets array, or false if not found.
publicstatic get_protected_scripts()
public static function get_protected_scripts()Get the list of protected script handles.
Return: array — List of protected script handles.
publicstatic get_protected_styles()
public static function get_protected_styles()Get the list of protected style handles.
Return: array — List of protected style handles.
Hooks
Hooks referenced in includes/Assets/class-asset-manager.php: Hook Type Line Notes wppo_page_asset_sizefilter 277 — wppo_asset_suggestion_thresholdfilter 330 —