2 require_once('admin.php');
4 $title = __('Categories');
5 $parent_file = 'link-manager.php';
7 //wp_enqueue_script( 'admin-categories' ); TODO: Fix AJAX
8 require_once ('admin-header.php');
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.');
16 function link_cat_row($category) {
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' );
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>";
26 $edit .= "<td style='text-align:center'>".__( "Default" );
31 $class = ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || " class='alternate'" == $class ) ? '' : " class='alternate'";
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";
44 <?php if (isset($_GET['message'])) : ?>
45 <div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
49 <?php if ( current_user_can('manage_categories') ) : ?>
50 <h2><?php printf(__('Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2>
52 <h2><?php _e('Categories') ?> </h2>
54 <table class="widefat">
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>
66 $categories = get_terms( 'link_category', 'hide_empty=0' );
69 foreach ( $categories as $category ) {
70 $category = sanitize_term($category, 'link_category', 'display');
71 $output .= link_cat_row($category);
73 $output = apply_filters('cat_rows', $output);
84 <?php if ( current_user_can('manage_categories') ) : ?>
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>
89 <?php include('edit-link-category-form.php'); ?>
93 <?php include('admin-footer.php'); ?>