WordPress.org

Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/categories.php

    r4258 r3422  
    44$title = __('Categories');
    55$parent_file = 'edit.php';
     6$list_js = true;
    67
    7 wp_reset_vars(array('action', 'cat'));
     8$wpvarstoreset = array('action','cat');
     9for ($i=0; $i<count($wpvarstoreset); $i += 1) {
     10    $wpvar = $wpvarstoreset[$i];
     11    if (!isset($$wpvar)) {
     12        if (empty($_POST["$wpvar"])) {
     13            if (empty($_GET["$wpvar"])) {
     14                $$wpvar = '';
     15            } else {
     16                $$wpvar = $_GET["$wpvar"];
     17            }
     18        } else {
     19            $$wpvar = $_POST["$wpvar"];
     20        }
     21    }
     22}
    823
    924switch($action) {
     
    1126case 'addcat':
    1227
    13     check_admin_referer('add-category');
     28    if ( !current_user_can('manage_categories') )
     29        die (__('Cheatin&#8217; uh?'));
     30   
     31    wp_insert_category($_POST);
    1432
    15     if ( !current_user_can('manage_categories') )
    16         wp_die(__('Cheatin&#8217; uh?'));
    17 
    18     if( wp_insert_category($_POST ) ) {
    19         wp_redirect('categories.php?message=1#addcat');
    20     } else {
    21         wp_redirect('categories.php?message=4#addcat');
    22     }
     33    header('Location: categories.php?message=1#addcat');
    2334break;
    2435
    2536case 'delete':
    26     $cat_ID = (int) $_GET['cat_ID'];
    27     check_admin_referer('delete-category_' .  $cat_ID);
     37
     38    check_admin_referer();
    2839
    2940    if ( !current_user_can('manage_categories') )
    30         wp_die(__('Cheatin&#8217; uh?'));
     41        die (__('Cheatin&#8217; uh?'));
    3142
     43    $cat_ID = (int) $_GET['cat_ID'];
    3244    $cat_name = get_catname($cat_ID);
    3345
    34     // Don't delete the default cats.
    35     if ( $cat_ID == get_option('default_category') )
    36         wp_die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the default one"), $cat_name));
    37 
    38     if ( $cat_ID == get_option('default_link_category') )
    39         wp_die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the default one for bookmarks"), $cat_name));
     46    if ( 1 == $cat_ID )
     47        die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the default one"), $cat_name));
    4048
    4149    wp_delete_category($cat_ID);
    4250
    43     wp_redirect('categories.php?message=2');
     51    header('Location: categories.php?message=2');
    4452
    4553break;
     
    5058    $cat_ID = (int) $_GET['cat_ID'];
    5159    $category = get_category_to_edit($cat_ID);
    52     include('edit-category-form.php');
     60    ?>
     61
     62<div class="wrap">
     63 <h2><?php _e('Edit Category') ?></h2>
     64 <form name="editcat" action="categories.php" method="post">
     65      <table class="editform" width="100%" cellspacing="2" cellpadding="5">
     66        <tr>
     67          <th width="33%" scope="row"><?php _e('Category name:') ?></th>
     68          <td width="67%"><input name="cat_name" type="text" value="<?php echo wp_specialchars($category->cat_name); ?>" size="40" /> <input type="hidden" name="action" value="editedcat" />
     69<input type="hidden" name="cat_ID" value="<?php echo $category->cat_ID ?>" /></td>
     70        </tr>
     71        <tr>
     72            <th scope="row"><?php _e('Category slug:') ?></th>
     73            <td><input name="category_nicename" type="text" value="<?php echo wp_specialchars($category->category_nicename); ?>" size="40" /></td>
     74        </tr>
     75        <tr>
     76            <th scope="row"><?php _e('Category parent:') ?></th>
     77            <td>       
     78            <select name='category_parent'>
     79      <option value='0' <?php if (!$category->category_parent) echo " selected='selected'"; ?>><?php _e('None') ?></option>
     80      <?php wp_dropdown_cats($category->cat_ID, $category->category_parent); ?>
     81      </select></td>
     82        </tr>
     83        <tr>
     84            <th scope="row"><?php _e('Description:') ?></th>
     85            <td><textarea name="category_description" rows="5" cols="50" style="width: 97%;"><?php echo wp_specialchars($category->category_description, 1); ?></textarea></td>
     86        </tr>
     87        </table>
     88      <p class="submit"><input type="submit" name="submit" value="<?php _e('Edit category') ?> &raquo;" /></p>
     89 </form>
     90 <p><a href="categories.php"><?php _e('&laquo; Return to category list'); ?></a></p>
     91</div>
     92    <?php
    5393
    5494break;
    5595
    5696case 'editedcat':
    57     $cat_ID = (int) $_POST['cat_ID'];
    58     check_admin_referer('update-category_' . $cat_ID);
    59 
    6097    if ( !current_user_can('manage_categories') )
    61         wp_die(__('Cheatin&#8217; uh?'));
    62 
     98        die (__('Cheatin&#8217; uh?'));
     99   
    63100    wp_update_category($_POST);
    64101
    65     wp_redirect('categories.php?message=3');
     102    header('Location: categories.php?message=3');
    66103break;
    67104
    68105default:
    69106
    70 wp_enqueue_script( 'admin-categories' );
    71107require_once ('admin-header.php');
    72108
     
    74110$messages[2] = __('Category deleted.');
    75111$messages[3] = __('Category updated.');
    76 $messages[4] = __('Category not added.');
    77112?>
    78113
     
    87122    <h2><?php _e('Categories') ?> </h2>
    88123<?php endif; ?>
    89 <table class="widefat">
    90     <thead>
     124<table id="the-list-x" width="100%" cellpadding="3" cellspacing="3">
    91125    <tr>
    92         <th scope="col" style="text-align: center"><?php _e('ID') ?></th>
     126        <th scope="col"><?php _e('ID') ?></th>
    93127        <th scope="col"><?php _e('Name') ?></th>
    94128        <th scope="col"><?php _e('Description') ?></th>
    95         <th scope="col" width="90" style="text-align: center"><?php _e('Posts') ?></th>
    96         <th scope="col" width="90" style="text-align: center"><?php _e('Bookmarks') ?></th>
    97         <th colspan="2" style="text-align: center"><?php _e('Action') ?></th>
     129        <th scope="col"><?php _e('# Posts') ?></th>
     130        <th colspan="2"><?php _e('Action') ?></th>
    98131    </tr>
    99     </thead>
    100     <tbody id="the-list">
    101132<?php
    102133cat_rows();
    103134?>
    104     </tbody>
    105135</table>
     136
     137<div id="ajax-response"></div>
    106138
    107139</div>
     
    109141<?php if ( current_user_can('manage_categories') ) : ?>
    110142<div class="wrap">
    111 <p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the posts and bookmarks in that category.  Instead, posts in the deleted category are set to the category <strong>%s</strong> and bookmarks are set to <strong>%s</strong>.'), get_catname(get_option('default_category')), get_catname(get_option('default_link_category'))) ?></p>
     143<p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete posts from that category, it will just set them back to the default category <strong>%s</strong>.'), get_catname(get_option('default_category'))) ?></p>
    112144</div>
    113145
    114 <?php include('edit-category-form.php'); ?>
     146<div class="wrap">
     147    <h2><?php _e('Add New Category') ?></h2>
     148    <form name="addcat" id="addcat" action="categories.php" method="post">
     149       
     150        <p><?php _e('Name:') ?><br />
     151        <input type="text" name="cat_name" value="" /></p>
     152        <p><?php _e('Category parent:') ?><br />
     153        <select name='category_parent' class='postform'>
     154        <option value='0'><?php _e('None') ?></option>
     155        <?php wp_dropdown_cats(0); ?>
     156        </select></p>
     157        <p><?php _e('Description: (optional)') ?> <br />
     158        <textarea name="category_description" rows="5" cols="50" style="width: 97%;"></textarea></p>
     159        <p class="submit"><input type="hidden" name="action" value="addcat" /><input type="submit" name="submit" value="<?php _e('Add Category &raquo;') ?>" /></p>
     160    </form>
     161</div>
    115162<?php endif; ?>
    116163
     
    120167
    121168include('admin-footer.php');
    122 
    123169?>
Note: See TracChangeset for help on using the changeset viewer.