Ticket #35495: 35495.diff
| File 35495.diff, 2.7 KB (added by , 10 years ago) |
|---|
-
src/wp-includes/taxonomy.php
1123 1123 * @return array|int|WP_Error List of WP_Term instances and their children. Will return WP_Error, if any of $taxonomies 1124 1124 * do not exist. 1125 1125 */ 1126 function get_terms( $taxonomies , $args = '' ) {1126 function get_terms( $taxonomies = array(), $args = '' ) { 1127 1127 global $wpdb; 1128 1128 $empty_array = array(); 1129 1129 1130 1130 $single_taxonomy = ! is_array( $taxonomies ) || 1 === count( $taxonomies ); 1131 1131 if ( ! is_array( $taxonomies ) ) { 1132 $taxonomies = array( $taxonomies ); 1132 if ( empty( $taxonomies ) ) { 1133 $taxonomies = array(); 1134 } else { 1135 $taxonomies = array( $taxonomies ); 1136 } 1133 1137 } 1134 1138 1135 1139 foreach ( $taxonomies as $taxonomy ) { … … 1286 1290 $order = 'ASC'; 1287 1291 } 1288 1292 1289 $where = "tt.taxonomy IN ('" . implode("', '", $taxonomies) . "')"; 1293 $where = ""; 1294 if ( 0 < count( $taxonomies ) ) { 1295 $where = "tt.taxonomy IN ('" . implode("', '", $taxonomies) . "')"; 1296 } 1290 1297 1291 1298 $exclude = $args['exclude']; 1292 1299 $exclude_tree = $args['exclude_tree']; … … 1308 1315 if ( ! empty( $exclude_tree ) ) { 1309 1316 $exclude_tree = wp_parse_id_list( $exclude_tree ); 1310 1317 $excluded_children = $exclude_tree; 1318 $query_taxonomies = array(); 1319 if ( 0 < count( $taxonomies ) ) { 1320 $query_taxonomies = $taxonomies[0]; 1321 } 1311 1322 foreach ( $exclude_tree as $extrunk ) { 1312 1323 $excluded_children = array_merge( 1313 1324 $excluded_children, 1314 (array) get_terms( $ taxonomies[0], array( 'child_of' => intval( $extrunk ), 'fields' => 'ids', 'hide_empty' => 0 ) )1325 (array) get_terms( $query_taxonomies, array( 'child_of' => intval( $extrunk ), 'fields' => 'ids', 'hide_empty' => 0 ) ) 1315 1326 ); 1316 1327 } 1317 1328 $exclusions = array_merge( $excluded_children, $exclusions ); … … 1422 1433 $distinct .= "DISTINCT"; 1423 1434 } 1424 1435 1436 if ( 0 === strpos( $where, ' AND ' ) ) { 1437 $where = substr( $where, 5 ); 1438 } 1439 1425 1440 $selects = array(); 1426 1441 switch ( $args['fields'] ) { 1427 1442 case 'all': … … 1490 1505 $order = isset( $clauses[ 'order' ] ) ? $clauses[ 'order' ] : ''; 1491 1506 $limits = isset( $clauses[ 'limits' ] ) ? $clauses[ 'limits' ] : ''; 1492 1507 1493 $query = "SELECT $distinct $fields FROM $wpdb->terms AS t $join WHERE $where $orderby $order $limits"; 1508 if ( ! empty( $where ) ) { 1509 $where = "WHERE " . $where; 1510 } 1494 1511 1512 $query = "SELECT $distinct $fields FROM $wpdb->terms AS t $join $where $orderby $order $limits"; 1513 1495 1514 // $args can be anything. Only use the args defined in defaults to compute the key. 1496 1515 $key = md5( serialize( wp_array_slice_assoc( $args, array_keys( $defaults ) ) ) . serialize( $taxonomies ) . $query ); 1497 1516 $last_changed = wp_cache_get( 'last_changed', 'terms' );
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)