This document provides an overview of the functions allowed in the Widget Options Logic. The functions are categorized by their respective purpose, including String Manipulation, Array Manipulation, Math Functions, Date/Time functions, JSON Functions, Variable Handling, and File Operations.
1. String Manipulation Functions
These functions allow for various string operations like manipulation, search, and modification.
strlen– Get the length of a string.substr– Return a part of a string.strtolower– Convert a string to lowercase.strtoupper– Convert a string to uppercase.trim– Strip whitespace from both sides of a string.ltrim– Strip whitespace from the left side of a string.rtrim– Strip whitespace from the right side of a string.preg_match– Perform a regular expression match.explode– Split a string by a delimiter into an array.implode– Join array elements into a single string.htmlspecialchars– Convert special characters to HTML entities.htmlentities– Convert all applicable characters to HTML entities.strip_tags– Strip HTML and PHP tags from a string.str_repeat– Repeat a string a specified number of times.str_split– Split a string into an array of characters.strpos– Find the position of the first occurrence of a substring.strrpos– Find the position of the last occurrence of a substring.stripos– Find the position of the first occurrence of a substring (case-insensitive).strripos– Find the position of the last occurrence of a substring (case-insensitive).substr_replace– Replace a part of a string with another string.wordwrap– Wrap a string to a given width.
2. Array Manipulation Functions #
These functions provide various ways to manipulate arrays such as merging, filtering, and mapping.
array_merge– Merge one or more arrays.array_diff– Compare arrays and return the difference.array_filter– Filter elements of an array using a callback function.array_map– Apply a callback to the elements of an array.array_keys– Return all the keys of an array.array_values– Return all the values of an array.in_array– Check if a value exists in an array.count– Count all elements in an array.sizeof– Alias ofcount().array_slice– Extract a slice of an array.array_push– Add elements to the end of an array.array_pop– Remove and return the last element of an array.array_reduce– Iteratively reduce an array to a single value using a callback.array_intersect– Return the intersection of arrays.array_unique– Remove duplicate values from an array.array_column– Return the values from a single column in an array.array_reverse– Reverse the order of elements in an array.
3. Math Functions #
These functions perform mathematical calculations or return mathematical results.
abs– Return the absolute value of a number.round– Round a floating-point number to the nearest integer.floor– Round down a number.ceil– Round up a number.min– Find the minimum value in an array or among arguments.max– Find the maximum value in an array or among arguments.pow– Raise a number to the power of another number.sqrt– Return the square root of a number.rand– Generate a random integer.mt_rand– Generate a better random integer using the Mersenne Twister algorithm.number_format– Format a number with grouped thousands.log– Return the natural logarithm of a number.exp– Returneraised to the power of a given number.bcadd– Add two arbitrary precision numbers.bcsub– Subtract two arbitrary precision numbers.bcmul– Multiply two arbitrary precision numbers.bcdiv– Divide two arbitrary precision numbers.
4. Date/Time Functions #
These functions deal with date and time operations such as formatting and calculations.
time– Return the current time as a Unix timestamp.date– Format a local time/date.strtotime– Parse an English textual datetime description into a Unix timestamp.mktime– Get Unix timestamp for a date.checkdate– Validate a Gregorian date.date_default_timezone_get– Get the default timezone.gmdate– Format a GMT/UTC date.
5. JSON Functions #
Functions for working with JSON data.
json_decode– Decode a JSON string into a PHP variable.json_encode– Encode a PHP variable into a JSON string.
6. Variable Handling Functions #
Functions for checking, converting, or manipulating variables.
isset– Check if a variable is set and is notnull.empty– Check if a variable is empty.unset– Destroy a variable.is_array– Check if a variable is an array.is_bool– Check if a variable is a boolean.is_callable– Check if a variable is callable.is_countable– Check if a variable is countable.is_double– Check if a variable is a double.is_float– Check if a variable is a float.is_int– Check if a variable is an integer.is_integer– Check if a variable is an integer.is_iterable– Check if a variable is iterable.is_long– Check if a variable is a long integer.is_null– Check if a variable isnull.is_numeric– Check if a variable is a number or a numeric string.is_object– Check if a variable is an object.is_real– Check if a variable is a real number.is_scalar– Check if a variable is a scalar.is_string– Check if a variable is a string.is_subclass_of– Check if an object is a subclass of a given class.is_uploaded_file– Check if the file was uploaded via HTTP POST.is_writable– Check if a file is writable.is_readable– Check if a file is readable.is_dir– Check if a path is a directory.is_file– Check if a path is a file.is_link– Check if a path is a symbolic link.intval– Get the integer value of a variable.strval– Get the string value of a variable.floatval– Get the float value of a variable.doubleval– Get the double value of a variable.boolval– Get the boolean value of a variable.realpath– Get the absolute path of a file.
7. File Operations (Read-Only) #
These functions allow for read-only operations on files.
readfile– Output a file.filesize– Get the size of a file.pathinfo– Return information about a file path.basename– Get the filename from a file path.dirname– Get the directory name from a file path.file_exists– Check if a file or directory exists.
Adding Custom Functions to Widget Options #
If you’d like to add custom functions that aren’t included in the default list of allowed functions, you can easily extend the functionality by adding a filter to your functions.php file (or any other suitable location in your theme or plugin).
To add multiple functions, simply add additional lines with the $allowed_functions[] array.
function add_extra_hooks( $allowed_functions ) {
// Add your custom functions here
$allowed_functions[] = 'function_to_add';
return $allowed_functions;
}
add_filter( 'widgetopts_allowed_php_functions', 'add_extra_hooks' );