Advertisements

wp_filter_object_list

Definition:
function wp_filter_object_list( $list, $args = array() {}

Filters a list of objects, based on a set of key => value arguments.

Parameters

  • array $list: An array of objects to filter
  • array $args: An array of key => value arguments to match against each object
  • string $operator: The logical operation to perform. ‘or’ means only one element from the array needs to match; ‘and’ means all elements must match. The default is ‘and’.
  • bool|string $field: A field from the object to place instead of the entire object

Return values

returns:A list of objects or object fields

Source code

function wp_filter_object_list( $list, $args = array(), $operator = 'and', $field = false ) {

	if ( ! is_array( $list ) )

		return array();



	$list = wp_list_filter( $list, $args, $operator );



	if ( $field )

		$list = wp_list_pluck( $list, $field );



	return $list;

}

3659

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: