Make WordPress Core

Changeset 6226


Ignore:
Timestamp:
10/11/2007 05:52:13 PM (17 years ago)
Author:
ryan
Message:

Lose Convert All Categories button. It is confusing people. Props foolswisdom. fixes #5058 for 2.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.3/wp-admin/import/wp-cat2tag.php

    r6147 r6226  
    6464        print '</ul>';
    6565
    66         print '<p class="submit"><input type="submit" name="maybe_convert_all_cats" value="' . __('Convert All Categories') . '" /> <input type="submit" name="submit" value="' . __('Convert &raquo;') . '" /></p>';
     66        print '<p class="submit"><input type="submit" name="submit" value="' . __('Convert &raquo;') . '" /></p>';
    6767        print '</form>';
    6868    }
     
    141141                        if ( !$wpdb->get_var("SELECT object_id FROM $wpdb->term_relationships WHERE object_id = '$post' AND term_taxonomy_id = '$id'") )                       
    142142                            $wpdb->query("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id) VALUES ('$post', '$id')");
     143                        clean_post_cache($post);
    143144                    }
    144145                } else {
     146                    $tt_ids = $wpdb->get_col("SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE term_id = '{$category->term_id}' AND taxonomy = 'category'");
     147                    if ( $tt_ids ) {
     148                        $posts = $wpdb->get_col("SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id IN (" . join(',', $tt_ids) . ") GROUP BY object_id");
     149                        foreach ( (array) $posts as $post )
     150                            clean_post_cache($post);
     151                    }
     152
    145153                    // Change the category to a tag.
    146154                    $wpdb->query("UPDATE $wpdb->term_taxonomy SET taxonomy = 'post_tag' WHERE term_id = '{$category->term_id}' AND taxonomy = 'category'");
     155
     156                    $terms = $wpdb->get_col("SELECT term_id FROM $wpdb->term_taxonomy WHERE parent = '{$category->term_id}' AND taxonomy = 'category'");
     157                    foreach ( (array) $terms as $term )
     158                        clean_category_cache($term);
    147159
    148160                    // Set all parents to 0 (root-level) if their parent was the converted tag
     
    161173    }
    162174
    163     function convert_all_confirm() {
    164         print '<div class="narrow">';
    165 
    166         print '<h3>' . __('Confirm') . '</h3>';
    167 
    168         print '<p>' . __('You are about to convert all categories to tags. Are you sure you want to continue?') . '</p>';
    169 
    170         print '<form action="admin.php?import=wp-cat2tag" method="post">';
    171         wp_nonce_field('import-cat2tag');
    172         print '<p style="text-align:center" class="submit"><input type="submit" value="' . __('Yes') . '" name="yes_convert_all_cats" />&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" value="' . __('No') . '" name="no_dont_do_it" /></p>';
    173         print '</form>';
    174 
    175         print '</div>';
    176     }
    177 
    178     function convert_all() {
    179         global $wpdb;
    180 
    181         $this->populate_all_categories();
    182         foreach ( $this->all_categories as $category )
    183             $this->categories_to_convert[] = $category->term_id;
    184         $this->convert_them();
    185     }
    186 
    187175    function init() {
    188176
    189         if (isset($_POST['maybe_convert_all_cats'])) {
    190             $step = 3;
    191         } elseif (isset($_POST['yes_convert_all_cats'])) {
    192             $step = 4;
    193         } elseif (isset($_POST['no_dont_do_it'])) {
    194             die('no_dont_do_it');
    195         } else {
    196             $step = (isset($_GET['step'])) ? (int) $_GET['step'] : 1;
    197         }
     177        $step = (isset($_GET['step'])) ? (int) $_GET['step'] : 1;
    198178
    199179        $this->header();
     
    215195                    $this->convert_them();
    216196                break;
    217 
    218                 case 3 :
    219                     $this->convert_all_confirm();
    220                 break;
    221 
    222                 case 4 :
    223                     $this->convert_all();
    224                 break;
    225197            }
    226198        }
Note: See TracChangeset for help on using the changeset viewer.