Ticket #9124: 9124.9.diff
File 9124.9.diff, 3.5 KB (added by , 14 years ago) |
---|
-
wp-includes/classes.php
275 275 276 276 if ( !empty( $this->query_vars[$wpvar] ) ) { 277 277 if ( ! is_array( $this->query_vars[$wpvar] ) ) { 278 $this->query_vars[$wpvar] = (string) $this->query_vars[$wpvar]; 278 $this->query_vars[$wpvar] = (string) $this->query_vars[$wpvar]; 279 279 } else { 280 280 foreach ( $this->query_vars[$wpvar] as $vkey => $v ) 281 281 $this->query_vars[$wpvar][$vkey] = (string) $v; … … 550 550 * A query is an associative array: 551 551 * - 'key' string The meta key 552 552 * - 'value' string|array The meta value 553 * - 'compare' (optional) string How to compare the key to the value. 554 * Possible values: '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'IN', 'BETWEEN'. 553 * - 'compare' (optional) string How to compare the key to the value. 554 * Possible values: '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'IN', 'BETWEEN'. 555 555 * Default: '=' 556 556 * - 'type' string (optional) The type of the value. 557 * Possible values: 'NUMERIC', 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED'. 557 * Possible values: 'NUMERIC', 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED'. 558 558 * Default: 'CHAR' 559 559 * 560 560 * @since 3.1.0 … … 573 573 * Possible values: 'term_id', 'slug' or 'name' 574 574 * Default: 'slug' 575 575 * - 'operator' string (optional) 576 * Possible values: 'IN' and 'NOT IN'. 576 * Possible values: 'IN' and 'NOT IN'. 577 577 * Default: 'IN' 578 * - 'include_children' bool (optional) Wether to include child terms. 578 * - 'include_children' bool (optional) Wether to include child terms. 579 579 * Default: true 580 580 * 581 581 * @since 3.1.0 … … 636 636 $meta_compare = isset( $q['compare'] ) ? strtoupper( $q['compare'] ) : '='; 637 637 $meta_type = isset( $q['type'] ) ? strtoupper( $q['type'] ) : 'CHAR'; 638 638 639 if ( ! in_array( $meta_compare, array( '=', '!=', '>', '>=', '<', '<=', 'LIKE', ' IN', 'BETWEEN' ) ) )639 if ( ! in_array( $meta_compare, array( '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) 640 640 $meta_compare = '='; 641 641 642 642 if ( 'NUMERIC' == $meta_type ) … … 658 658 if ( !empty( $meta_key ) ) 659 659 $where .= $wpdb->prepare( " AND $alias.meta_key = %s", $meta_key ); 660 660 661 if ( in_array( $meta_compare, array( 'IN', ' BETWEEN' ) ) ) {661 if ( in_array( $meta_compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) { 662 662 if ( ! is_array( $meta_value ) ) 663 663 $meta_value = preg_split( '/[,\s]+/', $meta_value ); 664 664 } else { … … 668 668 if ( empty( $meta_value ) ) 669 669 continue; 670 670 671 if ( 'IN' == $meta_compare) {671 if ( 'IN' == substr( $meta_compare, -2) ) { 672 672 $meta_field_types = substr( str_repeat( ',%s', count( $meta_value ) ), 1 ); 673 673 $meta_compare_string = "($meta_field_types)"; 674 674 unset( $meta_field_types ); 675 } elseif ( 'BETWEEN' == $meta_compare) {675 } elseif ( 'BETWEEN' == substr( $meta_compare, -7) ) { 676 676 $meta_value = array_slice( $meta_value, 0, 2 ); 677 677 $meta_compare_string = '%s AND %s'; 678 } elseif ( 'LIKE' == $meta_compare) {678 } elseif ( 'LIKE' == substr( $meta_compare, -4 ) ) { 679 679 $meta_value = '%' . like_escape( $meta_value ) . '%'; 680 680 $meta_compare_string = '%s'; 681 681 } else { … … 708 708 $query['include_children'] = true; 709 709 710 710 $query['do_query'] = false; 711 711 712 712 $sql_single = get_objects_in_term( $query['terms'], $query['taxonomy'], $query ); 713 713 714 714 if ( empty( $sql_single ) )