Properly handle nested arrays in wp_list_filter(). Props scribu, SergeyBiryukov. fixes #16137

git-svn-id: https://develop.svn.wordpress.org/trunk@18606 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2011-08-25 19:50:29 +00:00
parent aee898a1e7
commit 965dcf7bf9
1 changed files with 8 additions and 1 deletions

View File

@ -3198,7 +3198,14 @@ function wp_list_filter( $list, $args = array(), $operator = 'AND' ) {
$filtered = array();
foreach ( $list as $key => $obj ) {
$matched = count( array_intersect_assoc( (array) $obj, $args ) );
$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 <= $count )
|| ( 'NOT' == $operator && 0 == $matched ) ) {