helpers.php
Table of Contents
- asset() : string
- The Asset url.
- assetUrl() : string
- The Asset url only.
- env() : mixed
- Retrieve an environment variable with optional sanitization, encryption, and normalization.
- 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.
- pluginAccessManager() : PluginControl
- 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
- toMillisecond() : mixed
- twigit() : null|Twigit
- Retrieves the Twig configuration file path.
- twig() : Twigit
- Initializes and returns a Twig environment instance.
- isRaydiumDisabled() : bool
- Check if Raydium is disabled.
- getAppThemeDir() : string|null
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()
Retrieve an environment variable with optional sanitization, encryption, and normalization.
env(string $name[, mixed $default = null ][, bool $encrypt = false ][, bool $strtolower = false ][, bool $sysOverride = true ][, bool $syncGlobals = true ]) : mixed
This helper unifies three possible sources of environment values:
-
System environment variables (real OS/Docker/server envs via
getenv()
). -
$_ENV array (often populated by frameworks via
.env
files). - Fallback default (if neither source has a value).
Precedence rules depend on $sysOverride
:
-
When
$sysOverride = true
(default): System env values always override $_ENV/.env values if present. Order of resolution: getenv() > $_ENV > $default -
When
$sysOverride = false
: $_ENV/.env values take priority over system envs. Order of resolution: $_ENV > getenv() > $default
After resolving the raw value, it is passed to the Env instance for whitelist enforcement, optional encryption, normalization, and strtolower().
Notes:
- An empty string
""
is treated as a set value (no fallback). - If
$syncGlobals
is true, the resolved value is written back to both$_ENV
andgetenv()
to keep globals consistent. Disable this in tests or when side effects are undesirable. - Type coercion (e.g. "true" → bool, "123" → int) is handled by the Env class.
Parameters
- $name : string
-
The name of the environment variable to retrieve.
- $default : mixed = null
-
Value returned if not set in either getenv() or $_ENV.
- $encrypt : bool = false
-
Whether to encrypt the retrieved value (default false).
- $strtolower : bool = false
-
Whether to force lowercase output (default false).
- $sysOverride : bool = true
-
Whether system getenv() should override $_ENV values. Default true (12-factor style: system > .env).
- $syncGlobals : bool = true
-
Whether to sync resolved values back to global env via putenv(). Default true.
Tags
Return values
mixed —The resolved, sanitized environment variable value, or $default if not found.
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> —pluginAccessManager()
pluginAccessManager() : PluginControl
Return values
PluginControl —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 —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.
isRaydiumDisabled()
Check if Raydium is disabled.
isRaydiumDisabled() : bool
Return values
bool —Returns true if Raydium is disabled, false otherwise
getAppThemeDir()
getAppThemeDir() : string|null