Make WordPress Core

Ticket #30865: term-numeric-test.php

File term-numeric-test.php, 532 bytes (added by jhned, 9 years ago)

Term Numeric Test

Line 
1$term = $q[$t->query_var];
2
3if ( strpos($term, '+') !== false ) {
4        $terms = preg_split( '/[+]+/', $term );
5        foreach ( $terms as $term ) {
6                $field = '';
7                if ( is_numeric($term) ) {
8                        $field = 'term_id';
9                }
10                $tax_query[] = array_merge( $tax_query_defaults, array(
11                        'terms' => array( $term ),
12                        'field' => $field
13                ) );
14        }
15} else {
16        $field = '';
17        if ( is_numeric($term) ) {
18                $field = 'term_id';
19        }
20        $tax_query[] = array_merge( $tax_query_defaults, array(
21                'terms' => preg_split( '/[,]+/', $term ),
22                'field' => $field
23        ) );
24}