Changeset 36598 for trunk/src/wpincludes/taxonomy.php
 Timestamp:
 02/20/2016 08:03:31 PM (4 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/wpincludes/taxonomy.php
r36564 r36598 1310 1310 } 1311 1311 1312 $where = "tt.taxonomy IN ('" . implode("', '", $taxonomies) . "')"; 1312 $where_conditions = array(); 1313 1314 $where_conditions[] = "tt.taxonomy IN ('" . implode("', '", $taxonomies) . "')"; 1313 1315 1314 1316 $exclude = $args['exclude']; … … 1324 1326 1325 1327 if ( ! empty( $inclusions ) ) { 1326 $inclusions = ' AND t.term_id IN ( ' . $inclusions . ' )'; 1327 $where .= $inclusions; 1328 $where_conditions[] = 't.term_id IN ( ' . $inclusions . ' )'; 1328 1329 } 1329 1330 … … 1355 1356 1356 1357 if ( ! empty( $exclusions ) ) { 1357 $exclusions = ' ANDt.term_id NOT IN (' . implode( ',', array_map( 'intval', $exclusions ) ) . ')';1358 $exclusions = 't.term_id NOT IN (' . implode( ',', array_map( 'intval', $exclusions ) ) . ')'; 1358 1359 } else { 1359 1360 $exclusions = ''; … … 1372 1373 1373 1374 if ( ! empty( $exclusions ) ) { 1374 $where .= $exclusions; 1375 // Must do string manipulation here for backward compatibility with filter. 1376 $where_conditions[] = preg_replace( '/^\s*AND\s*/', '', $exclusions ); 1375 1377 } 1376 1378 … … 1382 1384 } 1383 1385 1384 $where .= " ANDt.name IN ('" . implode( "', '", array_map( 'esc_sql', $names ) ) . "')";1386 $where_conditions[] = "t.name IN ('" . implode( "', '", array_map( 'esc_sql', $names ) ) . "')"; 1385 1387 } 1386 1388 … … 1388 1390 if ( is_array( $args['slug'] ) ) { 1389 1391 $slug = array_map( 'sanitize_title', $args['slug'] ); 1390 $where .= " ANDt.slug IN ('" . implode( "', '", $slug ) . "')";1392 $where_conditions[] = "t.slug IN ('" . implode( "', '", $slug ) . "')"; 1391 1393 } else { 1392 1394 $slug = sanitize_title( $args['slug'] ); 1393 $where .= " ANDt.slug = '$slug'";1395 $where_conditions[] = "t.slug = '$slug'"; 1394 1396 } 1395 1397 } 1396 1398 1397 1399 if ( ! empty( $args['name__like'] ) ) { 1398 $where .= $wpdb>prepare( " ANDt.name LIKE %s", '%' . $wpdb>esc_like( $args['name__like'] ) . '%' );1400 $where_conditions[] = $wpdb>prepare( "t.name LIKE %s", '%' . $wpdb>esc_like( $args['name__like'] ) . '%' ); 1399 1401 } 1400 1402 1401 1403 if ( ! empty( $args['description__like'] ) ) { 1402 $where .= $wpdb>prepare( " ANDtt.description LIKE %s", '%' . $wpdb>esc_like( $args['description__like'] ) . '%' );1404 $where_conditions[] = $wpdb>prepare( "tt.description LIKE %s", '%' . $wpdb>esc_like( $args['description__like'] ) . '%' ); 1403 1405 } 1404 1406 1405 1407 if ( '' !== $parent ) { 1406 1408 $parent = (int) $parent; 1407 $where .= " ANDtt.parent = '$parent'";1409 $where_conditions[] = "tt.parent = '$parent'"; 1408 1410 } 1409 1411 … … 1413 1415 } 1414 1416 if ( $args['hide_empty'] && !$hierarchical ) { 1415 $where .= ' ANDtt.count > 0';1417 $where_conditions[] = 'tt.count > 0'; 1416 1418 } 1417 1419 … … 1432 1434 if ( ! empty( $args['search'] ) ) { 1433 1435 $like = '%' . $wpdb>esc_like( $args['search'] ) . '%'; 1434 $where .= $wpdb>prepare( ' AND((t.name LIKE %s) OR (t.slug LIKE %s))', $like, $like );1436 $where_conditions[] = $wpdb>prepare( '((t.name LIKE %s) OR (t.slug LIKE %s))', $like, $like ); 1435 1437 } 1436 1438 … … 1445 1447 1446 1448 if ( ! empty( $meta_clauses ) ) { 1447 $join 1448 $where .= $mq_sql['where'];1449 $join .= $mq_sql['join']; 1450 $where_conditions[] = preg_replace( '/^\s*AND\s*/', '', $mq_sql['where'] ); 1449 1451 $distinct .= "DISTINCT"; 1450 1452 … … 1534 1536 $join .= " INNER JOIN $wpdb>term_taxonomy AS tt ON t.term_id = tt.term_id"; 1535 1537 1538 $where = implode( ' AND ', $where_conditions ); 1539 1536 1540 $pieces = array( 'fields', 'join', 'where', 'distinct', 'orderby', 'order', 'limits' ); 1537 1541 … … 1555 1559 $limits = isset( $clauses[ 'limits' ] ) ? $clauses[ 'limits' ] : ''; 1556 1560 1557 $query = "SELECT $distinct $fields FROM $wpdb>terms AS t $join WHERE $where $orderby $order $limits"; 1561 if ( $where ) { 1562 $where = "WHERE $where"; 1563 } 1564 1565 $query = "SELECT $distinct $fields FROM $wpdb>terms AS t $join $where $orderby $order $limits"; 1558 1566 1559 1567 // $args can be anything. Only use the args defined in defaults to compute the key.
Note: See TracChangeset
for help on using the changeset viewer.