Deepdives
Helpers
Overview
Helpers are functions that can be used in any part of the application. They are globally available and can be used anywhere in the application.
The project has a helpers.php file in the app directory. This file contains all the helper functions that are used in the application.
List of Helpers
| Function Name | Description |
|---|---|
googleRecaptchaScript | Embeds Google reCAPTCHA script if captcha is enabled. |
checked | Returns 'checked' if two values are equal. |
selected | Returns 'selected' if two values are equal. |
isOtherTitleSelected | Returns 'selected' if a key is not present in the search array. |
removeNewlines | Removes extra whitespaces and newlines from a string. |
isApp | Checks if a cookie named 'minimalTheme' exists. |
isEU | Checks if the core region is not UK. |
__d | Translates a key and returns the default value if the translation key matches the translation result. |
wordpressImage | Returns the image URL if available, otherwise returns the original image. |
str_words | Truncates a string to a specified number of words. |
excluding_vat | Formats a price with or without the "ex-VAT" label based on the core region. |
clean | Strips HTML tags from a given string. |
app_version | Retrieves the application version from the composer.json file. |
_tsrcSorted | Accesses regional configuration under the toolstation namespace and returns it sorted alphabetically. |
superscriptable | Converts specified substrings to their corresponding superscript form based on configuration. |