Link Search Menu Expand Document

Application Helpers

Inpsyde\Vip\isWebRequest()

function isWebRequest(): bool

Returns true when a request is a “regular user request” from the web.

It excludes CLI, REST, AJAX, XML-RPC, health check and other system requests, and requests in maintenance mode.

Inpsyde\Vip\determineVipEnv()

function determineVipEnv(): string

Determine the environment name of the VIP application.

Inpsyde\Vip\determineWpEnv()

function determineWpEnv(): string

Determine the environment name of the VIP application. Similar to wp_get_environment_type(), it returns one of the four values supported by that function, but this can be called earlier, and it is calculated based on VIP environment.

Inpsyde\Vip\isLocalEnv()

function isLocalEnv(): bool

Returns true when WP environment type is “local”.

Inpsyde\Vip\isProdEnv()

function isProdEnv(): bool

Returns true when WP environment type is “production”.

Inpsyde\Vip\privateDirPath()

function privateDirPath(): string

The path of the /private directory determine via WPCOM_VIP_PRIVATE_DIR, with fallback for local environments.

Inpsyde\Vip\vipConfigPath()

function vipConfigPath(): string

The path of the /vip-config directory.

Inpsyde\Vip\earlyRedirect()

function earlyRedirect(string $location, int $status = 301): void

Similar to wp_redirect() but can be called before WP is loaded, ands sets X-Redirect-By header.

Inpsyde\Vip\isSsl()

function isSsl(): bool

Similar to is_ssl() but can be called before WP is loaded. Fallbacks to WP’s is_ssl() if that’s available.

Inpsyde\Vip\currentUrlPath()

function currentUrlPath(): string

Return current URL path, similar to what is possible to obtain via add_query_arg([]), but can be called before WP is loaded.

Inpsyde\Vip\currentUrlHost()

function currentUrlHost(): string

Return current host based on HTTP header, removing any port information.

Don’t trust it: might be changed by clients.

Inpsyde\Vip\buildFullRedirectUrlFor()

function buildFullRedirectUrlFor(
    string $base,
    bool $preservePath = true,
    bool $preserveQuery = true
): ?string

Takes a domain or a full URL as input, ensures it is a full absolute URL (prepending the HTTP schema if necessary).

Based on the additional parameters, append the current URL path and/or query string to the obtained URL.

Inpsyde\Vip\mergeQueryVars()

function mergeQueryVars(string $url, array $vars): string

Merge given data as query variables to the given URL. Similar to what one can obtain calling add_query_arg() can do, but can this function be called before WP is loaded.

Inpsyde\Vip\deployIdFile()

function deployIdFile(): ?string

The path of the deploy-id file generated by composer vip command. Null if not found.

Inpsyde\Vip\deployId()

function deployId(): ?string

The content of “deploy-id” file generated by composer vip command.

Excluding production, a random string returned if the file is not found. The reason for that is this ID is often used to invalidate cache, and so it makes sense to fall back to an always-changing random value when not in production.

Inpsyde\Vip\deployVersion()

function deployVersion(): ?string

The content of the deploy-version file generated by composer vip command. Null if not found.

Inpsyde\Vip\loadSunriseConfigForDomain()

function loadSunriseConfigForDomain(string $domain): array

Load the configuration for redirections and domain mapping for a specific domain.

Inpsyde\Vip\loadConfigFiles()

function loadConfigFiles(): void

Loads env-specific configuration files from the vip-config/env folder.

This is called from a MU plugin delivered with this plugin.

Inpsyde\Vip\skip2faForAutotestRequest()

function skip2faForAutotestRequest(): void

During request made for automated tests, sets the WP_RUN_CORE_TESTS constants which prevents 2FA to be loaded, facilitating the tests execution .

A request is recognized as an “automated tests” request thanks to a secret being present in globals, HTTP headers or cookies.