Filter
rpress_get_asset_url
On this page
Filters the URL of a bundled frontend script or stylesheet.
Runs for every plugin asset that RP_Frontend_Scripts registers through its private get_asset_url() helper, including the stylesheets in the rpress_enqueue_styles list. The default is plugins_url() for the given path relative to the main plugin file. Use it to serve assets from a CDN or a custom location.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$url | string | Default asset URL. |
$path | string | Asset path relative to the plugin root, for example assets/css/chosen.css. |
Return value#
string. The asset URL.
Example#
function my_asset_url( $url, $path ) {
// Serve plugin assets from a CDN.
return str_replace( home_url(), 'https://cdn.example.com', $url );
}
add_filter( 'rpress_get_asset_url', 'my_asset_url', 10, 2 );
Notes#
Fires once per asset on each page that registers scripts or builds the style list.
Source#
Applied in:
includes/class-rpress-frontend-scripts.php(line 52), inRP_Frontend_Scripts::get_asset_url()
See also#
Was this page helpful?
