helpers.php
Table of Contents
- asset() : string
- The Asset url.
- assetUrl() : string
- The Asset url only.
- env() : mixed
- Retrieves a sanitized, and optionally encrypted or modified, environment variable by name.
- appOptionsDir() : string|null
- configs() : mixed
- Retrieves configuration data using dot notation.
- cleanSensitiveEnv() : void
- Cleans up sensitive environment variables.
- localConfigsDir() : string
- isMultitenantApp() : bool
- Determines if the application is configured to operate in multi-tenant mode.
- getWpframeworkHttpEnv() : string|null
- setMultitenantUploadDirectory() : array<string|int, mixed|string>
- Sets the upload directory to a tenant-specific location.
- frameworkFooterLabel() : string
- Custom admin footer text.
- frameworkCurrentThemeInfo() : array<string|int, bool|string>
- exitWithThemeError() : void
- logMessage() : void
- Logs a message with the specified level and an optional log file.
- logWithStackTrace() : void
- customHeaderMiddleware() : void
- toMillisecond() : mixed
- twigit() : null|Twigit
- Retrieves the Twig configuration file path.
- twig() : Twigit
- Initializes and returns a Twig environment instance.
Functions
asset()
The Asset url.
asset(string $asset[, null|string $path = null ]) : string
Parameters
- $asset : string
-
path to the asset like: "/images/thing.png"
- $path : null|string = null
Return values
string —assetUrl()
The Asset url only.
assetUrl([null|string $path = null ]) : string
Parameters
- $path : null|string = null
Return values
string —env()
Retrieves a sanitized, and optionally encrypted or modified, environment variable by name.
env(string $name[, mixed $default = null ][, bool $encrypt = false ][, bool $strtolower = false ]) : mixed
Parameters
- $name : string
-
The name of the environment variable to retrieve.
- $default : mixed = null
-
Default value to return if the environment variable is not set.
- $encrypt : bool = false
-
Indicate if the value should be encrypted. Defaults to false.
- $strtolower : bool = false
-
Whether to convert the retrieved value to lowercase. Defaults to false.
Tags
Return values
mixed —The sanitized environment variable value, possibly encrypted or typecast, or transformed to lowercase if specified.
appOptionsDir()
appOptionsDir() : string|null
Return values
string|null —configs()
Retrieves configuration data using dot notation.
configs() : mixed
This function allows easy access to nested configuration data through dot notation syntax.
Tags
Return values
mixed —The full configuration object is returned.
cleanSensitiveEnv()
Cleans up sensitive environment variables.
cleanSensitiveEnv(array<string|int, mixed> $sensitives) : void
This function removes specified environment variables from the $_ENV superglobal and the environment to help secure sensitive information.
Parameters
- $sensitives : array<string|int, mixed>
-
An array of environment variable names to be cleaned up.
Return values
void —localConfigsDir()
localConfigsDir() : string
Return values
string —isMultitenantApp()
Determines if the application is configured to operate in multi-tenant mode.
isMultitenantApp() : bool
This is based on the presence and value of the IS_MULTITENANT
constant.
If IS_MULTITENANT
is defined and set to true
, the application is
considered to be in multi-tenant mode.
Return values
bool —Returns true
if the application is in multi-tenant mode, otherwise false
.
getWpframeworkHttpEnv()
getWpframeworkHttpEnv() : string|null
Return values
string|null —setMultitenantUploadDirectory()
Sets the upload directory to a tenant-specific location.
setMultitenantUploadDirectory(array<string|int, mixed> $dir) : array<string|int, mixed|string>
This function modifies the default WordPress upload directory paths to store tenant-specific uploads in a separate folder based on the tenant ID. It ensures that each tenant's uploads are organized and stored in an isolated directory.
Parameters
- $dir : array<string|int, mixed>
-
The array containing the current upload directory's path and URL.
Tags
Return values
array<string|int, mixed|string> —frameworkFooterLabel()
Custom admin footer text.
frameworkFooterLabel() : string
Return values
string —The formatted footer text.
frameworkCurrentThemeInfo()
frameworkCurrentThemeInfo() : array<string|int, bool|string>
Tags
Return values
array<string|int, bool|string> —exitWithThemeError()
exitWithThemeError(array<string|int, mixed> $themeInfo) : void
Parameters
- $themeInfo : array<string|int, mixed>
Return values
void —logMessage()
Logs a message with the specified level and an optional log file.
logMessage(string $message[, string $level = 'info' ][, array<string|int, mixed> $context = [] ][, null|string $logFile = null ]) : void
Parameters
- $message : string
-
The log message.
- $level : string = 'info'
-
The log level (e.g., 'info', 'error', 'debug', etc.).
- $context : array<string|int, mixed> = []
-
Optional context data for the log message.
- $logFile : null|string = null
-
Optional log file to use. If null, the default or fallback will be used.
Return values
void —logWithStackTrace()
logWithStackTrace() : void
Return values
void —customHeaderMiddleware()
customHeaderMiddleware(App $app) : void
Parameters
- $app : App
Return values
void —toMillisecond()
toMillisecond(float $seconds) : mixed
Parameters
- $seconds : float
Return values
mixed —twigit()
Retrieves the Twig configuration file path.
twigit() : null|Twigit
This function allows users to define their own Twig configuration file. If a custom configuration file exists at the specified path, it will be used. Otherwise, the default framework Twig configuration file is returned.
Return values
null|Twigit —The file path to the Twig configuration file.
twig()
Initializes and returns a Twig environment instance.
twig([array<string|int, mixed> $options = [] ][, array<string|int, mixed> $templates = [] ]) : Twigit
This function configures the Twig environment using the specified templates directory path and optional environment settings.
Twig environment options can be passed as an associative array to customize the behavior of the environment. Refer to the Twig documentation for a full list of available options.
Parameters
- $options : array<string|int, mixed> = []
- $templates : array<string|int, mixed> = []
Tags
Return values
Twigit —The initialized Twig environment instance.