3 * Edit category form for inclusion in administration panels.
6 * @subpackage Administration
10 if ( !defined('ABSPATH') )
13 if ( !current_user_can('manage_categories') )
14 wp_die(__('You do not have sufficient permissions to edit categories for this blog.'));
19 if ( ! isset( $category ) )
20 $category = (object) array();
25 * @internal Used to prevent errors in page when no category is being edited.
27 * @param object $category
29 function _fill_empty_category(&$category) {
30 if ( ! isset( $category->name ) )
33 if ( ! isset( $category->slug ) )
36 if ( ! isset( $category->parent ) )
37 $category->parent = '';
39 if ( ! isset( $category->description ) )
40 $category->description = '';
43 do_action('edit_category_form_pre', $category);
45 _fill_empty_category($category);
49 <?php screen_icon(); ?>
50 <h2><?php _e('Edit Category'); ?></h2>
51 <div id="ajax-response"></div>
52 <form name="editcat" id="editcat" method="post" action="categories.php" class="validate">
53 <input type="hidden" name="action" value="editedcat" />
54 <input type="hidden" name="cat_ID" value="<?php echo esc_attr($category->term_id) ?>" />
55 <?php wp_original_referer_field(true, 'previous'); wp_nonce_field('update-category_' . $cat_ID); ?>
56 <table class="form-table">
57 <tr class="form-field form-required">
58 <th scope="row" valign="top"><label for="cat_name"><?php _e('Category Name') ?></label></th>
59 <td><input name="cat_name" id="cat_name" type="text" value="<?php echo esc_attr($category->name); ?>" size="40" aria-required="true" /><br />
60 <span class="description"><?php _e('The name is used to identify the category almost everywhere, for example under the post or in the category widget.'); ?></span></td>
62 <tr class="form-field">
63 <th scope="row" valign="top"><label for="category_nicename"><?php _e('Category Slug') ?></label></th>
64 <td><input name="category_nicename" id="category_nicename" type="text" value="<?php echo esc_attr(apply_filters('editable_slug', $category->slug)); ?>" size="40" /><br />
65 <span class="description"><?php _e('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></span></td>
67 <tr class="form-field">
68 <th scope="row" valign="top"><label for="category_parent"><?php _e('Category Parent') ?></label></th>
70 <?php wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'category_parent', 'orderby' => 'name', 'selected' => $category->parent, 'hierarchical' => true, 'show_option_none' => __('None'))); ?><br />
71 <span class="description"><?php _e('Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.'); ?></span>
74 <tr class="form-field">
75 <th scope="row" valign="top"><label for="category_description"><?php _e('Description') ?></label></th>
76 <td><textarea name="category_description" id="category_description" rows="5" cols="50" style="width: 97%;"><?php echo esc_html($category->description); ?></textarea><br />
77 <span class="description"><?php _e('The description is not prominent by default, however some themes may show it.'); ?></span></td>
79 <?php do_action('edit_category_form_fields', $category); ?>
81 <p class="submit"><input type="submit" class="button-primary" name="submit" value="<?php esc_attr_e('Update Category'); ?>" /></p>
82 <?php do_action('edit_category_form', $category); ?>