Helper Functions (category)

__return_empty_array()

Simply returns an empty array: array(). Helper function of WordPress.

__return_empty_string()

Simply returns an empty string:". Helper function of WordPress.

__return_false()

Simply returns false. Helper function of WordPress.

__return_null()

Simply returns null. Auxiliary function of WordPress.

__return_true()

Simply returns true. Helper function of WordPress.

__return_zero()

Simply returns 0. Helper function of WordPress. Useful for use in filters.

array_key_first()

Gets the first key of the passed array. Does not touch the internal pointer of the array.

array_key_last()

Gets the last key of the given array. Does not touch the internal pointer of the array.

block_core_social_link_services()

Gets the SVG code of the social service: Twitter, Facebook, etc.

build_query()

Collects a query string from the provided simple/associative array.

get_page_hierarchy()

Sorts an array of hierarchical posts based on parent relationships (post_parent).

get_self_link()

Gets the URL (link) of the current page (request) that triggered the currently running code.

human_readable_duration()

Convert a duration in format HH:ii:ss or ii:ss to human readable format.

map_deep()

Applies the specified function to the values of the passed array/object/string/number. It's a recursive function.

maybe_serialize()

Serializes (turns into a string) the passed data if needed.

maybe_unserialize()

Unserialize data only if it was serialized or returns the original value.

path_join()

Join two filesystem paths together. If the second parameter is an absolute path (starts with a slash), then only it will be returned.

str_contains()

Checks if the specified string (substring) is in another string. Case sensitive.

str_ends_with()

Checks if the string ends with the specified substring. Case sensitive.

str_starts_with()

Checks if the string starts with the specified substring. Case sensitive.

stripslashes_deep()

Iterates through an array, object, scalar and removes escaping slashes (\) from string values.

timer_float()

Gets the time (in seconds) that has passed since the start of the PHP script execution.

timer_stop()

Gets the execution time of the PHP script from the moment the page generation starts until this function is called.

urlencode_deep()

Iterates over all elements of the array and processes all values with the function urlencode(). A string can also be passed.

wp_array_slice_assoc()

Leaves elements from the first array whose keys (indexes) match the values of the second array.

wp_basename()

Gets the last component from the specified path or URL, retrieving everything after the last /.

wp_debug_backtrace_summary()

Gets a trace with function names — a list of all functions/methods that were called to reach the current place in the code (from where this function was called).

wp_extract_urls()

Uses a regular expression to "extract" all links (URLs) from the provided text.

wp_filter_object_list()

Filters the given array of objects by the specified key=>value parameters.

wp_get_list_item_separator()

Gets the separator for list items. What the separator will be depends on the current site locale.

wp_html_split()

Parses the given text (in the form of HTML code) into HTML tags and comments, returning an array of values: tags and their text.

wp_is_jsonp_request()

Checks if the current request is a JSONP request or expects a JSONP response.

wp_json_encode()

Encode a variable into JSON, with some sanity checks. Checks strings and translates them to UTF-8.

wp_json_file_decode()

Reads and decodes (parses) the specified JSON file.

wp_kses_array_lc()

Translates all keys of the specified array to lowercase (ABC to abc). Keys of nested arrays are also processed.

wp_kses_hair()

Gets a list of HTML tag attributes (as an array) from the provided string with attributes.

wp_kses_uri_attributes()

Gets a list of HTML attributes that (according to the specification) should specify a URL.

wp_list_filter()

Filters an array of objects (or an array of arrays) and retrieves from the array those objects that have the specified parameter.

wp_list_pluck()

Collects a specified field from nested arrays of a multidimensional array.

wp_list_sort()

Sorts an array of objects or an array of arrays by one or more fields.

wp_make_link_relative()

Converts an absolute URL to a relative path. Removes the protocol (http/https) and domain, leaving / at the beginning.

wp_normalize_path()

Normalizes the path for a file or folder by replacing backslashes and double slashes with a single one.

wp_parse_args()

Combines two arrays so that the parameters of the first array (passed) replace the parameters of the second array (default) when they match. Parameters can be specified as a string.

wp_parse_id_list()

Processes/cleans an array of numbers (IDs) or a string where numbers are separated by commas or spaces. Will return an array of numbers.

wp_parse_list()

Breaks a string into an array of values separated by the characters ,   \t \n: comma, space, tab, newline.

wp_parse_slug_list()

Creates an array of tags from a string of words separated by commas, spaces. The values of the array are cleaned using sanitize_title().

wp_parse_str()

Parses the query string, for example, foo=1&foo2=2 and creates an array of data from it.

wp_parse_url()

Parses a URL and returns its components. A wrapper for PHP's parse_url() function that handles consistency in the return values across PHP versions.

wp_rand()

Generates a random number between the specified min and max.

wp_recursive_ksort()

Sorts an array and all nested arrays by key in ascending order (a-z).

wp_reset_vars()

Sets the specified variables as global if they are specified in the $_GET / $_POST request.

wp_send_json()

Encodes the passed variable into JSON, prints the result to the screen and terminates the script (die). Used to return data for AJAX requests.

wp_send_json_error()

Send a JSON response back to an Ajax request, indicating failure.

wp_send_json_success()

Returns JSON data. Is used to return a success response to AJAX request. The response object always contains the element success=true. die() php execution.

wp_slash()

Add slashes (\) to a string or array of strings.

wp_spaces_regexp()

Returns a regular expression that matches all kinds of spaces (line breaks, invisible characters, etc.).

wp_sprintf()

Variant of the PHP function sprintf() from WordPress. Supports %l (list) in the passed format.

wp_tempnam()

Creates an empty temporary writable file with a unique name in the temporary directory. After use, the file must be deleted using unlink();

wp_unique_id()

Gets a unique identifier.

wp_unslash()

Removes slashes from a string or from strings of an array, or properties of an object. The array can be of any nesting level.