Changeset 6226
- Timestamp:
- 10/11/2007 05:52:13 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.3/wp-admin/import/wp-cat2tag.php
r6147 r6226 64 64 print '</ul>'; 65 65 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>';66 print '<p class="submit"><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); 143 144 } 144 145 } 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 145 153 // Change the category to a tag. 146 154 $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); 147 159 148 160 // Set all parents to 0 (root-level) if their parent was the converted tag … … 161 173 } 162 174 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 187 175 function init() { 188 176 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; 198 178 199 179 $this->header(); … … 215 195 $this->convert_them(); 216 196 break; 217 218 case 3 :219 $this->convert_all_confirm();220 break;221 222 case 4 :223 $this->convert_all();224 break;225 197 } 226 198 }
Note: See TracChangeset
for help on using the changeset viewer.