Changeset 6394
- Timestamp:
- 12/16/2007 10:07:32 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/import/wp-cat2tag.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/import/wp-cat2tag.php
r6225 r6394 1 <?php 1 <?php 2 2 3 3 class WP_Categories_to_Tags { … … 6 6 7 7 function header() { 8 print'<div class="wrap">';9 print'<h2>' . __('Convert Categories to Tags') . '</h2>';8 echo '<div class="wrap">'; 9 echo '<h2>' . __('Convert Categories to Tags') . '</h2>'; 10 10 } 11 11 12 12 function footer() { 13 print'</div>';13 echo '</div>'; 14 14 } 15 15 … … 27 27 $this->populate_all_categories(); 28 28 29 print'<div class="narrow">';29 echo '<div class="narrow">'; 30 30 31 31 if (count($this->all_categories) > 0) { 32 print '<p>' . __('Howdy! This converter allows you to selectively convert existing categories to tags. To get started, check the checkboxes ofthe categories you wish to be converted, then click the Convert button.') . '</p>';33 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>';32 echo '<p>' . __('Hey there. Here you can selectively converts existing categories to tags. To get started, check the categories you wish to be converted, then click the Convert button.') . '</p>'; 33 echo '<p>' . __('Keep in mind that if you convert a category with child categories, the children become top-level orphans.') . '</p>'; 34 34 35 35 $this->categories_form(); 36 36 } else { 37 print'<p>'.__('You have no categories to convert!').'</p>';38 } 39 40 print'</div>';37 echo '<p>'.__('You have no categories to convert!').'</p>'; 38 } 39 40 echo '</div>'; 41 41 } 42 42 43 43 function categories_form() { 44 print '<form action="admin.php?import=wp-cat2tag&step=2" method="post">'; 44 ?> 45 <script type="text/javascript"> 46 <!-- 47 var checkflag = "false"; 48 function check_all_rows() { 49 field = document.formlist; 50 if ( 'false' == checkflag ) { 51 for ( i = 0; i < field.length; i++ ) { 52 if ( 'cats_to_convert[]' == field[i].name ) 53 field[i].checked = true; 54 } 55 checkflag = 'true'; 56 return '<?php _e('Uncheck All') ?>'; 57 } else { 58 for ( i = 0; i < field.length; i++ ) { 59 if ( 'cats_to_convert[]' == field[i].name ) 60 field[i].checked = false; 61 } 62 checkflag = 'false'; 63 return '<?php _e('Check All') ?>'; 64 } 65 } 66 67 // --> 68 </script> 69 <?php 70 echo '<form name="formlist" id="formlist" action="admin.php?import=wp-cat2tag&step=2" method="post"> 71 <p><input type="button" value="' . __('Check All') . '"' . ' onClick="this.value=check_all_rows()"></p>'; 45 72 wp_nonce_field('import-cat2tag'); 46 print'<ul style="list-style:none">';73 echo '<ul style="list-style:none">'; 47 74 48 75 $hier = _get_term_hierarchy('category'); … … 52 79 53 80 if ((int) $category->parent == 0) { 54 print'<li><label><input type="checkbox" name="cats_to_convert[]" value="' . intval($category->term_id) . '" /> ' . $category->name . ' (' . $category->count . ')</label>';81 echo '<li><label><input type="checkbox" name="cats_to_convert[]" value="' . intval($category->term_id) . '" /> ' . $category->name . ' (' . $category->count . ')</label>'; 55 82 56 83 if (isset($hier[$category->term_id])) { … … 58 85 } 59 86 60 print '</li>'; 61 } 62 } 63 64 print '</ul>'; 65 66 print '<p class="submit"><input type="submit" name="submit" value="' . __('Convert »') . '" /></p>'; 67 print '</form>'; 87 echo '</li>'; 88 } 89 } 90 91 echo '</ul>'; 92 93 echo '<p class="submit"><input type="submit" name="submit" value="' . __('Convert Tags »') . '" /></p>'; 94 95 echo '</form>'; 68 96 } 69 97 70 98 function _category_children($parent, $hier) { 71 print'<ul style="list-style:none">';99 echo '<ul style="list-style:none">'; 72 100 73 101 foreach ($hier[$parent->term_id] as $child_id) { 74 102 $child =& get_category($child_id); 75 103 76 print'<li><label><input type="checkbox" name="cats_to_convert[]" value="' . intval($child->term_id) . '" /> ' . $child->name . ' (' . $child->count . ')</label>';104 echo '<li><label><input type="checkbox" name="cats_to_convert[]" value="' . intval($child->term_id) . '" /> ' . $child->name . ' (' . $child->count . ')</label>'; 77 105 78 106 if (isset($hier[$child->term_id])) { … … 80 108 } 81 109 82 print'</li>';83 } 84 85 print'</ul>';110 echo '</li>'; 111 } 112 113 echo '</ul>'; 86 114 } 87 115 … … 104 132 105 133 if ( (!isset($_POST['cats_to_convert']) || !is_array($_POST['cats_to_convert'])) && empty($this->categories_to_convert)) { 106 print'<div class="narrow">';107 print '<p>' . sprintf(__('Uh, oh. Something didn\'t work. Please <a href="%s">try again</a>.'), 'admin.php?import=wp-cat2tag') . '</p>';108 print'</div>';134 echo '<div class="narrow">'; 135 echo '<p>' . sprintf(__('Uh, oh. Something didn’t work. Please <a href="%s">try again</a>.'), 'admin.php?import=wp-cat2tag') . '</p>'; 136 echo '</div>'; 109 137 return; 110 138 } … … 115 143 $hier = _get_term_hierarchy('category'); 116 144 117 print'<ul>';145 echo '<ul>'; 118 146 119 147 foreach ( (array) $this->categories_to_convert as $cat_id) { 120 148 $cat_id = (int) $cat_id; 121 149 122 print'<li>' . sprintf(__('Converting category #%s ... '), $cat_id);150 echo '<li>' . sprintf(__('Converting category #%s ... '), $cat_id); 123 151 124 152 if (!$this->_category_exists($cat_id)) { … … 129 157 if ( tag_exists($wpdb->escape($category->name)) ) { 130 158 _e('Category is already a tag.'); 131 print'</li>';159 echo '</li>'; 132 160 continue; 133 161 } … … 167 195 } 168 196 169 print '</li>'; 170 } 171 172 print '</ul>'; 197 echo '</li>'; 198 } 199 200 echo '</ul>'; 201 echo '<p>' . sprintf( __('We’re all done here, but you can always <a href="%s">convert more</a>.'), 'admin.php?import=wp-cat2tag' ) . '</p>'; 173 202 } 174 203 … … 180 209 181 210 if (!current_user_can('manage_categories')) { 182 print'<div class="narrow">';183 print'<p>' . __('Cheatin’ uh?') . '</p>';184 print'</div>';211 echo '<div class="narrow">'; 212 echo '<p>' . __('Cheatin’ uh?') . '</p>'; 213 echo '</div>'; 185 214 } else { 186 215 if ( $step > 1 )
Note: See TracChangeset
for help on using the changeset viewer.