Changeset 5251
- Timestamp:
- 04/12/2007 05:46:36 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/import/wp-cat2tag.php
r5229 r5251 17 17 global $wpdb; 18 18 19 $this->all_categories = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE (type & ~ " . TAXONOMY_TAG . ") != 0 ORDER BY cat_name ASC");19 $this->all_categories = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE (type & ~ " . TAXONOMY_TAG . ") != 0 AND category_count > 0 ORDER BY cat_name ASC"); 20 20 } 21 21 22 22 function welcome() { 23 $this->populate_all_categories(); 24 23 25 print '<div class="narrow">'; 24 print '<p>' . __('Howdy! This converter allows you to selectively convert existing categories to tags. To get started, check the checkboxes of the categories you wish to be converted, then click the Convert button.') . '</p>'; 25 print '<p>' . __('Keep in mind that if you convert a category with child categories, those child categories get their parent setting removed, so they\'re in the root.') . '</p>'; 26 27 $this->categories_form(); 26 27 if (count($this->all_categories) > 0) { 28 print '<p>' . __('Howdy! This converter allows you to selectively convert existing categories to tags. To get started, check the checkboxes of the categories you wish to be converted, then click the Convert button.') . '</p>'; 29 print '<p>' . __('Keep in mind that if you convert a category with child categories, those child categories get their parent setting removed, so they\'re in the root.') . '</p>'; 30 31 $this->categories_form(); 32 } else { 33 print '<p>You have no categories to convert!</p>'; 34 } 28 35 29 36 print '</div>'; … … 31 38 32 39 function categories_form() { 33 $this->populate_all_categories();34 35 40 print '<form action="admin.php?import=wp-cat2tag&step=2" method="post">'; 36 41 print '<ul style="list-style:none">'; … … 51 56 52 57 print '</ul>'; 53 print '<p class="submit"><input type="submit" name="submit" value="' . __('Convert »') . '" /></p>'; 58 59 print '<p class="submit"><input type="submit" name="maybe_convert_all_cats" value="' . __('Convert All Categories') . '" /> <input type="submit" name="submit" value="' . __('Convert »') . '" /></p>'; 54 60 print '</form>'; 55 61 } … … 139 145 } 140 146 147 function convert_all_confirm() { 148 print '<div class="narrow">'; 149 150 print '<h3>' . __('Confirm') . '</h3>'; 151 152 print '<p>' . __('You are about to convert all categories to tags. Are you sure you want to continue?') . '</p>'; 153 154 print '<form action="admin.php?import=wp-cat2tag" method="post">'; 155 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>'; 156 print '</form>'; 157 158 print '</div>'; 159 } 160 161 function convert_all() { 162 global $wpdb; 163 164 $cats = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE (type & ~ " . TAXONOMY_TAG . ") != 0 AND category_count > 0"); 165 166 $_POST['cats_to_convert'] = array(); 167 168 foreach ($cats as $cat) { 169 $_POST['cats_to_convert'][] = $cat->cat_ID; 170 } 171 172 $this->convert_them(); 173 } 174 141 175 function init() { 142 if (!isset($_GET['step'])) { 143 $step = 1; 144 } else { 145 $step = (int) $_GET['step']; 176 echo '<!--'; print_r($_POST); print_r($_GET); echo '-->'; 177 178 if (isset($_POST['maybe_convert_all_cats'])) { 179 $step = 3; 180 } elseif (isset($_POST['yes_convert_all_cats'])) { 181 $step = 4; 182 } elseif (isset($_POST['no_dont_do_it'])) { 183 die('no_dont_do_it'); 184 } else { 185 $step = (isset($_GET['step'])) ? (int) $_GET['step'] : 1; 146 186 } 147 187 … … 161 201 $this->convert_them(); 162 202 break; 203 204 case 3 : 205 $this->convert_all_confirm(); 206 break; 207 208 case 4 : 209 $this->convert_all(); 210 break; 163 211 } 164 212 }
Note: See TracChangeset
for help on using the changeset viewer.