[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/ -> class-wp-list-util.php (summary)

WordPress List utility class

File Size: 280 lines (7 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

WP_List_Util:: (7 methods):
  __construct()
  get_input()
  get_output()
  filter()
  pluck()
  sort()
  sort_callback()


Class: WP_List_Util  - X-Ref

List utility.

Utility class to handle operations on an array of objects or arrays.

__construct( $input )   X-Ref
Constructor.

Sets the input array.

param: array $input Array to perform operations on.
since: 4.7.0

get_input()   X-Ref
Returns the original input array.

return: array The input array.
since: 4.7.0

get_output()   X-Ref
Returns the output array.

return: array The output array.
since: 4.7.0

filter( $args = array()   X-Ref
Filters the list, based on a set of key => value arguments.

Retrieves the objects from the list that match the given arguments.
Key represents property name, and value represents property value.

If an object has more properties than those specified in arguments,
that will not disqualify it. When using the 'AND' operator,
any missing properties will disqualify it.

return: array Array of found values.
param: array  $args     Optional. An array of key => value arguments to match
param: string $operator Optional. The logical operation to perform. 'AND' means
since: 4.7.0

pluck( $field, $index_key = null )   X-Ref
Plucks a certain field out of each element in the input array.

This has the same functionality and prototype of
array_column() (PHP 5.5) but also supports objects.

return: array Array of found values. If `$index_key` is set, an array of found values with keys
param: int|string $field     Field to fetch from the object or array.
param: int|string $index_key Optional. Field from the element to use as keys for the new array.
since: 4.7.0

sort( $orderby = array()   X-Ref
Sorts the input array based on one or more orderby arguments.

return: array The sorted array.
param: string|array $orderby       Optional. Either the field name to order by or an array
param: string       $order         Optional. Either 'ASC' or 'DESC'. Only used if $orderby
param: bool         $preserve_keys Optional. Whether to preserve keys. Default false.
since: 4.7.0

sort_callback( $a, $b )   X-Ref
Callback to sort an array by specific fields.

return: int 0 if both objects equal. -1 if second object should come first, 1 otherwise.
param: object|array $a One object to compare.
param: object|array $b The other object to compare.
since: 4.7.0



Generated: Thu Nov 21 01:00:03 2024 Cross-referenced by PHPXref 0.7.1