wppaste
WordPress

WP_List_Util

Since
4.7.0
Source
wp-includes/class-wp-list-util.php:16
List utility.

Description

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

Compatibility

WordPress
since 4.7.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Properties · 3

$inputarrayprivate
The input array.
$outputarrayprivate
The output array.
$orderbystring[]private
Temporary arguments for sorting.

Methods · 7

  • __construct()Constructor.
  • get_input()Returns the original input array.
  • get_output()Returns the output array.
  • filter()Filters the list, based on a set of key => value arguments.
  • pluck()Plucks a certain field out of each element in the input array.
  • sort()Sorts the input array based on one or more orderby arguments.
  • sort_callback()Callback to sort an array by specific fields.

Source code

#[AllowDynamicProperties]class WP_List_Util {	/**	 * The input array.	 *	 * @since 4.7.0	 * @var array	 */	private $input = array(); 	/**	 * The output array.	 *	 * @since 4.7.0	 * @var array	 */	private $output = array(); 	/**	 * Temporary arguments for sorting.	 *	 * @since 4.7.0	 * @var string[]	 */	private $orderby = array(); 	/**	 * Constructor.	 *	 * Sets the input array.	 *	 * @since 4.7.0	 *	 * @param array $input Array to perform operations on.	 */	public function __construct( $input ) {		$this->output = $input;		$this->input  = $input;	} 	/**	 * Returns the original input array.	 *	 * @since 4.7.0	 *	 * @return array The input array.	 */	public function get_input() {		return $this->input;	} 	/**	 * Returns the output array.	 *	 * @since 4.7.0	 *	 * @return array The output array.	 */	public function get_output() {		return $this->output;	} 	/**	 * 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.	 *	 * @since 4.7.0	 *	 * @param array  $args     Optional. An array of key => value arguments to match	 *                         against each object. Default empty array.	 * @param string $operator Optional. The logical operation to perform. 'AND' means	 *                         all elements from the array must match. 'OR' means only	 *                         one element needs to match. 'NOT' means no elements may	 *                         match. Default 'AND'.

Changelog

Introduced in 4.7.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.8.8 tag, from src/wp-includes/class-wp-list-util.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.