raw
mp-wp_genesis           1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * Edit Link Categories Administration Panel.
mp-wp_genesis 4 *
mp-wp_genesis 5 * @package WordPress
mp-wp_genesis 6 * @subpackage Administration
mp-wp_genesis 7 */
mp-wp_genesis 8
mp-wp_genesis 9 /** WordPress Administration Bootstrap */
mp-wp_genesis 10 require_once('admin.php');
mp-wp_genesis 11
mp-wp_genesis 12 // Handle bulk actions
mp-wp_genesis 13 if ( isset($_GET['action']) && isset($_GET['delete']) ) {
mp-wp_genesis 14 check_admin_referer('bulk-link-categories');
mp-wp_genesis 15 $doaction = $_GET['action'] ? $_GET['action'] : $_GET['action2'];
mp-wp_genesis 16
mp-wp_genesis 17 if ( !current_user_can('manage_categories') )
mp-wp_genesis 18 wp_die(__('Cheatin&#8217; uh?'));
mp-wp_genesis 19
mp-wp_genesis 20 if ( 'delete' == $doaction ) {
mp-wp_genesis 21 foreach( (array) $_GET['delete'] as $cat_ID ) {
mp-wp_genesis 22 $cat_name = get_term_field('name', $cat_ID, 'link_category');
mp-wp_genesis 23 $default_cat_id = get_option('default_link_category');
mp-wp_genesis 24
mp-wp_genesis 25 // Don't delete the default cats.
mp-wp_genesis 26 if ( $cat_ID == $default_cat_id )
mp-wp_genesis 27 wp_die(sprintf(__("Can&#8217;t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
mp-wp_genesis 28
mp-wp_genesis 29 wp_delete_term($cat_ID, 'link_category', array('default' => $default_cat_id));
mp-wp_genesis 30 }
mp-wp_genesis 31
mp-wp_genesis 32 $location = 'edit-link-categories.php';
mp-wp_genesis 33 if ( $referer = wp_get_referer() ) {
mp-wp_genesis 34 if ( false !== strpos($referer, 'edit-link-categories.php') )
mp-wp_genesis 35 $location = $referer;
mp-wp_genesis 36 }
mp-wp_genesis 37
mp-wp_genesis 38 $location = add_query_arg('message', 6, $location);
mp-wp_genesis 39 wp_redirect($location);
mp-wp_genesis 40 exit();
mp-wp_genesis 41 }
mp-wp_genesis 42 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
mp-wp_genesis 43 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
mp-wp_genesis 44 exit;
mp-wp_genesis 45 }
mp-wp_genesis 46
mp-wp_genesis 47 $title = __('Link Categories');
mp-wp_genesis 48
mp-wp_genesis 49 wp_enqueue_script('admin-categories');
mp-wp_genesis 50 if ( current_user_can('manage_categories') )
mp-wp_genesis 51 wp_enqueue_script('inline-edit-tax');
mp-wp_genesis 52
mp-wp_genesis 53 require_once ('admin-header.php');
mp-wp_genesis 54
mp-wp_genesis 55 $messages[1] = __('Category added.');
mp-wp_genesis 56 $messages[2] = __('Category deleted.');
mp-wp_genesis 57 $messages[3] = __('Category updated.');
mp-wp_genesis 58 $messages[4] = __('Category not added.');
mp-wp_genesis 59 $messages[5] = __('Category not updated.');
mp-wp_genesis 60 $messages[6] = __('Categories deleted.'); ?>
mp-wp_genesis 61
mp-wp_genesis 62 <div class="wrap nosubsub">
mp-wp_genesis 63 <?php screen_icon(); ?>
mp-wp_genesis 64 <h2><?php echo wp_specialchars( $title );
mp-wp_genesis 65 if ( isset($_GET['s']) && $_GET['s'] )
mp-wp_genesis 66 printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', wp_specialchars( stripslashes($_GET['s']) ) ); ?>
mp-wp_genesis 67 </h2>
mp-wp_genesis 68
mp-wp_genesis 69 <?php if ( isset($_GET['message']) && ( $msg = (int) $_GET['message'] ) ) : ?>
mp-wp_genesis 70 <div id="message" class="updated fade"><p><?php echo $messages[$msg]; ?></p></div>
mp-wp_genesis 71 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
mp-wp_genesis 72 endif; ?>
mp-wp_genesis 73
mp-wp_genesis 74 <form class="search-form" action="" method="get">
mp-wp_genesis 75 <p class="search-box">
mp-wp_genesis 76 <label class="hidden" for="link-category-search-input"><?php _e( 'Search Categories' ); ?>:</label>
mp-wp_genesis 77 <input type="text" class="search-input" id="link-category-search-input" name="s" value="<?php _admin_search_query(); ?>" />
mp-wp_genesis 78 <input type="submit" value="<?php _e( 'Search Categories' ); ?>" class="button" />
mp-wp_genesis 79 </p>
mp-wp_genesis 80 </form>
mp-wp_genesis 81 <br class="clear" />
mp-wp_genesis 82
mp-wp_genesis 83 <div id="col-container">
mp-wp_genesis 84
mp-wp_genesis 85 <div id="col-right">
mp-wp_genesis 86 <div class="col-wrap">
mp-wp_genesis 87 <form id="posts-filter" action="" method="get">
mp-wp_genesis 88 <div class="tablenav">
mp-wp_genesis 89
mp-wp_genesis 90 <?php
mp-wp_genesis 91 $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
mp-wp_genesis 92 if ( empty($pagenum) )
mp-wp_genesis 93 $pagenum = 1;
mp-wp_genesis 94 if( ! isset( $catsperpage ) || $catsperpage < 0 )
mp-wp_genesis 95 $catsperpage = 20;
mp-wp_genesis 96
mp-wp_genesis 97 $page_links = paginate_links( array(
mp-wp_genesis 98 'base' => add_query_arg( 'pagenum', '%#%' ),
mp-wp_genesis 99 'format' => '',
mp-wp_genesis 100 'prev_text' => __('&laquo;'),
mp-wp_genesis 101 'next_text' => __('&raquo;'),
mp-wp_genesis 102 'total' => ceil(wp_count_terms('link_category') / $catsperpage),
mp-wp_genesis 103 'current' => $pagenum
mp-wp_genesis 104 ));
mp-wp_genesis 105
mp-wp_genesis 106 if ( $page_links )
mp-wp_genesis 107 echo "<div class='tablenav-pages'>$page_links</div>";
mp-wp_genesis 108 ?>
mp-wp_genesis 109
mp-wp_genesis 110 <div class="alignleft actions">
mp-wp_genesis 111 <select name="action">
mp-wp_genesis 112 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
mp-wp_genesis 113 <option value="delete"><?php _e('Delete'); ?></option>
mp-wp_genesis 114 </select>
mp-wp_genesis 115 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
mp-wp_genesis 116 <?php wp_nonce_field('bulk-link-categories'); ?>
mp-wp_genesis 117 </div>
mp-wp_genesis 118
mp-wp_genesis 119 <br class="clear" />
mp-wp_genesis 120 </div>
mp-wp_genesis 121
mp-wp_genesis 122 <div class="clear"></div>
mp-wp_genesis 123
mp-wp_genesis 124 <table class="widefat fixed" cellspacing="0">
mp-wp_genesis 125 <thead>
mp-wp_genesis 126 <tr>
mp-wp_genesis 127 <?php print_column_headers('edit-link-categories'); ?>
mp-wp_genesis 128 </tr>
mp-wp_genesis 129 </thead>
mp-wp_genesis 130
mp-wp_genesis 131 <tfoot>
mp-wp_genesis 132 <tr>
mp-wp_genesis 133 <?php print_column_headers('edit-link-categories', false); ?>
mp-wp_genesis 134 </tr>
mp-wp_genesis 135 </tfoot>
mp-wp_genesis 136
mp-wp_genesis 137 <tbody id="the-list" class="list:link-cat">
mp-wp_genesis 138 <?php
mp-wp_genesis 139 $start = ($pagenum - 1) * $catsperpage;
mp-wp_genesis 140 $args = array('offset' => $start, 'number' => $catsperpage, 'hide_empty' => 0);
mp-wp_genesis 141 if ( !empty( $_GET['s'] ) )
mp-wp_genesis 142 $args['search'] = $_GET['s'];
mp-wp_genesis 143
mp-wp_genesis 144 $categories = get_terms( 'link_category', $args );
mp-wp_genesis 145 if ( $categories ) {
mp-wp_genesis 146 $output = '';
mp-wp_genesis 147 foreach ( $categories as $category ) {
mp-wp_genesis 148 $output .= link_cat_row($category);
mp-wp_genesis 149 }
mp-wp_genesis 150 echo $output;
mp-wp_genesis 151 unset($category);
mp-wp_genesis 152 }
mp-wp_genesis 153
mp-wp_genesis 154 ?>
mp-wp_genesis 155 </tbody>
mp-wp_genesis 156 </table>
mp-wp_genesis 157
mp-wp_genesis 158 <div class="tablenav">
mp-wp_genesis 159 <?php
mp-wp_genesis 160 if ( $page_links )
mp-wp_genesis 161 echo "<div class='tablenav-pages'>$page_links</div>";
mp-wp_genesis 162 ?>
mp-wp_genesis 163
mp-wp_genesis 164 <div class="alignleft actions">
mp-wp_genesis 165 <select name="action2">
mp-wp_genesis 166 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
mp-wp_genesis 167 <option value="delete"><?php _e('Delete'); ?></option>
mp-wp_genesis 168 </select>
mp-wp_genesis 169 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
mp-wp_genesis 170 </div>
mp-wp_genesis 171
mp-wp_genesis 172 <br class="clear" />
mp-wp_genesis 173 </div>
mp-wp_genesis 174 <br class="clear" />
mp-wp_genesis 175 </form>
mp-wp_genesis 176
mp-wp_genesis 177 <div class="form-wrap">
mp-wp_genesis 178 <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>
mp-wp_genesis 179 </div>
mp-wp_genesis 180
mp-wp_genesis 181
mp-wp_genesis 182 </div>
mp-wp_genesis 183 </div><!-- /col-right -->
mp-wp_genesis 184
mp-wp_genesis 185 <div id="col-left">
mp-wp_genesis 186 <div class="col-wrap">
mp-wp_genesis 187
mp-wp_genesis 188 <?php if ( current_user_can('manage_categories') ) {
mp-wp_genesis 189 $category = (object) array(); $category->parent = 0; do_action('add_link_category_form_pre', $category); ?>
mp-wp_genesis 190
mp-wp_genesis 191 <div class="form-wrap">
mp-wp_genesis 192 <h3><?php _e('Add Category'); ?></h3>
mp-wp_genesis 193 <div id="ajax-response"></div>
mp-wp_genesis 194 <form name="addcat" id="addcat" class="add:the-list: validate" method="post" action="link-category.php">
mp-wp_genesis 195 <input type="hidden" name="action" value="addcat" />
mp-wp_genesis 196 <?php wp_original_referer_field(true, 'previous'); wp_nonce_field('add-link-category'); ?>
mp-wp_genesis 197
mp-wp_genesis 198 <div class="form-field form-required">
mp-wp_genesis 199 <label for="name"><?php _e('Category name') ?></label>
mp-wp_genesis 200 <input name="name" id="name" type="text" value="" size="40" aria-required="true" />
mp-wp_genesis 201 </div>
mp-wp_genesis 202
mp-wp_genesis 203 <div class="form-field">
mp-wp_genesis 204 <label for="slug"><?php _e('Category slug') ?></label>
mp-wp_genesis 205 <input name="slug" id="slug" type="text" value="" size="40" />
mp-wp_genesis 206 <p><?php _e('The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p>
mp-wp_genesis 207 </div>
mp-wp_genesis 208
mp-wp_genesis 209 <div class="form-field">
mp-wp_genesis 210 <label for="description"><?php _e('Description (optional)') ?></label>
mp-wp_genesis 211 <textarea name="description" id="description" rows="5" cols="40"></textarea>
mp-wp_genesis 212 </div>
mp-wp_genesis 213
mp-wp_genesis 214 <p class="submit"><input type="submit" class="button" name="submit" value="<?php _e('Add Category'); ?>" /></p>
mp-wp_genesis 215 <?php do_action('edit_link_category_form', $category); ?>
mp-wp_genesis 216 </form>
mp-wp_genesis 217 </div>
mp-wp_genesis 218
mp-wp_genesis 219 <?php } ?>
mp-wp_genesis 220
mp-wp_genesis 221 </div>
mp-wp_genesis 222 </div><!-- /col-left -->
mp-wp_genesis 223
mp-wp_genesis 224 </div><!-- /col-container -->
mp-wp_genesis 225 </div><!-- /wrap -->
mp-wp_genesis 226
mp-wp_genesis 227 <script type="text/javascript">
mp-wp_genesis 228 /* <![CDATA[ */
mp-wp_genesis 229 (function($){
mp-wp_genesis 230 $(document).ready(function(){
mp-wp_genesis 231 $('#doaction, #doaction2').click(function(){
mp-wp_genesis 232 if ( $('select[name^="action"]').val() == 'delete' ) {
mp-wp_genesis 233 var m = '<?php echo js_escape(__("You are about to delete the selected link categories.\n 'Cancel' to stop, 'OK' to delete.")); ?>';
mp-wp_genesis 234 return showNotice.warn(m);
mp-wp_genesis 235 }
mp-wp_genesis 236 });
mp-wp_genesis 237 });
mp-wp_genesis 238 })(jQuery);
mp-wp_genesis 239 /* ]]> */
mp-wp_genesis 240 </script>
mp-wp_genesis 241
mp-wp_genesis 242 <?php inline_edit_term_row('edit-link-categories'); ?>
mp-wp_genesis 243 <?php include('admin-footer.php'); ?>