Utils
in package
Utils class
Table of Contents
- get_absolute_script_url() : string
- Resolve a (possibly relative) script src to an absolute URL the same way WordPress core does in WP_Scripts::do_item(): a relative src is resolved against the scripts base URL (the site URL), unless it already points at the content directory. This keeps the resulting URL consistent with what WordPress itself would emit, including on non-default directory layouts (e.g. a custom WP_CONTENT_DIR/WP_CONTENT_URL).
- wp_version_compare() : bool|int
- Compare the current WordPress version with a given version. It's a wrapper around `version-compare` that additionally takes into account the suffix (like `-RC1`).
Methods
get_absolute_script_url()
Resolve a (possibly relative) script src to an absolute URL the same way WordPress core does in WP_Scripts::do_item(): a relative src is resolved against the scripts base URL (the site URL), unless it already points at the content directory. This keeps the resulting URL consistent with what WordPress itself would emit, including on non-default directory layouts (e.g. a custom WP_CONTENT_DIR/WP_CONTENT_URL).
public
static get_absolute_script_url(string $src) : string
Parameters
- $src : string
-
The script src, which may be relative or absolute.
Return values
string — The absolute script URL.wp_version_compare()
Compare the current WordPress version with a given version. It's a wrapper around `version-compare` that additionally takes into account the suffix (like `-RC1`).
public
static wp_version_compare(string $version[, string|null $operator = null ]) : bool|int
For example: version 6.3 is considered lower than 6.3-RC2, so you can do wp_version_compare( '6.3', '>=' ) and that will return true for 6.3-RC2.
Parameters
- $version : string
-
The version to compare against.
- $operator : string|null = null
-
Optional. The comparison operator. Defaults to null.
