-
+ EEB0F56F6AEB162762816414E04EBDDAD0A32DD8EBA218E894EB229E69312EA1E2318782A44DCBD359676D58F2B3A189D6E23BDDF52779A97505395FAA91F6DD
mp-wp/wp-admin/edit-link-categories.php
(0 . 0)(1 . 243)
11052 <?php
11053 /**
11054 * Edit Link Categories Administration Panel.
11055 *
11056 * @package WordPress
11057 * @subpackage Administration
11058 */
11059
11060 /** WordPress Administration Bootstrap */
11061 require_once('admin.php');
11062
11063 // Handle bulk actions
11064 if ( isset($_GET['action']) && isset($_GET['delete']) ) {
11065 check_admin_referer('bulk-link-categories');
11066 $doaction = $_GET['action'] ? $_GET['action'] : $_GET['action2'];
11067
11068 if ( !current_user_can('manage_categories') )
11069 wp_die(__('Cheatin’ uh?'));
11070
11071 if ( 'delete' == $doaction ) {
11072 foreach( (array) $_GET['delete'] as $cat_ID ) {
11073 $cat_name = get_term_field('name', $cat_ID, 'link_category');
11074 $default_cat_id = get_option('default_link_category');
11075
11076 // Don't delete the default cats.
11077 if ( $cat_ID == $default_cat_id )
11078 wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
11079
11080 wp_delete_term($cat_ID, 'link_category', array('default' => $default_cat_id));
11081 }
11082
11083 $location = 'edit-link-categories.php';
11084 if ( $referer = wp_get_referer() ) {
11085 if ( false !== strpos($referer, 'edit-link-categories.php') )
11086 $location = $referer;
11087 }
11088
11089 $location = add_query_arg('message', 6, $location);
11090 wp_redirect($location);
11091 exit();
11092 }
11093 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
11094 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
11095 exit;
11096 }
11097
11098 $title = __('Link Categories');
11099
11100 wp_enqueue_script('admin-categories');
11101 if ( current_user_can('manage_categories') )
11102 wp_enqueue_script('inline-edit-tax');
11103
11104 require_once ('admin-header.php');
11105
11106 $messages[1] = __('Category added.');
11107 $messages[2] = __('Category deleted.');
11108 $messages[3] = __('Category updated.');
11109 $messages[4] = __('Category not added.');
11110 $messages[5] = __('Category not updated.');
11111 $messages[6] = __('Categories deleted.'); ?>
11112
11113 <div class="wrap nosubsub">
11114 <?php screen_icon(); ?>
11115 <h2><?php echo wp_specialchars( $title );
11116 if ( isset($_GET['s']) && $_GET['s'] )
11117 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', wp_specialchars( stripslashes($_GET['s']) ) ); ?>
11118 </h2>
11119
11120 <?php if ( isset($_GET['message']) && ( $msg = (int) $_GET['message'] ) ) : ?>
11121 <div id="message" class="updated fade"><p><?php echo $messages[$msg]; ?></p></div>
11122 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
11123 endif; ?>
11124
11125 <form class="search-form" action="" method="get">
11126 <p class="search-box">
11127 <label class="hidden" for="link-category-search-input"><?php _e( 'Search Categories' ); ?>:</label>
11128 <input type="text" class="search-input" id="link-category-search-input" name="s" value="<?php _admin_search_query(); ?>" />
11129 <input type="submit" value="<?php _e( 'Search Categories' ); ?>" class="button" />
11130 </p>
11131 </form>
11132 <br class="clear" />
11133
11134 <div id="col-container">
11135
11136 <div id="col-right">
11137 <div class="col-wrap">
11138 <form id="posts-filter" action="" method="get">
11139 <div class="tablenav">
11140
11141 <?php
11142 $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
11143 if ( empty($pagenum) )
11144 $pagenum = 1;
11145 if( ! isset( $catsperpage ) || $catsperpage < 0 )
11146 $catsperpage = 20;
11147
11148 $page_links = paginate_links( array(
11149 'base' => add_query_arg( 'pagenum', '%#%' ),
11150 'format' => '',
11151 'prev_text' => __('«'),
11152 'next_text' => __('»'),
11153 'total' => ceil(wp_count_terms('link_category') / $catsperpage),
11154 'current' => $pagenum
11155 ));
11156
11157 if ( $page_links )
11158 echo "<div class='tablenav-pages'>$page_links</div>";
11159 ?>
11160
11161 <div class="alignleft actions">
11162 <select name="action">
11163 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
11164 <option value="delete"><?php _e('Delete'); ?></option>
11165 </select>
11166 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
11167 <?php wp_nonce_field('bulk-link-categories'); ?>
11168 </div>
11169
11170 <br class="clear" />
11171 </div>
11172
11173 <div class="clear"></div>
11174
11175 <table class="widefat fixed" cellspacing="0">
11176 <thead>
11177 <tr>
11178 <?php print_column_headers('edit-link-categories'); ?>
11179 </tr>
11180 </thead>
11181
11182 <tfoot>
11183 <tr>
11184 <?php print_column_headers('edit-link-categories', false); ?>
11185 </tr>
11186 </tfoot>
11187
11188 <tbody id="the-list" class="list:link-cat">
11189 <?php
11190 $start = ($pagenum - 1) * $catsperpage;
11191 $args = array('offset' => $start, 'number' => $catsperpage, 'hide_empty' => 0);
11192 if ( !empty( $_GET['s'] ) )
11193 $args['search'] = $_GET['s'];
11194
11195 $categories = get_terms( 'link_category', $args );
11196 if ( $categories ) {
11197 $output = '';
11198 foreach ( $categories as $category ) {
11199 $output .= link_cat_row($category);
11200 }
11201 echo $output;
11202 unset($category);
11203 }
11204
11205 ?>
11206 </tbody>
11207 </table>
11208
11209 <div class="tablenav">
11210 <?php
11211 if ( $page_links )
11212 echo "<div class='tablenav-pages'>$page_links</div>";
11213 ?>
11214
11215 <div class="alignleft actions">
11216 <select name="action2">
11217 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
11218 <option value="delete"><?php _e('Delete'); ?></option>
11219 </select>
11220 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
11221 </div>
11222
11223 <br class="clear" />
11224 </div>
11225 <br class="clear" />
11226 </form>
11227
11228 <div class="form-wrap">
11229 <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>
11230 </div>
11231
11232
11233 </div>
11234 </div><!-- /col-right -->
11235
11236 <div id="col-left">
11237 <div class="col-wrap">
11238
11239 <?php if ( current_user_can('manage_categories') ) {
11240 $category = (object) array(); $category->parent = 0; do_action('add_link_category_form_pre', $category); ?>
11241
11242 <div class="form-wrap">
11243 <h3><?php _e('Add Category'); ?></h3>
11244 <div id="ajax-response"></div>
11245 <form name="addcat" id="addcat" class="add:the-list: validate" method="post" action="link-category.php">
11246 <input type="hidden" name="action" value="addcat" />
11247 <?php wp_original_referer_field(true, 'previous'); wp_nonce_field('add-link-category'); ?>
11248
11249 <div class="form-field form-required">
11250 <label for="name"><?php _e('Category name') ?></label>
11251 <input name="name" id="name" type="text" value="" size="40" aria-required="true" />
11252 </div>
11253
11254 <div class="form-field">
11255 <label for="slug"><?php _e('Category slug') ?></label>
11256 <input name="slug" id="slug" type="text" value="" size="40" />
11257 <p><?php _e('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p>
11258 </div>
11259
11260 <div class="form-field">
11261 <label for="description"><?php _e('Description (optional)') ?></label>
11262 <textarea name="description" id="description" rows="5" cols="40"></textarea>
11263 </div>
11264
11265 <p class="submit"><input type="submit" class="button" name="submit" value="<?php _e('Add Category'); ?>" /></p>
11266 <?php do_action('edit_link_category_form', $category); ?>
11267 </form>
11268 </div>
11269
11270 <?php } ?>
11271
11272 </div>
11273 </div><!-- /col-left -->
11274
11275 </div><!-- /col-container -->
11276 </div><!-- /wrap -->
11277
11278 <script type="text/javascript">
11279 /* <![CDATA[ */
11280 (function($){
11281 $(document).ready(function(){
11282 $('#doaction, #doaction2').click(function(){
11283 if ( $('select[name^="action"]').val() == 'delete' ) {
11284 var m = '<?php echo js_escape(__("You are about to delete the selected link categories.\n 'Cancel' to stop, 'OK' to delete.")); ?>';
11285 return showNotice.warn(m);
11286 }
11287 });
11288 });
11289 })(jQuery);
11290 /* ]]> */
11291 </script>
11292
11293 <?php inline_edit_term_row('edit-link-categories'); ?>
11294 <?php include('admin-footer.php'); ?>