Changeset 815
- Timestamp:
- 02/01/04 02:00:26 (5 years ago)
- Files:
-
- trunk/wp-admin/admin-functions.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/wp-admin/admin-functions.php
r800 r815 3 3 4 4 // Dandy new recursive multiple category stuff. 5 function cat_rows($parent = 0, $level = 0 ) {5 function cat_rows($parent = 0, $level = 0, $categories = 0) { 6 6 global $wpdb, $tablecategories, $tablepost2cat, $bgcolor; 7 $categories = $wpdb->get_results("SELECT * FROM $tablecategories WHERE category_parent = $parent ORDER BY cat_name"); 7 if (!$categories) { 8 $categories = $wpdb->get_results("SELECT * FROM $tablecategories ORDER BY cat_name"); 9 } 8 10 if ($categories) { 9 11 foreach ($categories as $category) { 10 $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $tablepost2cat WHERE category_id = $category->cat_ID"); 11 $pad = str_repeat('— ', $level); 12 if ($category->category_parent == $parent) { 13 $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $tablepost2cat WHERE category_id = $category->cat_ID"); 14 $pad = str_repeat('— ', $level); 12 15 13 $bgcolor = ('#eee' == $bgcolor) ? 'none' : '#eee';14 echo "<tr style='background-color: $bgcolor'><td>$pad $category->cat_name</td>15 <td>$category->category_description</td>16 <td>$count</td>17 <td><a href='categories.php?action=edit&cat_ID=$category->cat_ID' class='edit'>Edit</a></td><td><a href='categories.php?action=Delete&cat_ID=$category->cat_ID' onclick=\"return confirm('You are about to delete the category \'". addslashes($category->cat_name) ."\' and all its posts will go to the default category.\\n \'OK\' to delete, \'Cancel\' to stop.')\" class='delete'>Delete</a></td>18 </tr>";16 $bgcolor = ('#eee' == $bgcolor) ? 'none' : '#eee'; 17 echo "<tr style='background-color: $bgcolor'><td>$pad $category->cat_name</td> 18 <td>$category->category_description</td> 19 <td>$count</td> 20 <td><a href='categories.php?action=edit&cat_ID=$category->cat_ID' class='edit'>Edit</a></td><td><a href='categories.php?action=Delete&cat_ID=$category->cat_ID' onclick=\"return confirm('You are about to delete the category \'". addslashes($category->cat_name) ."\' and all its posts will go to the default category.\\n \'OK\' to delete, \'Cancel\' to stop.')\" class='delete'>Delete</a></td> 21 </tr>"; 19 22 cat_rows($category->cat_ID, $level + 1); 23 } 20 24 } 21 25 } else { … … 24 28 } 25 29 26 function wp_dropdown_cats($currentcat, $currentparent = 0, $parent = 0, $level = 0 ) {30 function wp_dropdown_cats($currentcat, $currentparent = 0, $parent = 0, $level = 0, $categories = 0) { 27 31 global $wpdb, $tablecategories, $tablepost2cat, $bgcolor; 28 $categories = $wpdb->get_results("SELECT * FROM $tablecategories WHERE category_parent = $parent ORDER BY cat_name"); 32 if (!$categories) { 33 $categories = $wpdb->get_results("SELECT * FROM $tablecategories ORDER BY cat_name"); 34 } 29 35 if ($categories) { 30 foreach ($categories as $category) { if ($currentcat != $category->cat_ID ) {36 foreach ($categories as $category) { if ($currentcat != $category->cat_ID && $parent == $category->category_parent) { 31 37 $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $tablepost2cat WHERE category_id = $category->cat_ID"); 32 38 $pad = str_repeat('– ', $level); … … 35 41 echo " selected='selected'"; 36 42 echo ">$pad$category->cat_name</option>"; 37 if ($currentcat != $category->cat_ID) 38 wp_dropdown_cats($currentcat, $currentparent, $category->cat_ID, $level + 1); 43 wp_dropdown_cats($currentcat, $currentparent, $category->cat_ID, $level + 1, $categories); 39 44 } } 40 45 } else {
