Changes from branches/2.3/wp-admin/import/wp-cat2tag.php at r6226 to trunk/wp-admin/import/wp-cat2tag.php at r6147
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/import/wp-cat2tag.php
r6226 r6147 64 64 print '</ul>'; 65 65 66 print '<p class="submit"><input type="submit" name=" submit" value="' . __('Convert »') . '" /></p>';66 print '<p class="submit"><input type="submit" name="maybe_convert_all_cats" value="' . __('Convert All Categories') . '" /> <input type="submit" name="submit" value="' . __('Convert »') . '" /></p>'; 67 67 print '</form>'; 68 68 } … … 141 141 if ( !$wpdb->get_var("SELECT object_id FROM $wpdb->term_relationships WHERE object_id = '$post' AND term_taxonomy_id = '$id'") ) 142 142 $wpdb->query("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id) VALUES ('$post', '$id')"); 143 clean_post_cache($post);144 143 } 145 144 } 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 153 145 // Change the category to a tag. 154 146 $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);159 147 160 148 // Set all parents to 0 (root-level) if their parent was the converted tag … … 173 161 } 174 162 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" /> <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 175 187 function init() { 176 188 177 $step = (isset($_GET['step'])) ? (int) $_GET['step'] : 1; 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 } 178 198 179 199 $this->header(); … … 195 215 $this->convert_them(); 196 216 break; 217 218 case 3 : 219 $this->convert_all_confirm(); 220 break; 221 222 case 4 : 223 $this->convert_all(); 224 break; 197 225 } 198 226 }
Note: See TracChangeset
for help on using the changeset viewer.