| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
if ( ! isset( $category ) ) |
|---|
| 13 |
$category = (object) array(); |
|---|
| 14 |
|
|---|
| 15 |
if ( ! empty($cat_ID) ) { |
|---|
| 16 |
|
|---|
| 17 |
* @var string |
|---|
| 18 |
*/ |
|---|
| 19 |
$heading = ''; |
|---|
| 20 |
$submit_text = __('Edit Category'); |
|---|
| 21 |
$form = '<form name="editcat" id="editcat" method="post" action="categories.php" class="validate">'; |
|---|
| 22 |
$action = 'editedcat'; |
|---|
| 23 |
$nonce_action = 'update-category_' . $cat_ID; |
|---|
| 24 |
do_action('edit_category_form_pre', $category); |
|---|
| 25 |
} else { |
|---|
| 26 |
$heading = '<h2>' . __('Add Category') . '</h2>'; |
|---|
| 27 |
$submit_text = __('Add Category'); |
|---|
| 28 |
$form = '<form name="addcat" id="addcat" method="post" action="categories.php" class="add:the-list: validate">'; |
|---|
| 29 |
$action = 'addcat'; |
|---|
| 30 |
$nonce_action = 'add-category'; |
|---|
| 31 |
do_action('add_category_form_pre', $category); |
|---|
| 32 |
} |
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
function _fill_empty_category(&$category) { |
|---|
| 42 |
if ( ! isset( $category->name ) ) |
|---|
| 43 |
$category->name = ''; |
|---|
| 44 |
|
|---|
| 45 |
if ( ! isset( $category->slug ) ) |
|---|
| 46 |
$category->slug = ''; |
|---|
| 47 |
|
|---|
| 48 |
if ( ! isset( $category->parent ) ) |
|---|
| 49 |
$category->parent = ''; |
|---|
| 50 |
|
|---|
| 51 |
if ( ! isset( $category->description ) ) |
|---|
| 52 |
$category->description = ''; |
|---|
| 53 |
} |
|---|
| 54 |
|
|---|
| 55 |
_fill_empty_category($category); |
|---|
| 56 |
?> |
|---|
| 57 |
|
|---|
| 58 |
<div class="wrap"> |
|---|
| 59 |
<?php echo $heading ?> |
|---|
| 60 |
<div id="ajax-response"></div> |
|---|
| 61 |
<?php echo $form ?> |
|---|
| 62 |
<input type="hidden" name="action" value="<?php echo $action ?>" /> |
|---|
| 63 |
<input type="hidden" name="cat_ID" value="<?php echo $category->term_id ?>" /> |
|---|
| 64 |
<?php wp_nonce_field($nonce_action); ?> |
|---|
| 65 |
<table class="form-table"> |
|---|
| 66 |
<tr class="form-field form-required"> |
|---|
| 67 |
<th scope="row" valign="top"><label for="cat_name"><?php _e('Category Name') ?></label></th> |
|---|
| 68 |
<td><input name="cat_name" id="cat_name" type="text" value="<?php echo attribute_escape($category->name); ?>" size="40" aria-required="true" /><br /> |
|---|
| 69 |
<?php _e('The name is used to identify the category almost everywhere, for example under the post or in the category widget.'); ?></td> |
|---|
| 70 |
</tr> |
|---|
| 71 |
<tr class="form-field"> |
|---|
| 72 |
<th scope="row" valign="top"><label for="category_nicename"><?php _e('Category Slug') ?></label></th> |
|---|
| 73 |
<td><input name="category_nicename" id="category_nicename" type="text" value="<?php echo attribute_escape(apply_filters('editable_slug', $category->slug)); ?>" size="40" /><br /> |
|---|
| 74 |
<?php _e('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></td> |
|---|
| 75 |
</tr> |
|---|
| 76 |
<tr class="form-field"> |
|---|
| 77 |
<th scope="row" valign="top"><label for="category_parent"><?php _e('Category Parent') ?></label></th> |
|---|
| 78 |
<td> |
|---|
| 79 |
<?php wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'category_parent', 'orderby' => 'name', 'selected' => $category->parent, 'hierarchical' => true, 'show_option_none' => __('None'))); ?><br /> |
|---|
| 80 |
<?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.'); ?> |
|---|
| 81 |
</td> |
|---|
| 82 |
</tr> |
|---|
| 83 |
<tr class="form-field"> |
|---|
| 84 |
<th scope="row" valign="top"><label for="category_description"><?php _e('Description') ?></label></th> |
|---|
| 85 |
<td><textarea name="category_description" id="category_description" rows="5" cols="50" style="width: 97%;"><?php echo wp_specialchars($category->description); ?></textarea><br /> |
|---|
| 86 |
<?php _e('The description is not prominent by default, however some themes may show it.'); ?></td> |
|---|
| 87 |
</tr> |
|---|
| 88 |
</table> |
|---|
| 89 |
<p class="submit"><input type="submit" class="button" name="submit" value="<?php echo $submit_text ?>" /></p> |
|---|
| 90 |
<?php do_action('edit_category_form', $category); ?> |
|---|
| 91 |
</form> |
|---|
| 92 |
</div> |
|---|
| 93 |
|
|---|