Changeset 5563
- Timestamp:
- 05/27/2007 07:32:45 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/export.php
r5263 r5563 62 62 $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts $where ORDER BY post_date_gmt ASC"); 63 63 64 $categories = (array) $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename, category_description, category_parent, posts_private, links_private FROM $wpdb->categories LEFT JOIN $wpdb->post2cat ON (category_id = cat_id) LEFT JOIN $wpdb->posts ON (post_id <=> id) $where GROUP BY cat_id");64 $categories = (array) get_categories('get=all'); 65 65 66 66 function wxr_missing_parents($categories) { … … 69 69 70 70 foreach ( $categories as $category ) 71 $parents[$category-> cat_ID] = $category->category_parent;71 $parents[$category->term_id] = $category->parent; 72 72 73 73 $parents = array_unique(array_diff($parents, array_keys($parents))); … … 80 80 81 81 while ( $parents = wxr_missing_parents($categories) ) { 82 $found_parents = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename, category_description, category_parent, posts_private, links_private FROM $wpdb->categories WHERE cat_ID IN (" . join(', ', $parents) . ")");82 $found_parents = get_categories("include=" . join(', ', $parents)); 83 83 if ( is_array($found_parents) && count($found_parents) ) 84 84 $categories = array_merge($categories, $found_parents); … … 91 91 $passes = 1000 + count($categories); 92 92 while ( ( $cat = array_shift($categories) ) && ++$pass < $passes ) { 93 if ( $cat-> category_parent == 0 || isset($cats[$cat->category_parent]) ) {94 $cats[$cat-> cat_ID] = $cat;93 if ( $cat->parent == 0 || isset($cats[$cat->parent]) ) { 94 $cats[$cat->term_id] = $cat; 95 95 } else { 96 96 $categories[] = $cat; … … 111 111 112 112 function wxr_cat_name($c) { 113 if ( empty($c-> cat_name) )113 if ( empty($c->name) ) 114 114 return; 115 115 116 echo '<wp:cat_name>' . wxr_cdata($c-> cat_name) . '</wp:cat_name>';116 echo '<wp:cat_name>' . wxr_cdata($c->name) . '</wp:cat_name>'; 117 117 } 118 118 119 119 function wxr_category_description($c) { 120 if ( empty($c-> category_description) )120 if ( empty($c->description) ) 121 121 return; 122 122 123 echo '<wp:category_description>' . wxr_cdata($c-> category_description) . '</wp:category_description>';123 echo '<wp:category_description>' . wxr_cdata($c->description) . '</wp:category_description>'; 124 124 } 125 125 … … 164 164 <language><?php echo get_option('rss_language'); ?></language> 165 165 <?php if ( $cats ) : foreach ( $cats as $c ) : ?> 166 <wp:category><wp:category_nicename><?php echo $c-> category_nicename; ?></wp:category_nicename><wp:category_parent><?php echo $c->category_parent ? $cats[$c->category_parent]->cat_name : ''; ?></wp:category_parent><wp:posts_private><?php echo $c->posts_private ? '1' : '0'; ?></wp:posts_private><wp:links_private><?php echo $c->links_private ? '1' : '0'; ?></wp:links_private><?php wxr_cat_name($c); ?><?php wxr_category_description($c); ?></wp:category>166 <wp:category><wp:category_nicename><?php echo $c->slug; ?></wp:category_nicename><wp:category_parent><?php echo $c->parent ? $cats[$c->parent]->name : ''; ?></wp:category_parent><?php wxr_cat_name($c); ?><?php wxr_category_description($c); ?></wp:category> 167 167 <?php endforeach; endif; ?> 168 168 <?php do_action('rss2_head'); ?> -
trunk/wp-admin/index.php
r5308 r5563 102 102 $numposts = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'"); 103 103 $numcomms = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'"); 104 $numcats = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->categories"); 104 $numcats = wp_count_terms('category'); 105 $numtags = wp_count_terms('post_tag'); 105 106 106 107 $post_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Posts">post</a>', '%1$s <a href="%2$s" title="Posts">posts</a>', $numposts), number_format_i18n($numposts), 'edit.php'); … … 109 110 ?> 110 111 111 <p><?php printf(__('There are currently %1$s and %2$s, contained within %3$s .'), $post_str, $comm_str, $cat_str); ?></p>112 <p><?php printf(__('There are currently %1$s and %2$s, contained within %3$s and %4$s tags.'), $post_str, $comm_str, $cat_str, $numtags); ?></p> 112 113 </div> 113 114 -
trunk/wp-includes/deprecated.php
r5444 r5563 57 57 // Grab the first cat in the list. 58 58 $categories = get_the_category(); 59 $cat = $categories[0]-> cat_ID;59 $cat = $categories[0]->term_id; 60 60 61 61 if ( $echo ) … … 218 218 global $wpdb; 219 219 $cat_id = -1; 220 $results = $wpdb->get_results("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$cat_name'"); 221 if ($results) { 222 foreach ($results as $result) { 223 $cat_id = $result->cat_ID; 224 } 225 } 220 $cat = get_term_by('name', $cat_name, 'link_category'); 221 if ( $cat ) 222 $cat_id = $cat->term_id; 223 226 224 get_links($cat_id, $before, $after, $between, $show_images, $orderby, 227 225 $show_description, $show_rating, $limit, $show_updated); … … 236 234 global $wpdb; 237 235 238 $cat _id = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$category' LIMIT 1");239 240 if (! $cat_id)241 return;236 $cat = get_term_by('name', $cat_name, 'link_category'); 237 if ( !$cat ) 238 return false; 239 $cat_id = $cat->term_id; 242 240 243 241 $args = add_query_arg('category', $cat_id, $args); … … 264 262 ** } 265 263 **/ 266 // Deprecate in favor of get_linkz().267 264 function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) { 268 265 global $wpdb; 269 266 $cat_id = -1; 270 //$results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'"); 271 // TODO: Fix me. 272 if ($results) { 273 foreach ($results as $result) { 274 $cat_id = $result->cat_id; 275 } 276 } 267 $cat = get_term_by('name', $cat_name, 'link_category'); 268 if ( $cat ) 269 $cat_id = $cat->term_id; 270 277 271 return get_linkobjects($cat_id, $orderby, $limit); 278 272 } … … 314 308 **/ 315 309 // Deprecate in favor of get_linkz(). 316 function get_linkobjects($category = -1, $orderby = 'name', $limit = -1) {310 function get_linkobjects($category = 0, $orderby = 'name', $limit = 0) { 317 311 global $wpdb; 318 312 319 $sql = "SELECT * FROM $wpdb->links WHERE link_visible = 'Y'"; 320 if ($category != -1) { 321 $sql .= " AND link_category = $category "; 313 $links = get_bookmarks("category=$category&orderby=$orderby&limit=$limit"); 314 315 $links_array = array(); 316 foreach ($links as $link) { 317 $links_array[] = $link; 322 318 } 323 if ($orderby == '') 324 $orderby = 'id'; 325 if (substr($orderby,0,1) == '_') { 326 $direction = ' DESC'; 327 $orderby = substr($orderby,1); 328 } 329 if (strcasecmp('rand',$orderby) == 0) { 330 $orderby = 'rand()'; 331 } else { 332 $orderby = " link_" . $orderby; 333 } 334 $sql .= ' ORDER BY ' . $orderby; 335 $sql .= $direction; 336 /* The next 2 lines implement LIMIT TO processing */ 337 if ($limit != -1) 338 $sql .= " LIMIT $limit"; 339 340 $results = $wpdb->get_results($sql); 341 if ($results) { 342 foreach ($results as $result) { 343 $result->link_url = $result->link_url; 344 $result->link_name = $result->link_name; 345 $result->link_description = $result->link_description; 346 $result->link_notes = $result->link_notes; 347 $newresults[] = $result; 348 } 349 } 350 return $newresults; 319 320 return $links_array; 351 321 } 352 322 -
trunk/wp-includes/general-template.php
r5536 r5563 186 186 $category_name = $category_name[count($category_name)-2]; // there was a trailling slash 187 187 } 188 $title = $wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE category_nicename = '$category_name'"); 189 $title = apply_filters('single_cat_title', $title); 188 $cat = get_term_by('slug', $category_name, 'category'); 189 if ( $cat ) 190 $title = apply_filters('single_cat_title', $cat->name); 190 191 } 191 192 -
trunk/wp-includes/taxonomy.php
r5560 r5563 34 34 $args['object_type'] = $object_type; 35 35 $wp_taxonomies[$taxonomy] = $args; 36 } 37 38 function wp_count_terms( $taxonomy ) { 39 global $wpdb; 40 41 return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE taxonomy = '$taxonomy'"); 36 42 } 37 43
Note: See TracChangeset
for help on using the changeset viewer.