[ Index ]

PHP Cross Reference of zeList

title

Body

[close]

/admin/ -> link-categories.php (source)

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


Generated: Sat May 30 23:51:06 2009 Cross-referenced by PHPXref 0.7