views
Table of Contents
Functions
- MenuActiveClass() : string
- Returns CSS class string if the current URL matches the menu item URL.
- IsExternalUrl() : bool
- Checks if a URL points to an external site.
- ExternalTarget() : string
- Returns the target attribute for external links.
- MenuTitle() : string
- Returns the translated and formatted menu item title.
Functions
MenuActiveClass()
Returns CSS class string if the current URL matches the menu item URL.
MenuActiveClass(string $current_url, string $item_url[, string $active_class = ' active' ]) : string
Parameters
- $current_url : string
-
The current page URL.
- $item_url : string
-
The menu item URL to compare.
- $active_class : string = ' active'
-
The CSS class to return when active.
Return values
string —The active class string or empty string.
IsExternalUrl()
Checks if a URL points to an external site.
IsExternalUrl(string $url) : bool
Parameters
- $url : string
-
The URL to check.
Return values
bool —True if the URL is external.
ExternalTarget()
Returns the target attribute for external links.
ExternalTarget(string|bool $url_or_is_external) : string
Accepts either a URL string or a pre-computed boolean from IsExternalUrl().
Parameters
- $url_or_is_external : string|bool
-
URL to check, or boolean result of IsExternalUrl().
Return values
string —' target="_blank"' for external URLs, empty string otherwise.
MenuTitle()
Returns the translated and formatted menu item title.
MenuTitle(array<string|int, mixed> $voice[, bool $ucfirst = true ]) : string
Parameters
- $voice : array<string|int, mixed>
-
The menu item array with 'title' and/or 'name' keys.
- $ucfirst : bool = true
-
Whether to capitalize the first letter.
Return values
string —The formatted title.