mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-12-06 12:51:58 +00:00
Fail more gracefully for lower level users
git-svn-id: https://develop.svn.wordpress.org/trunk@1862 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -106,22 +106,26 @@ function dropdown_categories($default = 0) {
|
||||
|
||||
// Dandy new recursive multiple category stuff.
|
||||
function cat_rows($parent = 0, $level = 0, $categories = 0) {
|
||||
global $wpdb, $bgcolor;
|
||||
if (!$categories) {
|
||||
global $wpdb, $bgcolor, $user_level;
|
||||
if (!$categories)
|
||||
$categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");
|
||||
}
|
||||
|
||||
if ($categories) {
|
||||
foreach ($categories as $category) {
|
||||
if ($category->category_parent == $parent) {
|
||||
$category->cat_name = htmlspecialchars($category->cat_name);
|
||||
$count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID");
|
||||
$pad = str_repeat('— ', $level);
|
||||
|
||||
if ( $user_level > 3 )
|
||||
$edit = "<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('". sprintf(__("You are about to delete the category \'%s\'. All of its posts will go to the default category.\\n \'OK\' to delete, \'Cancel\' to stop."), addslashes($category->cat_name)) . "')\" class='delete'>" . __('Delete') . "</a>";
|
||||
else
|
||||
$edit = '';
|
||||
|
||||
$class = ('alternate' == $class) ? '' : 'alternate';
|
||||
echo "<tr class='$class'><th scope='row'>$category->cat_ID</th><td>$pad $category->cat_name</td>
|
||||
<td>$category->category_description</td>
|
||||
<td>$count</td>
|
||||
<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('". sprintf(__("You are about to delete the category \'%s\'. All of its posts will go to the default category.\\n \'OK\' to delete, \'Cancel\' to stop."), addslashes($category->cat_name)) . "')\" class='delete'>" . __('Delete') . "</a></td>
|
||||
<td>$edit</td>
|
||||
</tr>";
|
||||
cat_rows($category->cat_ID, $level + 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user