API Reference

Complete API for all Assets classes.

Asset (Abstract)

Base class for all assets.

MethodReturnDescription
src(string $path)staticSet source path relative to plugin
url(string $url)staticSet absolute URL
dependencies(array $deps)staticSet WP dependency handles
version(string $ver)staticSet asset version
condition(callable $cb)staticConditional enqueue
admin()staticAdmin pages only
front()staticFrontend only
onPage(string $hook)staticSpecific admin page
inline(string $code)staticAdd inline code after asset
shouldEnqueue(string $hook)boolCheck if asset should load
getHandle()stringGet prefixed handle
getLocation()stringGet location (front/admin/both)
enqueue()voidRegister and enqueue
register()voidRegister without enqueueing
deregister()voidDeregister asset

ScriptAsset

Extends Asset for JavaScript files.

MethodReturnDescription
inFooter()staticLoad in footer
async()staticAdd async attribute
defer()staticAdd defer attribute
module()staticSet type="module"
noModule()staticSet nomodule attribute
localize(string $name, array $data)staticwp_localize_script

StyleAsset

Extends Asset for CSS stylesheets.

MethodReturnDescription
media(string $media)staticSet media attribute
preload()staticAdd preload link hint

AssetManager

Central asset factory and registry.

MethodReturnDescription
script(string $handle)ScriptAssetCreate a script asset
style(string $handle)StyleAssetCreate a style asset
enqueueAll(string $loc, string $hook)voidEnqueue matching assets
getRegistered()Asset[]Get all registered assets

ViteAssetResolver

Vite manifest reader and dev server integration.

MethodReturnDescription
isDev()boolCheck if dev server is running
getDevServerUrl()stringGet dev server URL
resolve(string $entry)array|nullResolve manifest entry
enqueueEntry(string $entry, string $handle, array $deps)voidEnqueue entry (auto dev/prod)

resolve() Return Format

[
    'url' => 'https://example.com/dist/assets/main-abc123.js',
    'css' => [
        'https://example.com/dist/assets/main-def456.css',
    ],
    'imports' => [
        'https://example.com/dist/assets/vendor-ghi789.js',
    ],
]

AssetsServiceProvider

MethodDescription
register(ApplicationInterface $app)Registers AssetManager, ViteAssetResolver, aliases
boot(ApplicationInterface $app)Hooks into wp_enqueue_scripts and admin_enqueue_scripts