Changeset 5289

Show
Ignore:
Timestamp:
04/19/07 22:26:52 (1 year ago)
Author:
markjaquith
Message:

Roll tags out of 2.2 -- reverts [5272], [5271], [5257], [5254], [5253], [5251], [5250], [5243], [5235], [5234], [5232], [5231], [5229], [5228], [5217], [5216], [5215], [5213], half of [5210], [5209], [5205], [5203], [5201], [5196], [5184], [5168], [5163], [5162], [5150], [5149], [5148], [5147], [5113], [5112], [5111], and [5110]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2.2/wp-admin/admin-db.php

    r5272 r5289  
    122122        $links_private = 0; 
    123123 
    124     if ( empty($type) ) 
    125         $type = TAXONOMY_CATEGORY; 
    126  
    127     // Let's check if we have this category already, if so just do an update 
    128     if ( !$update && $cat_ID = category_object_exists( $category_nicename ) ) 
    129         $update = true; 
    130  
    131124    if (!$update) { 
    132         $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent, links_private, posts_private, type) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$category_parent', '$links_private', '$posts_private', '$type')"); 
     125        $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent, links_private, posts_private) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$category_parent', '$links_private', '$posts_private')"); 
    133126        $cat_ID = (int) $wpdb->insert_id; 
    134127    } else { 
    135         $wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent', links_private = '$links_private', posts_private = '$posts_private', type = '$type' WHERE cat_ID = '$cat_ID'"); 
     128        $wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent', links_private = '$links_private', posts_private = '$posts_private' WHERE cat_ID = '$cat_ID'"); 
    136129    } 
    137130 
     
    199192    $parent = $category->category_parent; 
    200193 
    201     // Delete the category if it is not also a tag. 
    202     if ( 0 == ($category->type & TAXONOMY_TAG) ) { 
    203         if ( !$wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'") ) 
    204             return 0; 
    205     } else { 
    206         $wpdb->query("UPDATE $wpdb->categories SET type = type & ~" . TAXONOMY_CATEGORY . " WHERE cat_ID = '$cat_ID'"); 
    207     } 
     194    // Delete the category 
     195    if ( !$wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'") ) 
     196        return 0; 
     197 
    208198    // Update children to point to new parent 
    209199    $wpdb->query("UPDATE $wpdb->categories SET category_parent = '$parent' WHERE category_parent = '$cat_ID'"); 
    210200 
    211201    // Only set posts and links to the default category if they're not in another category already 
    212     $posts = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE category_id='$cat_ID' AND rel_type = 'category'"); 
     202    $posts = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE category_id='$cat_ID'"); 
    213203    foreach ( (array) $posts as $post_id ) { 
    214204        $cats = wp_get_post_categories($post_id); 
     
    236226 
    237227function wp_create_category($cat_name) { 
    238     if ( $id = category_exists($cat_name) ) 
    239         return $id; 
    240     $cat_array = array('cat_name' => $cat_name, 'type' => TAXONOMY_CATEGORY); 
    241  
    242     if ( $id = category_object_exists($cat_name) ) { 
    243         $category = get_category($id); 
    244         $cat_array['type'] = $category->type | $cat_array['type']; 
    245         $cat_array['cat_ID'] = $id; 
    246         return wp_update_category($cat_array); 
    247     } else { 
    248         return wp_insert_category($cat_array); 
    249     } 
     228    $cat_array = compact('cat_name'); 
     229    return wp_insert_category($cat_array); 
    250230} 
    251231 
     
    266246} 
    267247 
    268 function category_object_exists($cat_name) { 
     248function category_exists($cat_name) { 
    269249    global $wpdb; 
    270250    if (!$category_nicename = sanitize_title($cat_name)) 
     
    272252 
    273253    return (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'"); 
    274 } 
    275  
    276 function category_exists($cat_name) { 
    277     global $wpdb; 
    278     if (!$category_nicename = sanitize_title($cat_name)) 
    279         return 0; 
    280  
    281     return (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename' AND ( type & " . TAXONOMY_CATEGORY .  " != 0 )"); 
    282 } 
    283  
    284 function tag_exists($tag_name) { 
    285     global $wpdb; 
    286     if (! $tag_nicename = sanitize_title($tag_name)) 
    287         return 0; 
    288  
    289     return (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$tag_nicename' AND ( type & " . TAXONOMY_TAG .  " != 0 )"); 
    290 } 
    291  
    292 function wp_create_tag($tag_name) { 
    293     if ( $id = tag_exists($tag_name) ) 
    294         return $id; 
    295     $tag_array = array('cat_name' => $tag_name, 'type' => TAXONOMY_TAG); 
    296  
    297     if ( $id = category_object_exists($tag_name) ) { 
    298         $category = get_category($id); 
    299         $tag_array['type'] = $category->type | $tag_array['type']; 
    300         $tag_array['cat_ID'] = $id; 
    301         $id = wp_update_category($tag_array); 
    302         return $id; 
    303     } else { 
    304         return wp_insert_category($tag_array); 
    305     } 
    306254} 
    307255 
  • branches/2.2/wp-admin/admin-functions.php

    r5259 r5289  
    648648function return_categories_list( $parent = 0 ) { 
    649649    global $wpdb; 
    650     return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent AND ( type & " . TAXONOMY_CATEGORY . " != 0 ) AND ( link_count = 0 OR category_count != 0 ) ORDER BY category_count DESC" ); 
     650    return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent AND ( link_count = 0 OR category_count != 0 OR ( link_count = 0 AND category_count = 0 ) ) ORDER BY category_count DESC" ); 
    651651} 
    652652 
     
    658658} 
    659659 
    660 function get_tags_to_edit( $post_id ) { 
    661     global $wpdb; 
    662  
    663     $post_id = (int) $post_id; 
    664     if ( !$post_id ) 
    665         return false; 
    666  
    667     $tags = $wpdb->get_results( " 
    668              SELECT category_id, cat_name 
    669              FROM $wpdb->categories, $wpdb->post2cat 
    670              WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$post_id' AND rel_type = 'tag' 
    671              " ); 
    672     if ( !$tags ) 
    673         return false; 
    674  
    675     foreach ( $tags as $tag ) 
    676         $tag_names[] = $tag->cat_name; 
    677     $tags_to_edit = join( ', ', $tag_names ); 
    678     $tags_to_edit = attribute_escape( $tags_to_edit ); 
    679     $tags_to_edit = apply_filters( 'tags_to_edit', $tags_to_edit ); 
    680     return $tags_to_edit; 
    681 } 
    682  
    683660function get_nested_categories( $default = 0, $parent = 0 ) { 
    684661    global $post_ID, $link_id, $mode, $wpdb; 
     
    688665             SELECT category_id 
    689666             FROM $wpdb->categories, $wpdb->post2cat 
    690              WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$post_ID' AND rel_type = 'category' 
     667             WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$post_ID' 
    691668             " ); 
    692669 
     
    745722function return_link_categories_list( $parent = 0 ) { 
    746723    global $wpdb; 
    747     return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent AND ( type & " . TAXONOMY_CATEGORY . " != 0 ) AND ( category_count = 0 OR link_count != 0 ) ORDER BY link_count DESC" ); 
     724    return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent AND ( category_count = 0  OR link_count != 0 OR ( link_count = 0 AND category_count = 0 ) ) ORDER BY link_count DESC" ); 
    748725} 
    749726 
  • branches/2.2/wp-admin/categories.php

    r5217 r5289  
    119119 
    120120<?php include('edit-category-form.php'); ?> 
    121  
    122 <div class="wrap"> 
    123 <h3><?php _e('Importers &amp; Converters'); ?></h3> 
    124  
    125 <ul> 
    126     <li><a href="admin.php?import=wp-cat2tag"><?php _e('Selectively convert categories to tags'); ?></a></li> 
    127     <li><a href="admin.php?import=utw"><?php _e('Import Ultimate Tag Warrior tags'); ?></a></li> 
    128 </ul> 
    129 </div> 
    130121<?php endif; ?> 
    131122 
  • branches/2.2/wp-admin/edit-form-advanced.php

    r5257 r5289  
    160160<?php echo $form_prevstatus ?> 
    161161 
    162 <fieldset id="tagdiv"> 
    163     <legend><?php _e('Tags (separate multiple tags with commas: cats, pet food, dogs)'); ?></legend> 
    164     <div><input type="text" name="tags_input" id="tags-input" size="30" tabindex="3" value="<?php echo get_tags_to_edit( $post_ID ); ?>" /></div> 
    165 </fieldset> 
    166162 
    167163<p class="submit"> 
  • branches/2.2/wp-admin/options-permalink.php

    r5150 r5289  
    7474        $wp_rewrite->set_category_base($category_base); 
    7575    } 
    76  
    77     if ( isset($_POST['tag_base']) ) { 
    78         $tag_base = $_POST['tag_base']; 
    79         if (! empty($tag_base) ) 
    80             $tag_base = preg_replace('#/+#', '/', '/' . $_POST['tag_base']); 
    81         $wp_rewrite->set_tag_base($tag_base); 
    82     } 
    8376} 
    8477 
    8578$permalink_structure = get_option('permalink_structure'); 
    8679$category_base = get_option('category_base'); 
    87 $tag_base = get_option( 'tag_base' ); 
    8880 
    8981if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') ) 
     
    168160    <p>  
    169161  <?php _e('Category base'); ?>: <input name="category_base" type="text" class="code"  value="<?php echo attribute_escape($category_base); ?>" size="30" />  
    170      </p> 
    171       <p> 
    172       <?php _e('Tag base'); ?>: <input name="tag_base" type="text" class="code"  value="<?php echo attribute_escape($tag_base); ?>" size="30" />  
    173162     </p>  
    174163    <p class="submit">  
  • branches/2.2/wp-admin/upgrade-schema.php

    r5184 r5289  
    1919  category_count bigint(20) NOT NULL default '0', 
    2020  link_count bigint(20) NOT NULL default '0', 
    21   tag_count bigint(20) NOT NULL default '0', 
    2221  posts_private tinyint(1) NOT NULL default '0', 
    2322  links_private tinyint(1) NOT NULL default '0', 
    24   type tinyint NOT NULL default '1', 
    2523  PRIMARY KEY  (cat_ID), 
    2624  KEY category_nicename (category_nicename) 
     
    9189  post_id bigint(20) NOT NULL default '0', 
    9290  category_id bigint(20) NOT NULL default '0', 
    93   rel_type varchar(64) NOT NULL default 'category', 
    9491  PRIMARY KEY  (rel_id), 
    9592  KEY post_id (post_id,category_id) 
     
    244241    add_option('show_on_front', 'posts'); 
    245242 
    246     // 2.2 
    247     add_option('tag_base'); 
    248  
    249243    // Delete unused options 
    250244    $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing'); 
  • branches/2.2/wp-admin/wp-admin.css

    r5256 r5289  
    539539} 
    540540 
    541 #postdiv, #titlediv, #guiddiv, #tagdiv
     541#postdiv, #titlediv, #guiddiv
    542542    margin: 0 8px 0 0; 
    543543    padding: 0; 
     
    559559} 
    560560 
    561 #titlediv input, #guiddiv input, #tagdiv input
     561#titlediv input, #guiddiv input
    562562    margin: 0; 
    563563    width: 100%; 
  • branches/2.2/wp-content/themes/classic/index.php

    r5168 r5289  
    99<div class="post" id="post-<?php the_ID(); ?>"> 
    1010     <h3 class="storytitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3> 
    11     <div class="meta"><?php _e("Filed under:"); ?> <?php the_category(',') ?> &#8212; <?php the_tags(__('Tags: '), ', ', ' &#8212; '); ?> <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></div> 
     11    <div class="meta"><?php _e("Filed under:"); ?> <?php the_category(',') ?> &#8212; <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></div> 
    1212 
    1313    <div class="storycontent"> 
  • branches/2.2/wp-content/themes/default/archive.php

    r5250 r5289  
    22 
    33    <div id="content" class="narrowcolumn"> 
    4 <?php is_tag(); ?> 
     4 
    55        <?php if (have_posts()) : ?> 
    66 
    7     <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?> 
    8      <?php /* If this is a category archive */ if (is_category()) { ?> 
     7        <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?> 
     8<?php /* If this is a category archive */ if (is_category()) { ?> 
    99        <h2 class="pagetitle">Archive for the &#8216;<?php single_cat_title(); ?>&#8217; Category</h2> 
    10       <?php /* If this is a tag archive */ } elseif( is_tag() ) { ?> 
    11         <h2 class="pagetitle">Posts Tagged &#8216;<?php single_cat_title(); ?>&#8217;</h2> 
     10 
    1211      <?php /* If this is a daily archive */ } elseif (is_day()) { ?> 
    1312        <h2 class="pagetitle">Archive for <?php the_time('F jS, Y'); ?></h2> 
    14       <?php /* If this is a monthly archive */ } elseif (is_month()) { ?> 
     13 
     14     <?php /* If this is a monthly archive */ } elseif (is_month()) { ?> 
    1515        <h2 class="pagetitle">Archive for <?php the_time('F, Y'); ?></h2> 
    16       <?php /* If this is a yearly archive */ } elseif (is_year()) { ?> 
     16 
     17        <?php /* If this is a yearly archive */ } elseif (is_year()) { ?> 
    1718        <h2 class="pagetitle">Archive for <?php the_time('Y'); ?></h2> 
     19 
    1820      <?php /* If this is an author archive */ } elseif (is_author()) { ?> 
    1921        <h2 class="pagetitle">Author Archive</h2> 
    20       <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?> 
     22 
     23        <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?> 
    2124        <h2 class="pagetitle">Blog Archives</h2> 
    22       <?php } ?> 
     25 
     26        <?php } ?> 
    2327 
    2428 
     
    3741                </div> 
    3842 
    39                 <p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p> 
     43                <p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p> 
    4044 
    4145            </div> 
  • branches/2.2/wp-content/themes/default/index.php

    r5111 r5289  
    1515                </div> 
    1616 
    17                 <p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p> 
     17                <p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p> 
    1818            </div> 
    1919 
  • branches/2.2/wp-content/themes/default/search.php

    r5149 r5289  
    1919                <small><?php the_time('l, F jS, Y') ?></small> 
    2020 
    21                 <p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p> 
     21                <p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p> 
    2222            </div> 
    2323 
  • branches/2.2/wp-content/themes/default/single.php

    r5147 r5289  
    1717 
    1818                <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?> 
    19                 <?php the_tags( '<p>Tags: ', ', ', '</p>'); ?> 
    2019 
    2120                <p class="postmetadata alt"> 
  • branches/2.2/wp-includes/category-template.php

    r5265 r5289  
    273273} 
    274274 
    275 function wp_tag_cloud( $args = '' ) { 
    276     $defaults = array( 
    277         'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,  
    278         'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC', 
    279         'exclude' => '', 'include' => '' 
    280     ); 
    281     $args = wp_parse_args( $args, $defaults ); 
    282  
    283     $tags = get_tags( array_merge($args, array('orderby' => 'count', 'order' => 'DESC')) ); // Always query top tags 
    284  
    285     if ( empty($tags) ) 
    286         return; 
    287  
    288     $return = wp_generate_tag_cloud( $tags, $args ); // Here's where those top tags get sorted according to $args 
    289     echo apply_filters( 'wp_tag_cloud', $return, $args ); 
    290 } 
    291  
    292 // $tags = prefetched tag array ( get_tags() ) 
    293 // $args['format'] = 'flat' => whitespace separated, 'list' => UL, 'array' => array() 
    294 // $args['orderby'] = 'name', 'count' 
    295 function wp_generate_tag_cloud( $tags, $args = '' ) { 
    296     global $wp_rewrite; 
    297     $defaults = array( 
    298         'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45, 
    299         'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC' 
    300     ); 
    301     $args = wp_parse_args( $args, $defaults ); 
    302     extract($args); 
    303  
    304     if ( !$tags ) 
    305         return; 
    306     $counts = $tag_links = array(); 
    307     foreach ( (array) $tags as $tag ) { 
    308         $counts[$tag->cat_name] = $tag->tag_count; 
    309         $tag_links[$tag->cat_name] = get_tag_link( $tag->cat_ID ); 
    310     } 
    311  
    312     $min_count = min($counts); 
    313     $spread = max($counts) - $min_count; 
    314     if ( $spread <= 0 ) 
    315         $spread = 1; 
    316     $font_spread = $largest - $smallest; 
    317     if ( $font_spread <= 0 ) 
    318         $font_spread = 1; 
    319     $font_step = $font_spread / $spread; 
    320  
    321     // SQL cannot save you; this is a second (potentially different) sort on a subset of data. 
    322     if ( 'name' == $orderby ) 
    323         uksort($counts, 'strnatcasecmp'); 
    324     else 
    325         asort($counts); 
    326  
    327     if ( 'DESC' == $order ) 
    328         $counts = array_reverse( $tag_counts, true ); 
    329  
    330     $a = array(); 
    331  
    332     $rel = ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) ? ' rel="tag"' : ''; 
    333  
    334     foreach ( $counts as $tag => $count ) { 
    335         $tag_link = clean_url($tag_links[$tag]); 
    336         $tag = str_replace(' ', '&nbsp;', wp_specialchars( $tag )); 
    337         $a[] = "<a href='$tag_link' title='" . attribute_escape( sprintf( __('%d topics'), $count ) ) . "'$rel style='font-size: " . 
    338             ( $smallest + ( ( $count - $min_count ) * $font_step ) ) 
    339             . "$unit;'>$tag</a>"; 
    340     } 
    341  
    342     switch ( $format ) : 
    343     case 'array' : 
    344         $return =& $a; 
    345         break; 
    346     case 'list' : 
    347         $return = "<ul class='wp-tag-cloud'>\n\t<li>"; 
    348         $return .= join("</li>\n\t<li>", $a); 
    349         $return .= "</li>\n</ul>\n"; 
    350         break; 
    351     default : 
    352         $return = join("\n", $a); 
    353         break; 
    354     endswitch; 
    355  
    356     return apply_filters( 'wp_generate_tag_cloud', $return, $tags, $args ); 
    357 } 
    358  
    359275// 
    360276// Helper functions 
     
    373289} 
    374290 
    375 // 
    376 // Tags 
    377 // 
    378  
    379 function get_tag_link( $tag_id ) { 
    380     global $wp_rewrite; 
    381     $catlink = $wp_rewrite->get_tag_permastruct(); 
    382  
    383     $category = &get_category($tag_id); 
    384     $category_nicename = $category->category_nicename; 
    385  
    386     if ( empty($catlink) ) { 
    387         $file = get_option('home') . '/'; 
    388         $catlink = $file . '?tag=' . $category_nicename; 
    389     } else { 
    390  
    391         $catlink = str_replace('%tag%', $category_nicename, $catlink); 
    392         $catlink = get_option('home') . user_trailingslashit($catlink, 'category'); 
    393     } 
    394     return apply_filters('tag_link', $catlink, $tag_id); 
    395 } 
    396  
    397 function get_the_tags( $id = 0 ) { 
    398     global $post;  
    399   
    400     $id = (int) $id; 
    401  
    402     if ( ! $id && ! in_the_loop() )  
    403         return false; // in-the-loop function  
    404   
    405     if ( !$id )  
    406         $id = (int) $post->ID; 
    407  
    408     $tags = wp_get_post_tags( $id ); 
    409     $tags = apply_filters( 'get_the_tags', $tags ); 
    410     if ( empty( $tags ) )  
    411         return false;  
    412     return $tags;  
    413 } 
    414  
    415 function the_tags( $before = 'Tags: ', $sep = ', ', $after = '' ) { 
    416     $tags = get_the_tags(); 
    417  
    418     if ( empty( $tags ) ) 
    419         return false; 
    420      
    421     $tag_list = $before; 
    422     foreach ( $tags as $tag ) 
    423         $tag_links[] = '<a href="' . get_tag_link($tag->cat_ID) . '">' . $tag->cat_name . '</a>'; 
    424  
    425     $tag_links = join( $sep, $tag_links ); 
    426     $tag_links = apply_filters( 'the_tags', $tag_links ); 
    427     $tag_list .= $tag_links; 
    428  
    429     $tag_list .= $after; 
    430  
    431     echo $tag_list; 
    432 } 
    433  
    434291?> 
  • branches/2.2/wp-includes/category.php

    r5248 r5289  
    11<?php 
    2  
    3 define('TAXONOMY_CATEGORY', 1); 
    4 define('TAXONOMY_TAG', 2); 
    52 
    63function get_all_category_ids() { 
     
    8178        else 
    8279            $where .= ' AND category_count > 0'; 
    83     } else { 
    84         $where .= ' AND ( type & ' . TAXONOMY_CATEGORY . ' != 0 ) '; 
    85     } 
    86  
    87      
     80    } 
    8881 
    8982    if ( !empty($number) ) 
     
    214207} 
    215208 
    216 function get_category_by_slug( $slug  ) { 
    217     global $wpdb; 
    218     $slug = sanitize_title( $slug ); 
    219     if ( empty( $slug ) ) 
    220         return false; 
    221     $category = $wpdb->get_var( "SELECT * FROM $wpdb->categories WHERE category_nicename = '$slug' " ); 
    222     return get_category( $category ); 
    223 } 
    224  
    225209// Get the ID of a category from its name 
    226210function get_cat_ID($cat_name='General') { 
     
    345329    return $children; 
    346330} 
    347  
    348 // Tags 
    349  
    350 function &get_tags($args = '') { 
    351     global $wpdb, $category_links; 
    352  
    353     $defaults = array('orderby' => 'name', 'order' => 'ASC', 
    354         'hide_empty' => true, 'exclude' => '', 'include' => '', 
    355         'number' => ''); 
    356     $args = wp_parse_args( $args, $defaults ); 
    357     if ( 'count' == $args['orderby'] ) 
    358         $args['orderby'] = 'tag_count'; 
    359     else 
    360         $args['orderby'] = "cat_" . $args['orderby'];  // restricts order by to cat_ID and cat_name fields 
    361     $args['number'] = (int) $args['number']; 
    362     extract($args); 
    363  
    364     $key = md5( serialize( $args ) ); 
    365     if ( $cache = wp_cache_get( 'get_tags', 'category' ) ) 
    366         if ( isset( $cache[ $key ] ) ) 
    367             return apply_filters('get_tags', $cache[$key], $args); 
    368  
    369     $where = 'cat_ID > 0'; 
    370     $inclusions = ''; 
    371     if ( !empty($include) ) { 
    372         $child_of = 0; //ignore child_of and exclude params if using include 
    373         $exclude = ''; 
    374         $incategories = preg_split('/[\s,]+/',$include); 
    375         if ( count($incategories) ) { 
    376             foreach ( $incategories as $incat ) { 
    377                 if (empty($inclusions)) 
    378                     $inclusions = ' AND ( cat_ID = ' . intval($incat) . ' '; 
    379                 else 
    380                     $inclusions .= ' OR cat_ID = ' . intval($incat) . ' '; 
    381             } 
    382         } 
    383     } 
    384  
    385     if (!empty($inclusions)) 
    386         $inclusions .= ')'; 
    387     $where .= $inclusions; 
    388  
    389     $exclusions = ''; 
    390     if ( !empty($exclude) ) { 
    391         $excategories = preg_split('/[\s,]+/',$exclude); 
    392         if ( count($excategories) ) { 
    393             foreach ( $excategories as $excat ) { 
    394                 if (empty($exclusions)) 
    395                     $exclusions = ' AND ( cat_ID <> ' . intval($excat) . ' '; 
    396                 else 
    397                     $exclusions .= ' AND cat_ID <> ' . intval($excat) . ' '; 
    398             } 
    399         } 
    400     } 
    401  
    402     if (!empty($exclusions)) 
    403         $exclusions .= ')'; 
    404     $exclusions = apply_filters('list_tags_exclusions', $exclusions, $args ); 
    405     $where .= $exclusions; 
    406  
    407     if ( $hide_empty ) 
    408         $where .= ' AND tag_count > 0'; 
    409  
    410     $where .= ' AND ( type & ' . TAXONOMY_TAG . ' != 0 ) '; 
    411  
    412     if ( !empty($number) ) 
    413         $number = 'LIMIT ' . $number; 
    414     else 
    415         $number = ''; 
    416  
    417     $tags = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE $where ORDER BY $orderby $order $number"); 
    418  
    419     if ( empty($tags) ) 
    420         return array(); 
    421  
    422     $cache[ $key ] = $tags; 
    423     wp_cache_set( 'get_tags', $cache, 'category' ); 
    424  
    425     $tags = apply_filters('get_tags', $tags, $args); 
    426     return $tags; 
    427 } 
    428  
    429331?> 
  • branches/2.2/wp-includes/classes.php

    r5164 r5289  
    22 
    33class WP { 
    4     var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots'); 
     4    var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots'); 
    55 
    66    var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type'); 
  • branches/2.2/wp-includes/functions.php

    r5284 r5289  
    603603 
    604604function clean_post_cache($id) { 
    605     global $post_cache, $post_meta_cache, $category_cache, $tag_cache, $blog_id; 
     605    global $post_cache, $post_meta_cache, $category_cache, $blog_id; 
    606606 
    607607    if ( isset( $post_cache[$blog_id][$id] ) ) 
     
    613613    if ( isset( $category_cache[$blog_id][$id]) ) 
    614614        unset ( $category_cache[$blog_id][$id] ); 
    615  
    616     if ( isset( $tag_cache[$blog_id][$id]) ) 
    617         unset ( $tag_cache[$blog_id][$id] ); 
    618615} 
    619616 
     
    642639 
    643640function update_post_category_cache($post_ids) { 
    644     global $wpdb, $category_cache, $tag_cache, $blog_id; 
     641    global $wpdb, $category_cache, $blog_id; 
    645642 
    646643    if ( empty($post_ids) ) 
     
    663660    $post_id_list = join( ',', $post_id_array ); // with already cached stuff removed 
    664661 
    665     $dogs = $wpdb->get_results("SELECT post_id, category_id, rel_type FROM $wpdb->post2cat WHERE post_id IN ($post_id_list)"); 
     662    $dogs = $wpdb->get_results("SELECT post_id, category_id FROM $wpdb->post2cat WHERE post_id IN ($post_id_list)"); 
    666663 
    667664    if ( empty($dogs) ) 
    668665        return; 
    669666 
    670     foreach ($dogs as $catt) { 
    671         if ( 'category' == $catt->rel_type ) 
    672             $category_cache[$blog_id][$catt->post_id][$catt->category_id] = &get_category($catt->category_id); 
    673         elseif ( 'tag' == $catt->rel_type ) 
    674             $tag_cache[$blog_id][$catt->post_id][$catt->category_id] = &get_category($catt->category_id); 
    675     } 
     667    foreach ($dogs as $catt) 
     668        $category_cache[$blog_id][$catt->post_id][$catt->category_id] = &get_category($catt->category_id); 
    676669} 
    677670 
    678671function update_post_caches(&$posts) { 
    679     global $post_cache, $category_cache, $post_meta_cache, $tag_cache
     672    global $post_cache, $category_cache, $post_meta_cache
    680673    global $wpdb, $blog_id; 
    681674 
     
    14761469} 
    14771470 
    1478 function wp_parse_args( $args, $defaults = '' ) { 
    1479     if ( is_array($args) ) : 
    1480         $r =& $args; 
    1481     else : 
    1482         parse_str( $args, $r ); 
    1483         if ( get_magic_quotes_gpc() ) 
    1484             $r = stripslashes_deep( $r ); 
    1485     endif; 
    1486  
    1487     if ( is_array($defaults) ) : 
    1488         extract($defaults); 
    1489         extract($r); 
    1490         return compact(array_keys($defaults)); // only those options defined in $defaults 
    1491     else : 
    1492         return $r; 
    1493     endif; 
    1494 } 
    1495  
    14961471?> 
  • branches/2.2/wp-includes/link-template.php

    r5282 r5289  
    6060        '%post_id%', 
    6161        '%category%', 
    62         '%tag%', 
    6362        '%author%', 
    6463        '%pagename%' 
  • branches/2.2/wp-includes/post.php

    r5271 r5289  
    459459} 
    460460 
    461 function wp_get_post_tags( $post_id = 0 ) { 
    462     global $tag_cache, $blog_id; 
    463  
    464     $post_id = (int) $post_id; 
    465      
    466     if ( !isset( $tag_cache[$blog_id][$post_id] ) ) 
    467         update_post_category_cache( $post_id ); // loads $tag_cache 
    468  
    469     return $tag_cache[$blog_id][$post_id]; 
    470 } 
    471  
    472461function wp_get_recent_posts($num = 10) { 
    473462    global $wpdb; 
     
    531520        $comment_status  = apply_filters('comment_status_pre', $comment_status); 
    532521        $ping_status     = apply_filters('ping_status_pre',    $ping_status); 
    533         $tags_input      = apply_filters('tags_input_pre',     $tags_input); 
    534522    } 
    535523 
     
    666654    } 
    667655 
    668     wp_set_post_categories( $post_ID, $post_category ); 
    669     wp_set_post_tags( $post_ID, $tags_input ); 
     656    wp_set_post_categories($post_ID, $post_category); 
    670657 
    671658    if ( 'page' == $post_type ) { 
     
    785772} 
    786773 
    787 function wp_add_post_tags($post_id = 0, $tags = '') { 
    788     return wp_set_post_tags($post_id, $tags, true); 
    789 } 
    790  
    791 function wp_set_post_tags( $post_id = 0, $tags = '', $append = false ) { 
    792     /* $append - true = don't delete existing tags, just add on, false = replace the tags with the new tags */ 
    793     global $wpdb; 
    794      
    795     $post_id = (int) $post_id; 
    796      
    797     if ( !$post_id ) 
    798         return false; 
    799      
    800     // prevent warnings for unintialized variables 
    801     $tag_ids = array(); 
    802  
    803     if ( empty($tags) ) 
    804         $tags = array(); 
    805     $tags = (is_array($tags)) ? $tags : explode( ',', $tags ); 
    806      
    807     foreach ( $tags as $tag ) { 
    808         $tag = trim( $tag ); 
    809         if ( !$tag_slug = sanitize_title( $tag ) ) 
    810             continue; // discard 
    811         if ( !$tag_id = tag_exists( $tag ) ) 
    812             $tag_id = wp_create_tag( $tag ); 
    813         $tag_ids[] = $tag_id; 
    814     } 
    815  
    816     if ( empty($tag_ids) && ( !empty($tags) || $append ) ) 
    817         return false; 
    818      
    819     $tag_ids = array_unique( $tag_ids ); 
    820      
    821     // First the old tags 
    822     $old_tags = $wpdb->get_col(" 
    823         SELECT category_id 
    824         FROM $wpdb->post2cat 
    825         WHERE post_id = '$post_id' AND rel_type = 'tag'"); 
    826      
    827     if ( !$old_tags ) { 
    828         $old_tags = array(); 
    829     } else { 
    830         $old_tags = array_unique( $old_tags ); 
    831     } 
    832      
    833     // Delete any? 
    834     $delete_tags = array_diff( $old_tags, $tag_ids); 
    835     if ( $delete_tags && !$append ) { 
    836         foreach ( $delete_tags as $del ) { 
    837             $wpdb->query(" 
    838                 DELETE FROM $wpdb->post2cat 
    839                 WHERE category_id = '$del' 
    840                     AND post_id = '$post_id' 
    841                     AND rel_type = 'tag' 
    842                 "); 
    843         } 
    844     } 
    845      
    846     // Add any? 
    847     $add_tags = array_diff( $tag_ids, $old_tags ); 
    848     if ( $add_tags ) { 
    849         foreach ( $add_tags as $new_tag ) { 
    850             $new_tag = (int) $new_tag; 
    851             if ( !empty($new_tag) ) 
    852                 $wpdb->query(" 
    853                     INSERT INTO $wpdb->post2cat (post_id, category_id, rel_type)  
    854                     VALUES ('$post_id', '$new_tag', 'tag')"); 
    855         } 
    856     } 
    857      
    858     // Update category counts. 
    859     $all_affected_tags = array_unique( array_merge( $tag_ids, $old_tags ) ); 
    860     foreach ( $all_affected_tags as $tag_id ) { 
    861         $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_status = 'publish' AND post_type = 'post' AND category_id = '$tag_id' AND rel_type = 'tag'" ); 
    862         $wpdb->query( "UPDATE $wpdb->categories SET tag_count = '$count', type = type | " . TAXONOMY_TAG . " WHERE cat_ID = '$tag_id'" ); 
    863         if ( $count == 0 ) 
    864             $wpdb->query( "UPDATE $wpdb->categories SET type = type & ~". TAXONOMY_TAG . " WHERE cat_ID = '$tag_id'" ); 
    865         clean_category_cache( $tag_id ); 
    866         do_action( 'edit_category', $tag_id ); 
    867         do_action( 'edit_tag', $tag_id ); 
    868     } 
    869 } 
    870  
    871774function wp_set_post_categories($post_ID = 0, $post_categories = array()) { 
    872775    global $wpdb; 
     
    883786        SELECT category_id 
    884787        FROM $wpdb->post2cat 
    885         WHERE post_id = '$post_ID' AND rel_type = 'category'"); 
     788        WHERE post_id = '$post_ID'"); 
    886789 
    887790    if (!$old_categories) { 
     
    899802                DELETE FROM $wpdb->post2cat 
    900803                WHERE category_id = '$del' 
    901                     AND post_id = '$post_ID' AND rel_type = 'category' 
     804                    AND post_id = '$post_ID' 
    902805                "); 
    903806        } 
     
    920823    $all_affected_