Helpers

Table of Contents

prefix()  : mixed
Adds HivePress prefix.
unprefix()  : mixed
Removes HivePress prefix.
get_array_value()  : mixed
Gets array item value by key.
get_first_array_value()  : mixed
Gets first array item value.
get_last_array_value()  : mixed
Gets last array item value.
search_array_value()  : mixed
Searches array item value by keys.
merge_arrays()  : array<string|int, mixed>
Merges arrays with mixed values.
merge_trees()  : array<string|int, mixed>
Merges trees with mixed values.
sort_array()  : array<string|int, mixed>
Sorts array by a custom order.
get_class_name()  : string
Gets a short class name.
get_class_parents()  : array<string|int, mixed>
Gets parent classes including a child.
is_class_instance()  : bool
Checks if object is a class instance.
create_class_instance()  : object
Creates a class instance.
call_class_method()  : mixed
Calls a class method.
replace_tokens()  : string
Replaces tokens with values.
html_attributes()  : string
Renders HTML attributes.
esc_json()  : string
Escapes JSON.
sanitize_html()  : string
Sanitizes HTML.
sanitize_slug()  : string
Sanitizes slug.
sanitize_key()  : string
Sanitizes key.
format_number()  : string
Formats number.
is_plugin_active()  : bool
Checks plugin status.
is_rest()  : bool
Checks if the current request is REST.
rest_response()  : WP_Rest_Response
Creates a REST API response.
rest_error()  : WP_Rest_Response
Creates a REST API error.
get_column_width()  : int
Gets the number of columns out of 12.
has_shortcode()  : bool
Checks if text contains shortcodes.

Functions

prefix()

Adds HivePress prefix.

prefix(mixed $names) : mixed
Parameters
$names : mixed

Names to prefix.

unprefix()

Removes HivePress prefix.

unprefix(mixed $names) : mixed
Parameters
$names : mixed

Names to unprefix.

get_array_value()

Gets array item value by key.

get_array_value(array<string|int, mixed> $array, string $key[, mixed $default = null ]) : mixed
Parameters
$array : array<string|int, mixed>

Source array.

$key : string

Key to search.

$default : mixed = null

Default value.

get_first_array_value()

Gets first array item value.

get_first_array_value(array<string|int, mixed> $array[, mixed $default = null ]) : mixed
Parameters
$array : array<string|int, mixed>

Source array.

$default : mixed = null

Default value.

Tags
since
1.3.1

get_last_array_value()

Gets last array item value.

get_last_array_value(array<string|int, mixed> $array[, mixed $default = null ]) : mixed
Parameters
$array : array<string|int, mixed>

Source array.

$default : mixed = null

Default value.

Tags
since
1.3.1

search_array_value()

Searches array item value by keys.

search_array_value(array<string|int, mixed> $array, mixed $keys) : mixed
Parameters
$array : array<string|int, mixed>

Source array.

$keys : mixed

Keys to search.

merge_arrays()

Merges arrays with mixed values.

merge_arrays() : array<string|int, mixed>

merge_trees()

Merges trees with mixed values.

merge_trees(array<string|int, mixed> $parent_tree, array<string|int, mixed> $child_tree[, string $tree_key = null ][, string $node_key = null ]) : array<string|int, mixed>
Parameters
$parent_tree : array<string|int, mixed>

Parent tree.

$child_tree : array<string|int, mixed>

Child tree.

$tree_key : string = null

Tree key.

$node_key : string = null

Node key.

sort_array()

Sorts array by a custom order.

sort_array(array<string|int, mixed> $array) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>

Source array.

get_class_name()

Gets a short class name.

get_class_name(string $class) : string
Parameters
$class : string

Class name.

get_class_parents()

Gets parent classes including a child.

get_class_parents(string $class) : array<string|int, mixed>
Parameters
$class : string

Class name.

is_class_instance()

Checks if object is a class instance.

is_class_instance(object $object, string $class) : bool
Parameters
$object : object

Class object.

$class : string

Class name.

create_class_instance()

Creates a class instance.

create_class_instance(string $class[, array<string|int, mixed> $args = [] ]) : object
Parameters
$class : string

Class name.

$args : array<string|int, mixed> = []

Instance arguments.

call_class_method()

Calls a class method.

call_class_method(string $class, string $method[, array<string|int, mixed> $args = [] ]) : mixed
Parameters
$class : string

Class name.

$method : string

Method name.

$args : array<string|int, mixed> = []

Method arguments.

replace_tokens()

Replaces tokens with values.

replace_tokens(array<string|int, mixed> $tokens, string $text) : string
Parameters
$tokens : array<string|int, mixed>

Array of tokens.

$text : string

Text to be processed.

html_attributes()

Renders HTML attributes.

html_attributes(array<string|int, mixed> $attributes) : string
Parameters
$attributes : array<string|int, mixed>

Array of attributes.

esc_json()

Escapes JSON.

esc_json(string $json[, bool $html = false ]) : string
Parameters
$json : string

JSON string.

$html : bool = false

Contains HTML?

sanitize_html()

Sanitizes HTML.

sanitize_html(string $html[, array<string|int, mixed> $tags = [] ]) : string
Parameters
$html : string

HTML to sanitize.

$tags : array<string|int, mixed> = []

Allowed HTML tags.

sanitize_slug()

Sanitizes slug.

sanitize_slug(string $text) : string
Parameters
$text : string

Text to sanitize.

sanitize_key()

Sanitizes key.

sanitize_key(string $text) : string
Parameters
$text : string

Text to sanitize.

format_number()

Formats number.

format_number(float $number[, int $decimals = null ]) : string
Parameters
$number : float

Number.

$decimals : int = null

Precision.

is_plugin_active()

Checks plugin status.

is_plugin_active(string $name) : bool
Parameters
$name : string

Plugin name.

rest_response()

Creates a REST API response.

rest_response(int $code[, array<string|int, mixed> $data = null ]) : WP_Rest_Response
Parameters
$code : int

Error code.

$data : array<string|int, mixed> = null

Response data.

rest_error()

Creates a REST API error.

rest_error(int $code[, array<string|int, mixed> $errors = [] ]) : WP_Rest_Response
Parameters
$code : int

Error code.

$errors : array<string|int, mixed> = []

Error messages.

get_column_width()

Gets the number of columns out of 12.

get_column_width(int $number) : int
Parameters
$number : int

Columns number.

has_shortcode()

Checks if text contains shortcodes.

has_shortcode(string $text) : bool
Parameters
$text : string

Text to be checked.