wp_list_filter [ WordPress Function ]
wp_list_filter ( $list, $args = array(), $operator = 'AND' )
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Filters a list of objects, based on a set of key => value arguments.
Source
<?php
function wp_list_filter( $list, $args = array(), $operator = 'AND' ) {
if ( ! is_array( $list ) )
return array();
if ( empty( $args ) )
return $list;
$operator = strtoupper( $operator );
$count = count( $args );
$filtered = array();
foreach ( $list as $key => $obj ) {
$to_match = (array) $obj;
$matched = 0;
foreach ( $args as $m_key => $m_value ) {
if ( $m_value == $to_match[ $m_key ] )
$matched++;
}
if ( ( 'AND' == $operator && $matched == $count )
|| ( 'OR' == $operator && $matched > 0 )
|| ( 'NOT' == $operator && 0 == $matched ) ) {
$filtered[$key] = $obj;
}
}
return $filtered;
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- #16499 (wp_list_filter() no longer watches for $list to be an array ...
Now the call gets passed right to wp_list_filter(), which no longer does the ... Can probably just patch wp_filter_object_list() rather than the new wp_list_filter().
core.trac.wordpress.org - #18092 (wp_list_filter() OR operator doesn't work) – WordPress Trac
Description. wp_list_filter() always returns all elements when the OR operator is passed. This affects corresponding usage of get_post_types(), get_taxonomies() ...
core.trac.wordpress.org - Function Reference/wp list filter « WordPress Codex
Description. Filters a list of objects, based on a set of key => value arguments. Usage. <?php wp_list_filter( $list, $args, $operator ); ?> Parameters. $list: (array) ...
codex.wordpress.org - wp_list_filter (WordPress Function) - WPSeek.com
WordPress lookup for wp_list_filter, a WordPress Function. wpseek.com is a WordPress-centric search tool for developers and theme authors.
wpseek.com