source: trunk/www.guidonia.net/wp/wp-admin/edit-link-categories.php@ 44

Last change on this file since 44 was 44, checked in by luciano, 15 years ago
File size: 6.9 KB
RevLine 
[44]1<?php
2/**
3 * Edit Link Categories Administration Panel.
4 *
5 * @package WordPress
6 * @subpackage Administration
7 */
8
9/** WordPress Administration Bootstrap */
10require_once('admin.php');
11
12// Handle bulk actions
13if ( 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 = 'edit-link-categories.php';
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
49wp_enqueue_script('admin-categories');
50if ( current_user_can('manage_categories') )
51 wp_enqueue_script('inline-edit-tax');
52
53require_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 esc_html( $title );
65if ( isset($_GET['s']) && $_GET['s'] )
66 printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( 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']);
72endif; ?>
73
74<form class="search-form" action="" method="get">
75<p class="search-box">
76 <label class="screen-reader-text" for="link-category-search-input"><?php _e( 'Search Categories' ); ?>:</label>
77 <input type="text" id="link-category-search-input" name="s" value="<?php _admin_search_query(); ?>" />
78 <input type="submit" value="<?php esc_attr_e( 'Search Categories' ); ?>" class="button" />
79</p>
80</form>
81<br class="clear" />
82
83<div id="col-container">
84
85<div id="col-right">
86<div class="col-wrap">
87<form id="posts-filter" action="" method="get">
88<div class="tablenav">
89
90<?php
91$pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
92if ( empty($pagenum) )
93 $pagenum = 1;
94if( ! isset( $catsperpage ) || $catsperpage < 0 )
95 $catsperpage = 20;
96
97$page_links = paginate_links( array(
98 'base' => add_query_arg( 'pagenum', '%#%' ),
99 'format' => '',
100 'prev_text' => __('&laquo;'),
101 'next_text' => __('&raquo;'),
102 'total' => ceil(wp_count_terms('link_category') / $catsperpage),
103 'current' => $pagenum
104));
105
106if ( $page_links )
107 echo "<div class='tablenav-pages'>$page_links</div>";
108?>
109
110<div class="alignleft actions">
111<select name="action">
112<option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
113<option value="delete"><?php _e('Delete'); ?></option>
114</select>
115<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
116<?php wp_nonce_field('bulk-link-categories'); ?>
117</div>
118
119<br class="clear" />
120</div>
121
122<div class="clear"></div>
123
124<table class="widefat fixed" cellspacing="0">
125 <thead>
126 <tr>
127<?php print_column_headers('edit-link-categories'); ?>
128 </tr>
129 </thead>
130
131 <tfoot>
132 <tr>
133<?php print_column_headers('edit-link-categories', false); ?>
134 </tr>
135 </tfoot>
136
137 <tbody id="the-list" class="list:link-cat">
138<?php
139$start = ($pagenum - 1) * $catsperpage;
140$args = array('offset' => $start, 'number' => $catsperpage, 'hide_empty' => 0);
141if ( !empty( $_GET['s'] ) )
142 $args['search'] = $_GET['s'];
143
144$categories = get_terms( 'link_category', $args );
145if ( $categories ) {
146 $output = '';
147 foreach ( $categories as $category ) {
148 $output .= link_cat_row($category);
149 }
150 echo $output;
151 unset($category);
152}
153
154?>
155 </tbody>
156</table>
157
158<div class="tablenav">
159<?php
160if ( $page_links )
161 echo "<div class='tablenav-pages'>$page_links</div>";
162?>
163
164<div class="alignleft actions">
165<select name="action2">
166<option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
167<option value="delete"><?php _e('Delete'); ?></option>
168</select>
169<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
170</div>
171
172<br class="clear" />
173</div>
174<br class="clear" />
175</form>
176
177<div class="form-wrap">
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>
179</div>
180
181
182</div>
183</div><!-- /col-right -->
184
185<div id="col-left">
186<div class="col-wrap">
187
188<?php if ( current_user_can('manage_categories') ) {
189 $category = (object) array(); $category->parent = 0; do_action('add_link_category_form_pre', $category); ?>
190
191<div class="form-wrap">
192<h3><?php _e('Add Link Category'); ?></h3>
193<div id="ajax-response"></div>
194<form name="addcat" id="addcat" class="add:the-list: validate" method="post" action="link-category.php">
195<input type="hidden" name="action" value="addcat" />
196<?php wp_original_referer_field(true, 'previous'); wp_nonce_field('add-link-category'); ?>
197
198<div class="form-field form-required">
199 <label for="name"><?php _e('Link Category name') ?></label>
200 <input name="name" id="name" type="text" value="" size="40" aria-required="true" />
201</div>
202
203<div class="form-field">
204 <label for="slug"><?php _e('Link Category slug') ?></label>
205 <input name="slug" id="slug" type="text" value="" size="40" />
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>
207</div>
208
209<div class="form-field">
210 <label for="description"><?php _e('Description (optional)') ?></label>
211 <textarea name="description" id="description" rows="5" cols="40"></textarea>
212</div>
213
214<p class="submit"><input type="submit" class="button" name="submit" value="<?php esc_attr_e('Add Category'); ?>" /></p>
215<?php do_action('edit_link_category_form', $category); ?>
216</form>
217</div>
218
219<?php } ?>
220
221</div>
222</div><!-- /col-left -->
223
224</div><!-- /col-container -->
225</div><!-- /wrap -->
226
227<?php inline_edit_term_row('edit-link-categories'); ?>
228<?php include('admin-footer.php'); ?>
Note: See TracBrowser for help on using the repository browser.