wp_list_filter( array $input_list, array $args = array(), string $operator = 'AND' ): array
- Since
- 3.1.0, 4.7.0, 5.9.0
- Source
wp-includes/functions.php:5461
Description
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.
If you want to retrieve a particular field from all matching objects, use wp_filter_object_list() instead.
Compatibility
- WordPress
- since 5.9.0
- PHP
- 7.4–8.6-dev
- 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), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$input_listarray- An array of objects to filter.
$argsarrayoptional- An array of key => value arguments to match against each object. Default empty array.Default:
array() $operatorstringoptional- 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'.Default:
'AND'
Return value
array- Array of found values.
Performance profile
How much work a call to wp_list_filter() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Trivial
- Scaling
- Constant
- Instructions
- 9
- Plugin surface
- None
- Called by
- 15
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5. The body compiles to 9.
Nothing here hands control to plugin code.
15 places in core call this, so the cost is paid more often than your own code shows.
What one call costs · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_list_filter() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 9 | wp_filter_object_list() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 9 instructions, 9 executed per call, 0 branches. The work does not change between versions.
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 1
- wp_filter_object_list()Filters a list of objects, based on a set of key => value arguments.
Used by · 15
- WP_Automatic_Updater::send_debug_email()Prepares and sends an email of a full log of background update results, useful for debugging and geekery.
- WP_REST_Menu_Items_Controller::get_item_schema()Retrieves the nav menu item's schema, conforming to JSON Schema.
- WP_REST_Menu_Items_Controller::prepare_item_for_response()Prepares a single nav menu item output for response.
- WP_REST_Post_Types_Controller::prepare_item_for_response()Prepares a post type object for serialization.
- WP_REST_Posts_Controller::check_assign_terms_permission()Checks whether current user can assign all terms sent with the current request.
- WP_REST_Posts_Controller::get_available_actions()Gets the link relations available for the post and current user.
- WP_REST_Posts_Controller::get_item_schema()Retrieves the post's schema, conforming to JSON Schema.
- WP_REST_Posts_Controller::get_schema_links()Retrieves Link Description Objects that should be added to the Schema for the posts collection.
- WP_REST_Posts_Controller::handle_terms()Updates the post's terms from a REST request.
- WP_REST_Posts_Controller::prepare_item_for_response()Prepares a single post output for response.
- WP_REST_Posts_Controller::prepare_tax_query()Prepares the 'tax_query' for a collection of posts.
- WP_REST_Posts_Controller::prepare_taxonomy_limit_schema()Prepares the collection schema for including and excluding items by terms.
Show all 15
- WP_REST_Response::remove_link()Removes a link from the response.
- WP_REST_Server::get_routes()Retrieves the route map.
- _access_denied_splash()Displays an access denied message when a user tries to view a site's dashboard they do not have access to.
Source code
function wp_list_filter( $input_list, $args = array(), $operator = 'AND' ) { return wp_filter_object_list( $input_list, $args, $operator );}Changelog
Introduced in 3.1.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
wp_filter_object_list().from the docblockWP_List_Util class.from the docblockAbout this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/functions.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.