Constants

HOST_TYPE_MAIN

HOST_TYPE_MAIN ='main'

nip.io

HOST_TYPE_MAIN_WITH_ALL_SUBDOMAINS

HOST_TYPE_MAIN_WITH_ALL_SUBDOMAINS ='main+subdomains'

.nip.io

HOST_TYPE_CURRENT

HOST_TYPE_CURRENT ='current'

feat.nip.io

HOST_TYPE_CURRENT_PROTOCOL

HOST_TYPE_CURRENT_PROTOCOL ='current+protocol'

https://feat.nip.io

HOST_TYPE_CURRENT_WITH_ALL_SUBDOMAINS

HOST_TYPE_CURRENT_WITH_ALL_SUBDOMAINS ='current+subdomains'

.feat.nip.io

PREINSTALLED_ENV_IONOS

PREINSTALLED_ENV_IONOS ='ionos'

Methods

joinWithAndSeparator()

joinWithAndSeparator(array<mixed,string>  $array,string  $andSeparator)

Join an array of strings together with comma and the last one with `and`.

Parameters

array<mixed,string> $array
string $andSeparator

getPermalink()

getPermalink(\WP_Post|\DevOwl\RealCookieBanner\number  $post): string|false

Always create a clone of the post cause we need to force the `post_status` to get the valid permalink.

This also returns a valid permalink even for trashed or draft posts.

Parameters

\WP_Post|\DevOwl\RealCookieBanner\number $post

Returns

string|false

getPreviewUrl()

getPreviewUrl(\WP_Post  $post)

Get preview or of given post.

Parameters

\WP_Post $post

get_admin_colors()

get_admin_colors(): array<mixed,string>

Get the currently used admin color scheme.

Returns

array<mixed,string>

array_flatten()

array_flatten(array  $array,boolean  $recursive = false)

Flatten an array.

Parameters

array $array
boolean $recursive

removeNonPermalinkQueryFromUrl()

removeNonPermalinkQueryFromUrl(string  $url)

Remove all query arguments not designed in our permalink structure.

Parameters

string $url

getRandomWeightedElement()

getRandomWeightedElement(array  $weightedValues)

Pass in an associative array, such as array('A'=>5, 'B'=>45, 'C'=>50).

It is recommend to sort the weights ascending to speed up performance.

Parameters

array $weightedValues

getIpAddress()

getIpAddress()

Get the IP address of the current request.

flatten()

flatten(array  $array)

Flatten an array.

Parameters

array $array

isPreinstalledEnvironment()

isPreinstalledEnvironment(): string|false

Check if the current installation is a preinstalled environment.

Returns

string|false

isThemeActive()

isThemeActive(string  $slug)

Check if a single theme is active. It supports parent theme.

Parameters

string $slug

anyPluginActive()

anyPluginActive(string|array<mixed,string>  $plugins)

Checks if any of the given plugins is active. It supports also slugs.

Parameters

string|array<mixed,string> $plugins

isPluginActive()

isPluginActive(string  $plugin)

Check if a single plugin is active. It supports also slugs.

Parameters

string $plugin

setCookie()

setCookie(string  $name,string  $value = '',integer  $expire,string  $path = '',string  $domain = '',boolean  $secure = false,boolean  $httponly = false,string  $samesite = '')

Support samesite cookie flag in both php 7.2 (current production) and php >= 7.3 (when we get there) From: https://github.com/GoogleChromeLabs/samesite-examples/blob/master/php.md and https://stackoverflow.com/a/46971326/2308553

Parameters

string $name
string $value
integer $expire
string $path
string $domain
boolean $secure
boolean $httponly
string $samesite

hash()

hash(string  $data)

Hash a passed string. It uses PHP `hash` and md5 as fallback as `hash` is not available in all environments.

Parameters

string $data

host()

host(string  $type)

Get a host URL for technical cookie definitions.

Parameters

string $type

See class constants

giveHost()

giveHost(string  $host_with_subdomain)

Remove all subdomains from host string.

Parameters

string $host_with_subdomain

startsWith()

startsWith(string  $haystack,string  $needle)

Check if a string starts with a given needle.

Parameters

string $haystack

The string to search in

string $needle

The starting string

endsWith()

endsWith(string  $haystack,string  $needle)

Check if a string starts with a given needle.

Parameters

string $haystack

The string to search in

string $needle

The starting string

isFrontend()

isFrontend()

Check if current page is frontend page of WordPress.

isDownload()

isDownload()

Check if the current page request is a download.

isPageBuilder()

isPageBuilder()

Check if the current request is the editor of a page builder.

isCLI()

isCLI()

Check if current request is coming from WP CLI.

isRest()

isRest()

Checks if the current request is a WP REST API request.

Case #1: After WP_REST_Request initialisation Case #2: Support "plain" permalink settings Case #3: It can happen that WP_Rewrite is not yet initialized, so do this (wp-settings.php) Case #4: URL Path begins with wp-json/ (your REST prefix) Also supports WP installations in subfolders

currentContentTypeIs()

currentContentTypeIs(string  $mime)

Check if current content type is the given mime type.

Parameters

string $mime

posts_where_find_in_set()

posts_where_find_in_set(array  $where,object  $query)

Allow `find_in_set` in `meta_query` compare functionality.

Parameters

array $where
object $query

getOptionRaw()

getOptionRaw(string  $optionName,mixed  $default = false)

Get the raw value of a `wp_options` value by respecting the object cache. It is not modified through option-filters.

Parameters

string $optionName
mixed $default

getOriginalHomeUrl()

getOriginalHomeUrl()

This is needed to get the home_url without any additional pathes (e.g. WPML).

getRequestUrl()

getRequestUrl()

Get the current requested URL.