<?php
-if ( ! empty($cat_ID) ) {
- $heading = __('Edit Category');
- $submit_text = __('Edit Category');
- $form = '<form name="editcat" id="editcat" method="post" action="categories.php" class="validate">';
- $action = 'editedcat';
- $nonce_action = 'update-category_' . $cat_ID;
- do_action('edit_category_form_pre', $category);
-} else {
- $heading = __('Add Category');
- $submit_text = __('Add Category');
- $form = '<form name="addcat" id="addcat" method="post" action="categories.php" class="add:the-list: validate">';
- $action = 'addcat';
- $nonce_action = 'add-category';
- do_action('add_category_form_pre', $category);
+/**
+ * Edit category form for inclusion in administration panels.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * @var object
+ */
+if ( ! isset( $category ) )
+ $category = (object) array();
+
+/**
+ * @ignore
+ * @since 2.7
+ * @internal Used to prevent errors in page when no category is being edited.
+ *
+ * @param object $category
+ */
+function _fill_empty_category(&$category) {
+ if ( ! isset( $category->name ) )
+ $category->name = '';
+
+ if ( ! isset( $category->slug ) )
+ $category->slug = '';
+
+ if ( ! isset( $category->parent ) )
+ $category->parent = '';
+
+ if ( ! isset( $category->description ) )
+ $category->description = '';
}
+
+do_action('edit_category_form_pre', $category);
+
+_fill_empty_category($category);
?>
<div class="wrap">
-<h2><?php echo $heading ?></h2>
+<?php screen_icon(); ?>
+<h2><?php _e('Edit Category'); ?></h2>
<div id="ajax-response"></div>
-<?php echo $form ?>
-<input type="hidden" name="action" value="<?php echo $action ?>" />
+<form name="editcat" id="editcat" method="post" action="categories.php" class="validate">
+<input type="hidden" name="action" value="editedcat" />
<input type="hidden" name="cat_ID" value="<?php echo $category->term_id ?>" />
-<?php wp_nonce_field($nonce_action); ?>
+<?php wp_original_referer_field(true, 'previous'); wp_nonce_field('update-category_' . $cat_ID); ?>
<table class="form-table">
<tr class="form-field form-required">
<th scope="row" valign="top"><label for="cat_name"><?php _e('Category Name') ?></label></th>
<?php _e('The description is not prominent by default, however some themes may show it.'); ?></td>
</tr>
</table>
-<p class="submit"><input type="submit" class="button" name="submit" value="<?php echo $submit_text ?>" /></p>
+<p class="submit"><input type="submit" class="button-primary" name="submit" value="<?php _e('Update Category'); ?>" /></p>
<?php do_action('edit_category_form', $category); ?>
</form>
</div>