Make WordPress Core

Changeset 15733


Ignore:
Timestamp:
10/06/2010 11:13:37 AM (16 years ago)
Author:
scribu
Message:

Better way of settings tax related query flags. See #12891

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/query.php

    r15732 r15733  
    12901290                        }
    12911291
    1292                         if ( empty($qv['cat']) || ($qv['cat'] == '0') )
    1293                                 $this->is_category = false;
    1294                         else
    1295                                 $this->is_category = strpos($qv['cat'], '-') === false;
    1296 
    1297                         if ( !empty($qv['category_name']) ) {
    1298                                 $this->is_category = true;
    1299                         }
    1300 
    1301                         if ( empty($qv['category__in']) ) {
    1302                                 $qv['category__in'] = array();
    1303                         } else {
    1304                                 $qv['category__in'] = array_map('absint', (array) $qv['category__in']);
    1305                                 $this->is_category = true;
    1306                         }
    1307 
    1308                         if ( empty($qv['category__not_in']) ) {
    1309                                 $qv['category__not_in'] = array();
    1310                         } else {
    1311                                 $qv['category__not_in'] = array_map('absint', (array) $qv['category__not_in']);
    1312                         }
    1313 
    1314                         if ( empty($qv['category__and']) ) {
    1315                                 $qv['category__and'] = array();
    1316                         } else {
    1317                                 $qv['category__and'] = array_map('absint', (array) $qv['category__and']);
    1318                                 $this->is_category = true;
    1319                         }
    1320 
    1321                         if (  '' != $qv['tag'] )
    1322                                 $this->is_tag = true;
    1323 
    1324                         $qv['tag_id'] = absint($qv['tag_id']);
    1325                         if ( !empty($qv['tag_id']) )
    1326                                 $this->is_tag = true;
    1327 
    1328                         if ( empty($qv['tag__in']) ) {
    1329                                 $qv['tag__in'] = array();
    1330                         } else {
    1331                                 $qv['tag__in'] = array_map('absint', (array) $qv['tag__in']);
    1332                                 $this->is_tag = true;
    1333                         }
    1334 
    1335                         if ( empty($qv['tag__not_in']) ) {
    1336                                 $qv['tag__not_in'] = array();
    1337                         } else {
    1338                                 $qv['tag__not_in'] = array_map('absint', (array) $qv['tag__not_in']);
    1339                         }
    1340 
    1341                         if ( !is_array($qv['tag__and']) || empty($qv['tag__and']) ) {
    1342                                 $qv['tag__and'] = array();
    1343                         } else {
    1344                                 $qv['tag__and'] = array_map('absint', (array) $qv['tag__and']);
    1345                                 $this->is_tag = true;
    1346                         }
    1347 
    1348                         if ( empty($qv['tag_slug__in']) ) {
    1349                                 $qv['tag_slug__in'] = array();
    1350                         } else {
    1351                                 $qv['tag_slug__in'] = array_map('sanitize_title', (array) $qv['tag_slug__in']);
    1352                                 $this->is_tag = true;
    1353                         }
    1354 
    1355                         if ( empty($qv['tag_slug__and']) ) {
    1356                                 $qv['tag_slug__and'] = array();
    1357                         } else {
    1358                                 $qv['tag_slug__and'] = array_map('sanitize_title', (array) $qv['tag_slug__and']);
    1359                                 $this->is_tag = true;
    1360                         }
    1361 
    1362                         if ( empty($qv['taxonomy']) || empty($qv['term']) ) {
    1363                                 $this->is_tax = false;
    1364                                 foreach ( $GLOBALS['wp_taxonomies'] as $taxonomy => $t ) {
    1365                                         if ( $t->query_var && isset($qv[$t->query_var]) && '' != $qv[$t->query_var] ) {
    1366                                                 $qv['taxonomy'] = $taxonomy;
    1367                                                 $qv['term'] = $qv[$t->query_var];
    1368                                                 $this->is_tax = true;
    1369                                                 break;
    1370                                         }
    1371                                 }
    1372                         } else {
    1373                                 $this->is_tax = true;
    1374                         }
    1375 
    13761292                        $this->parse_tax_query( $qv );
    13771293
    … …  
    15841500
    15851501                $this->tax_query = $tax_query;
     1502
     1503                foreach ( $this->tax_query as $query ) {
     1504                        if ( 'IN' == $query['operator'] ) {
     1505                                switch ( $query['taxonomy'] ) {
     1506                                        case 'category':
     1507                                                $this->is_category = true;
     1508                                                break;
     1509                                        case 'post_tag':
     1510                                                $this->is_tag = true;
     1511                                                break;
     1512                                        default:
     1513                                                $this->is_tax = true;
     1514                                }
     1515                        }
     1516                }
    15861517        }
    15871518
Note: See TracChangeset for help on using the changeset viewer.