Ticket #9124: 9124.8.diff
File 9124.8.diff, 2.1 KB (added by , 14 years ago) |
---|
-
wp-includes/classes.php
552 552 * @param array $qv The query variables 553 553 */ 554 554 function parse_meta_query( $qv ) { 555 if ( ! empty( $qv['meta_query'] ) && is_array( $qv['meta_query'] ) ) {555 if ( ! empty( $qv['meta_query'] ) && is_array( $qv['meta_query'] ) ) { 556 556 $this->meta_query = $qv['meta_query']; 557 557 } 558 558 559 559 $meta_query = array(); 560 foreach ( array( 'key', 'value', 'compare' ) as $key ) {561 if ( ! empty( $qv[ "meta_$key" ] ) )560 foreach ( array( 'key', 'value', 'compare', 'type' ) as $key ) { 561 if ( ! empty( $qv[ "meta_$key" ] ) ) 562 562 $meta_query[ $key ] = $qv[ "meta_$key" ]; 563 563 } 564 564 565 if ( ! empty( $meta_query ) ) {565 if ( ! empty( $meta_query ) ) { 566 566 array_unshift( $this->meta_query, $meta_query ); 567 567 } 568 568 } … … 593 593 $meta_compare = isset( $q['compare'] ) ? strtoupper( $q['compare'] ) : '='; 594 594 $meta_type = isset( $q['type'] ) ? strtoupper( $q['type'] ) : 'CHAR'; 595 595 596 if ( ! in_array( $meta_compare, array( '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'IN', 'BETWEEN' ) ) )596 if ( ! in_array( $meta_compare, array( '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'IN', 'BETWEEN' ) ) ) 597 597 $meta_compare = '='; 598 598 599 if ( 'STRING' == $meta_type ) 600 $meta_type = 'CHAR'; 601 elseif ( 'NUMERIC' == $meta_type ) 599 if ( 'NUMERIC' == $meta_type ) 602 600 $meta_type = 'SIGNED'; 603 elseif ( ! in_array( $meta_type, array( 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED' ) ) )601 elseif ( ! in_array( $meta_type, array( 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED' ) ) ) 604 602 $meta_type = 'CHAR'; 605 603 606 604 if ( empty( $meta_key ) && empty( $meta_value ) ) … … 618 616 $where .= $wpdb->prepare( " AND $alias.meta_key = %s", $meta_key ); 619 617 620 618 if ( in_array( $meta_compare, array( 'IN', 'BETWEEN' ) ) ) { 621 if ( ! is_array( $meta_value ) )619 if ( ! is_array( $meta_value ) ) 622 620 $meta_value = preg_split( '/[,\s]+/', $meta_value ); 623 621 } else { 624 622 $meta_value = trim( $meta_value );