| 1 |
<?php |
|---|
| 2 |
require_once('admin.php'); |
|---|
| 3 |
|
|---|
| 4 |
$title = __('Categories'); |
|---|
| 5 |
$parent_file = 'link-manager.php'; |
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
require_once ('admin-header.php'); |
|---|
| 9 |
|
|---|
| 10 |
$messages[1] = __('Category added.'); |
|---|
| 11 |
$messages[2] = __('Category deleted.'); |
|---|
| 12 |
$messages[3] = __('Category updated.'); |
|---|
| 13 |
$messages[4] = __('Category not added.'); |
|---|
| 14 |
$messages[5] = __('Category not updated.'); |
|---|
| 15 |
|
|---|
| 16 |
function link_cat_row($category) { |
|---|
| 17 |
global $class; |
|---|
| 18 |
|
|---|
| 19 |
if ( current_user_can( 'manage_categories' ) ) { |
|---|
| 20 |
$edit = "<a href='link-category.php?action=edit&cat_ID=$category->term_id' class='edit'>".__( 'Edit' )."</a></td>"; |
|---|
| 21 |
$default_cat_id = (int) get_option( 'default_link_category' ); |
|---|
| 22 |
|
|---|
| 23 |
if ( $category->term_id != $default_cat_id ) |
|---|
| 24 |
$edit .= "<td><a href='" . wp_nonce_url( "link-category.php?action=delete&cat_ID=$category->term_id", 'delete-link-category_' . $category->term_id ) . "' onclick=\"return deleteSomething( 'cat', $category->term_id, '" . js_escape(sprintf( __("You are about to delete the category '%s'.\nAll links that were only assigned to this category will be assigned to the '%s' category.\n'OK' to delete, 'Cancel' to stop." ), $category->name, get_term_field( 'name', $default_cat_id, 'link_category' ))) . "' );\" class='delete'>".__( 'Delete' )."</a>"; |
|---|
| 25 |
else |
|---|
| 26 |
$edit .= "<td style='text-align:center'>".__( "Default" ); |
|---|
| 27 |
} else { |
|---|
| 28 |
$edit = ''; |
|---|
| 29 |
} |
|---|
| 30 |
|
|---|
| 31 |
$class = ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || " class='alternate'" == $class ) ? '' : " class='alternate'"; |
|---|
| 32 |
|
|---|
| 33 |
$category->count = number_format_i18n( $category->count ); |
|---|
| 34 |
$count = ( $category->count > 0 ) ? "<a href='link-manager.php?cat_id=$category->term_id'>$category->count</a>" : $category->count; |
|---|
| 35 |
return "<tr id='cat-$category->term_id'$class> |
|---|
| 36 |
<th scope='row' style='text-align: center'>$category->term_id</th> |
|---|
| 37 |
<td>" . ( $name_override ? $name_override : $pad . ' ' . $category->name ) . "</td> |
|---|
| 38 |
<td>$category->description</td> |
|---|
| 39 |
<td align='center'>$count</td> |
|---|
| 40 |
<td>$edit</td>\n\t</tr>\n"; |
|---|
| 41 |
} |
|---|
| 42 |
?> |
|---|
| 43 |
|
|---|
| 44 |
<?php if (isset($_GET['message'])) : ?> |
|---|
| 45 |
<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div> |
|---|
| 46 |
<?php endif; ?> |
|---|
| 47 |
|
|---|
| 48 |
<div class="wrap"> |
|---|
| 49 |
<?php if ( current_user_can('manage_categories') ) : ?> |
|---|
| 50 |
<h2><?php printf(__('Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2> |
|---|
| 51 |
<?php else : ?> |
|---|
| 52 |
<h2><?php _e('Categories') ?> </h2> |
|---|
| 53 |
<?php endif; ?> |
|---|
| 54 |
<table class="widefat"> |
|---|
| 55 |
<thead> |
|---|
| 56 |
<tr> |
|---|
| 57 |
<th scope="col" style="text-align: center"><?php _e('ID') ?></th> |
|---|
| 58 |
<th scope="col"><?php _e('Name') ?></th> |
|---|
| 59 |
<th scope="col"><?php _e('Description') ?></th> |
|---|
| 60 |
<th scope="col" width="90" style="text-align: center"><?php _e('Links') ?></th> |
|---|
| 61 |
<th colspan="2" style="text-align: center"><?php _e('Action') ?></th> |
|---|
| 62 |
</tr> |
|---|
| 63 |
</thead> |
|---|
| 64 |
<tbody id="the-list"> |
|---|
| 65 |
<?php |
|---|
| 66 |
$categories = get_terms( 'link_category', 'hide_empty=0' ); |
|---|
| 67 |
if ( $categories ) { |
|---|
| 68 |
$output = ''; |
|---|
| 69 |
foreach ( $categories as $category ) { |
|---|
| 70 |
$category = sanitize_term($category, 'link_category', 'display'); |
|---|
| 71 |
$output .= link_cat_row($category); |
|---|
| 72 |
} |
|---|
| 73 |
$output = apply_filters('cat_rows', $output); |
|---|
| 74 |
echo $output; |
|---|
| 75 |
unset($category); |
|---|
| 76 |
} |
|---|
| 77 |
|
|---|
| 78 |
?> |
|---|
| 79 |
</tbody> |
|---|
| 80 |
</table> |
|---|
| 81 |
|
|---|
| 82 |
</div> |
|---|
| 83 |
|
|---|
| 84 |
<?php if ( current_user_can('manage_categories') ) : ?> |
|---|
| 85 |
<div class="wrap"> |
|---|
| 86 |
<p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the links in that category. Instead, links that were only assigned to the deleted category are set to the category <strong>%s</strong>.'), get_term_field('name', get_option('default_link_category'), 'link_category')) ?></p> |
|---|
| 87 |
</div> |
|---|
| 88 |
|
|---|
| 89 |
<?php include('edit-link-category-form.php'); ?> |
|---|
| 90 |
|
|---|
| 91 |
<?php endif; ?> |
|---|
| 92 |
|
|---|
| 93 |
<?php include('admin-footer.php'); ?> |
|---|
| 94 |
|
|---|