Changeset 8572 for trunk/wp-includes/taxonomy.php
- Timestamp:
- 08/06/2008 08:31:54 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/taxonomy.php
r8433 r8572 50 50 51 51 $taxonomies = array(); 52 foreach ( $wp_taxonomies as $taxonomy ) {52 foreach ( (array) $wp_taxonomies as $taxonomy ) { 53 53 if ( array_intersect($object, (array) $taxonomy->object_type) ) 54 54 $taxonomies[] = $taxonomy->name; … … 231 231 $taxonomies = array($taxonomies); 232 232 233 foreach ( $taxonomies as $taxonomy ) {233 foreach ( (array) $taxonomies as $taxonomy ) { 234 234 if ( ! is_taxonomy($taxonomy) ) 235 235 return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy')); … … 426 426 $children = $terms[$term]; 427 427 428 foreach ( $terms[$term] as $child ) {428 foreach ( (array) $terms[$term] as $child ) { 429 429 if ( isset($terms[$child]) ) 430 430 $children = array_merge($children, get_term_children($child, $taxonomy)); … … 559 559 } 560 560 561 foreach ( $taxonomies as $taxonomy ) {561 foreach ( (array) $taxonomies as $taxonomy ) { 562 562 if ( ! is_taxonomy($taxonomy) ) 563 563 return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy')); … … 627 627 $interms = preg_split('/[\s,]+/',$include); 628 628 if ( count($interms) ) { 629 foreach ( $interms as $interm ) {629 foreach ( (array) $interms as $interm ) { 630 630 if (empty($inclusions)) 631 631 $inclusions = ' AND ( t.term_id = ' . intval($interm) . ' '; … … 644 644 $exterms = preg_split('/[\s,]+/',$exclude); 645 645 if ( count($exterms) ) { 646 foreach ( $exterms as $exterm ) {646 foreach ( (array) $exterms as $exterm ) { 647 647 if (empty($exclusions)) 648 648 $exclusions = ' AND ( t.term_id <> ' . intval($exterm) . ' '; … … 722 722 723 723 // Make sure we show empty categories that have children. 724 if ( $hierarchical && $hide_empty ) {724 if ( $hierarchical && $hide_empty && is_array($terms) ) { 725 725 foreach ( $terms as $k => $term ) { 726 726 if ( ! $term->count ) { 727 727 $children = _get_term_children($term->term_id, $terms, $taxonomies[0]); 728 foreach ( $children as $child ) 729 if ( $child->count ) 730 continue 2; 728 if( is_array($children) ) 729 foreach ( $children as $child ) 730 if ( $child->count ) 731 continue 2; 731 732 732 733 // It really is empty … … 825 826 $do_object = true; 826 827 827 foreach ( $fields as $field ) {828 foreach ( (array) $fields as $field ) { 828 829 if ( $do_object ) 829 830 $term->$field = sanitize_term_field($field, $term->$field, $term->term_id, $taxonomy, $context); … … 956 957 $taxonomies = array($taxonomies); 957 958 958 foreach ( $taxonomies as $taxonomy ) {959 foreach ( (array) $taxonomies as $taxonomy ) { 959 960 $terms = wp_get_object_terms($object_id, $taxonomy, 'fields=tt_ids'); 960 961 $in_terms = "'" . implode("', '", $terms) . "'"; … … 1083 1084 $taxonomies = array($taxonomies); 1084 1085 1085 foreach ( $taxonomies as $taxonomy ) {1086 foreach ( (array) $taxonomies as $taxonomy ) { 1086 1087 if ( ! is_taxonomy($taxonomy) ) 1087 1088 return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy')); … … 1324 1325 $term_ids = array(); 1325 1326 1326 foreach ( $terms as $term) {1327 foreach ( (array) $terms as $term) { 1327 1328 if ( !strlen(trim($term)) ) 1328 1329 continue; … … 1588 1589 1589 1590 if ( $do_deferred ) { 1590 foreach ( array_keys($_deferred) as $tax ) {1591 foreach ( (array) array_keys($_deferred) as $tax ) { 1591 1592 wp_update_term_count_now( $_deferred[$tax], $tax ); 1592 1593 unset( $_deferred[$tax] ); … … 1629 1630 } else { 1630 1631 // Default count updater 1631 foreach ( $terms as $term) {1632 foreach ( (array) $terms as $term) { 1632 1633 $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term) ); 1633 1634 $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) ); … … 1822 1823 */ 1823 1824 function update_term_cache($terms, $taxonomy = '') { 1824 foreach ( $terms as $term ) {1825 foreach ( (array) $terms as $term ) { 1825 1826 $term_taxonomy = $taxonomy; 1826 1827 if ( empty($term_taxonomy) ) … … 1897 1898 return $empty_array; 1898 1899 1899 foreach ( $terms as $term ) {1900 foreach ( (array) $terms as $term ) { 1900 1901 $use_id = false; 1901 1902 if ( !is_object($term) ) { … … 1957 1958 $term_items = array(); 1958 1959 1959 foreach ( $terms as $key => $term ) {1960 foreach ( (array) $terms as $key => $term ) { 1960 1961 $terms_by_id[$term->term_id] = & $terms[$key]; 1961 1962 $term_ids[$term->term_taxonomy_id] = $term->term_id; … … 2007 2008 global $wpdb; 2008 2009 2009 foreach ( $terms as $term ) {2010 foreach ( (array) $terms as $term ) { 2010 2011 $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term ) ); 2011 2012 $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
Note: See TracChangeset
for help on using the changeset viewer.