| [ Root ] [ Search ] [ Index ] |
PHP Cross Reference of WordPress 3.0.1Provided by Yoast |
[Summary view] [Print] [Text view]
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’ uh?')); 19 20 if ( 'delete' == $doaction ) { 21 $cats = (array) $_GET['delete']; 22 $default_cat_id = get_option('default_link_category'); 23 24 foreach( $cats as $cat_ID ) { 25 $cat_ID = (int) $cat_ID; 26 // Don't delete the default cats. 27 if ( $cat_ID == $default_cat_id ) 28 wp_die( sprintf( __("Can’t delete the <strong>%s</strong> category: this is the default one"), get_term_field('name', $cat_ID, 'link_category') ) ); 29 30 wp_delete_term($cat_ID, 'link_category', array('default' => $default_cat_id)); 31 } 32 33 $location = 'edit-link-categories.php'; 34 if ( $referer = wp_get_referer() ) { 35 if ( false !== strpos($referer, 'edit-link-categories.php') ) 36 $location = $referer; 37 } 38 39 $location = add_query_arg('message', 6, $location); 40 wp_redirect($location); 41 exit(); 42 } 43 } elseif ( ! empty($_GET['_wp_http_referer']) ) { 44 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); 45 exit; 46 } 47 48 $title = __('Link Categories'); 49 50 wp_enqueue_script('admin-categories'); 51 if ( current_user_can('manage_categories') ) 52 wp_enqueue_script('inline-edit-tax'); 53 54 add_contextual_help($current_screen, '<p>' . __('You can create groups of links by using link categories. Link category names must be unique and link categories are separate from the categories you use for posts.') . '</p>' . 55 '<p>' . __('You can delete link categories, but that action does not delete the links within the category. Instead, it moves them to the default link category.') . '</p>' . 56 '<p><strong>' . __('For more information:') . '</strong></p>' . 57 '<p>' . __('<a href="http://codex.wordpress.org/Links_Link_Categories_SubPanel" target="_blank">Link Categories Documentation</a>') . '</p>' . 58 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' 59 ); 60 61 require_once ('admin-header.php'); 62 63 $messages[1] = __('Category added.'); 64 $messages[2] = __('Category deleted.'); 65 $messages[3] = __('Category updated.'); 66 $messages[4] = __('Category not added.'); 67 $messages[5] = __('Category not updated.'); 68 $messages[6] = __('Categories deleted.'); ?> 69 70 <div class="wrap nosubsub"> 71 <?php screen_icon(); ?> 72 <h2><?php echo esc_html( $title ); 73 if ( isset($_GET['s']) && $_GET['s'] ) 74 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( stripslashes($_GET['s']) ) ); ?> 75 </h2> 76 77 <?php if ( isset($_GET['message']) && ( $msg = (int) $_GET['message'] ) ) : ?> 78 <div id="message" class="updated"><p><?php echo $messages[$msg]; ?></p></div> 79 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']); 80 endif; ?> 81 82 <form class="search-form" action="" method="get"> 83 <p class="search-box"> 84 <label class="screen-reader-text" for="link-category-search-input"><?php _e( 'Search Categories' ); ?>:</label> 85 <input type="text" id="link-category-search-input" name="s" value="<?php _admin_search_query(); ?>" /> 86 <input type="submit" value="<?php esc_attr_e( 'Search Categories' ); ?>" class="button" /> 87 </p> 88 </form> 89 <br class="clear" /> 90 91 <div id="col-container"> 92 93 <div id="col-right"> 94 <div class="col-wrap"> 95 <form id="posts-filter" action="" method="get"> 96 <div class="tablenav"> 97 98 <?php 99 $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0; 100 if ( empty($pagenum) ) 101 $pagenum = 1; 102 if ( ! isset( $catsperpage ) || $catsperpage < 0 ) 103 $catsperpage = 20; 104 105 $page_links = paginate_links( array( 106 'base' => add_query_arg( 'pagenum', '%#%' ), 107 'format' => '', 108 'prev_text' => __('«'), 109 'next_text' => __('»'), 110 'total' => ceil(wp_count_terms('link_category') / $catsperpage), 111 'current' => $pagenum 112 )); 113 114 if ( $page_links ) 115 echo "<div class='tablenav-pages'>$page_links</div>"; 116 ?> 117 118 <div class="alignleft actions"> 119 <select name="action"> 120 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option> 121 <option value="delete"><?php _e('Delete'); ?></option> 122 </select> 123 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" /> 124 <?php wp_nonce_field('bulk-link-categories'); ?> 125 </div> 126 127 <br class="clear" /> 128 </div> 129 130 <div class="clear"></div> 131 132 <table class="widefat fixed" cellspacing="0"> 133 <thead> 134 <tr> 135 <?php print_column_headers('edit-link-categories'); ?> 136 </tr> 137 </thead> 138 139 <tfoot> 140 <tr> 141 <?php print_column_headers('edit-link-categories', false); ?> 142 </tr> 143 </tfoot> 144 145 <tbody id="the-list" class="list:link-cat"> 146 <?php 147 $start = ($pagenum - 1) * $catsperpage; 148 $args = array('offset' => $start, 'number' => $catsperpage, 'hide_empty' => 0); 149 if ( !empty( $_GET['s'] ) ) 150 $args['search'] = $_GET['s']; 151 152 $categories = get_terms( 'link_category', $args ); 153 if ( $categories ) { 154 $output = ''; 155 foreach ( $categories as $category ) { 156 $output .= link_cat_row($category); 157 } 158 echo $output; 159 unset($category); 160 } 161 162 ?> 163 </tbody> 164 </table> 165 166 <div class="tablenav"> 167 <?php 168 if ( $page_links ) 169 echo "<div class='tablenav-pages'>$page_links</div>"; 170 ?> 171 172 <div class="alignleft actions"> 173 <select name="action2"> 174 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option> 175 <option value="delete"><?php _e('Delete'); ?></option> 176 </select> 177 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 178 </div> 179 180 <br class="clear" /> 181 </div> 182 <br class="clear" /> 183 </form> 184 185 <div class="form-wrap"> 186 <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> 187 </div> 188 189 190 </div> 191 </div><!-- /col-right --> 192 193 <div id="col-left"> 194 <div class="col-wrap"> 195 196 <?php if ( current_user_can('manage_categories') ) { 197 $category = (object) array(); $category->parent = 0; do_action('add_link_category_form_pre', $category); ?> 198 199 <div class="form-wrap"> 200 <h3><?php _e('Add Link Category'); ?></h3> 201 <div id="ajax-response"></div> 202 <form name="addcat" id="addcat" class="add:the-list: validate" method="post" action="link-category.php"> 203 <input type="hidden" name="action" value="addcat" /> 204 <?php wp_original_referer_field(true, 'previous'); wp_nonce_field('add-link-category'); ?> 205 206 <div class="form-field form-required"> 207 <label for="name"><?php _e('Link Category name') ?></label> 208 <input name="name" id="link-name" type="text" value="" size="40" aria-required="true" /> 209 </div> 210 <?php if ( !global_terms_enabled() ) { ?> 211 <div class="form-field"> 212 <label for="slug"><?php _e('Link Category slug') ?></label> 213 <input name="slug" id="link-slug" type="text" value="" size="40" /> 214 <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> 215 </div> 216 <?php } ?> 217 <div class="form-field"> 218 <label for="description"><?php _e('Description (optional)') ?></label> 219 <textarea name="description" id="link-description" rows="5" cols="40"></textarea> 220 <p><?php _e('The description is not prominent by default; however, some themes may show it.'); ?></p> 221 </div> 222 223 <p class="submit"><input type="submit" class="button" name="submit" value="<?php esc_attr_e('Add Category'); ?>" /></p> 224 <?php do_action('edit_link_category_form', $category); ?> 225 </form> 226 </div> 227 228 <?php } ?> 229 230 </div> 231 </div><!-- /col-left --> 232 233 </div><!-- /col-container --> 234 </div><!-- /wrap --> 235 236 <?php inline_edit_term_row('edit-link-categories', 'link_category'); ?> 237 <?php include ('./admin-footer.php'); ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Oct 14 05:12:05 2010 | Cross-referenced by PHPXref 0.7 |