19 } else { |
19 } else { |
20 unset( $_redirect ); |
20 unset( $_redirect ); |
21 } |
21 } |
22 |
22 |
23 // Handle bulk actions |
23 // Handle bulk actions |
24 if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) { |
24 if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) || isset($_GET['bulk_edit']) ) { |
25 $doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2']; |
25 check_admin_referer('bulk-posts'); |
|
26 $sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() ); |
|
27 |
|
28 if ( strpos($sendback, 'post.php') !== false ) |
|
29 $sendback = admin_url('post-new.php'); |
|
30 |
|
31 if ( isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) { |
|
32 $post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_GET['post_status']); |
|
33 $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='post' AND post_status = %s", $post_status ) ); |
|
34 $doaction = 'delete'; |
|
35 } elseif ( ( $_GET['action'] != -1 || $_GET['action2'] != -1 ) && ( isset($_GET['post']) || isset($_GET['ids']) ) ) { |
|
36 $post_ids = isset($_GET['post']) ? array_map( 'intval', (array) $_GET['post'] ) : explode(',', $_GET['ids']); |
|
37 $doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2']; |
|
38 } else { |
|
39 wp_redirect( admin_url('edit.php') ); |
|
40 } |
26 |
41 |
27 switch ( $doaction ) { |
42 switch ( $doaction ) { |
|
43 case 'trash': |
|
44 $trashed = 0; |
|
45 foreach( (array) $post_ids as $post_id ) { |
|
46 if ( !current_user_can('delete_post', $post_id) ) |
|
47 wp_die( __('You are not allowed to move this post to the trash.') ); |
|
48 |
|
49 if ( !wp_trash_post($post_id) ) |
|
50 wp_die( __('Error in moving to trash...') ); |
|
51 |
|
52 $trashed++; |
|
53 } |
|
54 $sendback = add_query_arg( array('trashed' => $trashed, 'ids' => join(',', $post_ids)), $sendback ); |
|
55 break; |
|
56 case 'untrash': |
|
57 $untrashed = 0; |
|
58 foreach( (array) $post_ids as $post_id ) { |
|
59 if ( !current_user_can('delete_post', $post_id) ) |
|
60 wp_die( __('You are not allowed to restore this post from the trash.') ); |
|
61 |
|
62 if ( !wp_untrash_post($post_id) ) |
|
63 wp_die( __('Error in restoring from trash...') ); |
|
64 |
|
65 $untrashed++; |
|
66 } |
|
67 $sendback = add_query_arg('untrashed', $untrashed, $sendback); |
|
68 break; |
28 case 'delete': |
69 case 'delete': |
29 if ( isset($_GET['post']) && ! isset($_GET['bulk_edit']) && (isset($_GET['doaction']) || isset($_GET['doaction2'])) ) { |
70 $deleted = 0; |
30 check_admin_referer('bulk-posts'); |
71 foreach( (array) $post_ids as $post_id ) { |
31 $deleted = 0; |
72 $post_del = & get_post($post_id); |
32 foreach( (array) $_GET['post'] as $post_id_del ) { |
73 |
33 $post_del = & get_post($post_id_del); |
74 if ( !current_user_can('delete_post', $post_id) ) |
34 |
75 wp_die( __('You are not allowed to delete this post.') ); |
35 if ( !current_user_can('delete_post', $post_id_del) ) |
76 |
36 wp_die( __('You are not allowed to delete this post.') ); |
77 if ( $post_del->post_type == 'attachment' ) { |
37 |
78 if ( ! wp_delete_attachment($post_id) ) |
38 if ( $post_del->post_type == 'attachment' ) { |
79 wp_die( __('Error in deleting...') ); |
39 if ( ! wp_delete_attachment($post_id_del) ) |
80 } else { |
40 wp_die( __('Error in deleting...') ); |
81 if ( !wp_delete_post($post_id) ) |
41 } else { |
82 wp_die( __('Error in deleting...') ); |
42 if ( !wp_delete_post($post_id_del) ) |
|
43 wp_die( __('Error in deleting...') ); |
|
44 } |
|
45 $deleted++; |
|
46 } |
83 } |
|
84 $deleted++; |
47 } |
85 } |
|
86 $sendback = add_query_arg('deleted', $deleted, $sendback); |
48 break; |
87 break; |
49 case 'edit': |
88 case 'edit': |
50 if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) { |
89 $done = bulk_edit_posts($_GET); |
51 check_admin_referer('bulk-posts'); |
90 |
52 |
91 if ( is_array($done) ) { |
53 if ( -1 == $_GET['_status'] ) { |
92 $done['updated'] = count( $done['updated'] ); |
54 $_GET['post_status'] = null; |
93 $done['skipped'] = count( $done['skipped'] ); |
55 unset($_GET['_status'], $_GET['post_status']); |
94 $done['locked'] = count( $done['locked'] ); |
56 } else { |
95 $sendback = add_query_arg( $done, $sendback ); |
57 $_GET['post_status'] = $_GET['_status']; |
|
58 } |
|
59 |
|
60 $done = bulk_edit_posts($_GET); |
|
61 } |
96 } |
62 break; |
97 break; |
63 } |
98 } |
64 |
99 |
65 $sendback = wp_get_referer(); |
100 if ( isset($_GET['action']) ) |
66 if ( strpos($sendback, 'post.php') !== false ) $sendback = admin_url('post-new.php'); |
101 $sendback = remove_query_arg( array('action', 'action2', 'cat', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view', 'post_type'), $sendback ); |
67 elseif ( strpos($sendback, 'attachments.php') !== false ) $sendback = admin_url('attachments.php'); |
102 |
68 if ( isset($done) ) { |
|
69 $done['updated'] = count( $done['updated'] ); |
|
70 $done['skipped'] = count( $done['skipped'] ); |
|
71 $done['locked'] = count( $done['locked'] ); |
|
72 $sendback = add_query_arg( $done, $sendback ); |
|
73 } |
|
74 if ( isset($deleted) ) |
|
75 $sendback = add_query_arg('deleted', $deleted, $sendback); |
|
76 wp_redirect($sendback); |
103 wp_redirect($sendback); |
77 exit(); |
104 exit(); |
78 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { |
105 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { |
79 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); |
106 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); |
80 exit; |
107 exit; |
97 else |
132 else |
98 $mode = esc_attr($_GET['mode']); ?> |
133 $mode = esc_attr($_GET['mode']); ?> |
99 |
134 |
100 <div class="wrap"> |
135 <div class="wrap"> |
101 <?php screen_icon(); ?> |
136 <?php screen_icon(); ?> |
102 <h2><?php echo esc_html( $title ); |
137 <h2><?php echo esc_html( $title ); ?> <a href="post-new.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'post'); ?></a> <?php |
103 if ( isset($_GET['s']) && $_GET['s'] ) |
138 if ( isset($_GET['s']) && $_GET['s'] ) |
104 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( get_search_query() ) ); ?> |
139 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( get_search_query() ) ); ?> |
105 </h2> |
140 </h2> |
106 |
141 |
107 <?php |
142 <?php |
108 if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?> |
143 if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?> |
109 <div id="message" class="updated fade"><p><strong><?php _e('Your post has been saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View post'); ?></a> | <a href="<?php echo get_edit_post_link( $_GET['posted'] ); ?>"><?php _e('Edit post'); ?></a></p></div> |
144 <div id="message" class="updated fade"><p><strong><?php _e('Your post has been saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View post'); ?></a> | <a href="<?php echo get_edit_post_link( $_GET['posted'] ); ?>"><?php _e('Edit post'); ?></a></p></div> |
110 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']); |
145 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']); |
111 endif; ?> |
146 endif; ?> |
112 |
147 |
113 <?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) ) { ?> |
148 <?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) ) { ?> |
114 <div id="message" class="updated fade"><p> |
149 <div id="message" class="updated fade"><p> |
115 <?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) { |
150 <?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) { |
116 printf( _n( '%s post updated.', '%s posts updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) ); |
151 printf( _n( '%s post updated.', '%s posts updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) ); |
117 unset($_GET['updated']); |
152 unset($_GET['updated']); |
118 } |
153 } |
124 printf( _n( '%s post not updated, somebody is editing it.', '%s posts not updated, somebody is editing them.', $_GET['locked'] ), number_format_i18n( $_GET['locked'] ) ); |
159 printf( _n( '%s post not updated, somebody is editing it.', '%s posts not updated, somebody is editing them.', $_GET['locked'] ), number_format_i18n( $_GET['locked'] ) ); |
125 unset($_GET['locked']); |
160 unset($_GET['locked']); |
126 } |
161 } |
127 |
162 |
128 if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) { |
163 if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) { |
129 printf( _n( 'Post deleted.', '%s posts deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) ); |
164 printf( _n( 'Post permanently deleted.', '%s posts permanently deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) ); |
130 unset($_GET['deleted']); |
165 unset($_GET['deleted']); |
131 } |
166 } |
132 |
167 |
133 $_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted'), $_SERVER['REQUEST_URI'] ); |
168 if ( isset($_GET['trashed']) && (int) $_GET['trashed'] ) { |
|
169 printf( _n( 'Post moved to the trash.', '%s posts moved to the trash.', $_GET['trashed'] ), number_format_i18n( $_GET['trashed'] ) ); |
|
170 $ids = isset($_GET['ids']) ? $_GET['ids'] : 0; |
|
171 echo ' <a href="' . esc_url( wp_nonce_url( "edit.php?doaction=undo&action=untrash&ids=$ids", "bulk-posts" ) ) . '">' . __('Undo') . '</a><br />'; |
|
172 unset($_GET['trashed']); |
|
173 } |
|
174 |
|
175 if ( isset($_GET['untrashed']) && (int) $_GET['untrashed'] ) { |
|
176 printf( _n( 'Post restored from the trash.', '%s posts restored from the trash.', $_GET['untrashed'] ), number_format_i18n( $_GET['untrashed'] ) ); |
|
177 unset($_GET['undeleted']); |
|
178 } |
|
179 |
|
180 $_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed'), $_SERVER['REQUEST_URI'] ); |
134 ?> |
181 ?> |
135 </p></div> |
182 </p></div> |
136 <?php } ?> |
183 <?php } ?> |
137 |
184 |
138 <form id="posts-filter" action="" method="get"> |
185 <form id="posts-filter" action="<?php echo admin_url('edit.php'); ?>" method="get"> |
139 |
186 |
140 <ul class="subsubsub"> |
187 <ul class="subsubsub"> |
141 <?php |
188 <?php |
142 if ( empty($locked_post_status) ) : |
189 if ( empty($locked_post_status) ) : |
143 $status_links = array(); |
190 $status_links = array(); |
144 $num_posts = wp_count_posts( 'post', 'readable' ); |
191 $num_posts = wp_count_posts( 'post', 'readable' ); |
145 $total_posts = array_sum( (array) $num_posts ); |
192 $class = ''; |
146 $class = empty( $_GET['post_status'] ) ? ' class="current"' : ''; |
193 $allposts = ''; |
147 $status_links[] = "<li><a href='edit.php' $class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'posts' ), number_format_i18n( $total_posts ) ) . '</a>'; |
194 |
148 |
195 if ( $user_posts ) { |
|
196 if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user->ID ) ) |
|
197 $class = ' class="current"'; |
|
198 $status_links[] = "<li><a href='edit.php?author=$current_user->ID'$class>" . sprintf( _nx( 'My Posts <span class="count">(%s)</span>', 'My Posts <span class="count">(%s)</span>', $user_posts_count, 'posts' ), number_format_i18n( $user_posts_count ) ) . '</a>'; |
|
199 $allposts = '?all_posts=1'; |
|
200 } |
|
201 |
|
202 $total_posts = array_sum( (array) $num_posts ) - $num_posts->trash; |
|
203 $class = empty($class) && empty($_GET['post_status']) ? ' class="current"' : ''; |
|
204 $status_links[] = "<li><a href='edit.php{$allposts}'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'posts' ), number_format_i18n( $total_posts ) ) . '</a>'; |
149 |
205 |
150 foreach ( $post_stati as $status => $label ) { |
206 foreach ( $post_stati as $status => $label ) { |
151 $class = ''; |
207 $class = ''; |
152 |
208 |
153 if ( !in_array( $status, $avail_post_stati ) ) |
209 if ( !in_array( $status, $avail_post_stati ) ) |
154 continue; |
210 continue; |
155 |
211 |
156 if ( empty( $num_posts->$status ) ) |
212 if ( empty( $num_posts->$status ) ) |
157 continue; |
213 continue; |
|
214 |
158 if ( isset($_GET['post_status']) && $status == $_GET['post_status'] ) |
215 if ( isset($_GET['post_status']) && $status == $_GET['post_status'] ) |
159 $class = ' class="current"'; |
216 $class = ' class="current"'; |
160 |
217 |
161 $status_links[] = "<li><a href='edit.php?post_status=$status' $class>" . sprintf( _n( $label[2][0], $label[2][1], $num_posts->$status ), number_format_i18n( $num_posts->$status ) ) . '</a>'; |
218 $status_links[] = "<li><a href='edit.php?post_status=$status'$class>" . sprintf( _n( $label[2][0], $label[2][1], $num_posts->$status ), number_format_i18n( $num_posts->$status ) ) . '</a>'; |
162 } |
219 } |
163 echo implode( " |</li>\n", $status_links ) . '</li>'; |
220 echo implode( " |</li>\n", $status_links ) . '</li>'; |
164 unset( $status_links ); |
221 unset( $status_links ); |
165 endif; |
222 endif; |
166 ?> |
223 ?> |
188 'next_text' => __('»'), |
243 'next_text' => __('»'), |
189 'total' => $wp_query->max_num_pages, |
244 'total' => $wp_query->max_num_pages, |
190 'current' => $_GET['paged'] |
245 'current' => $_GET['paged'] |
191 )); |
246 )); |
192 |
247 |
|
248 $is_trash = isset($_GET['post_status']) && $_GET['post_status'] == 'trash'; |
|
249 |
193 ?> |
250 ?> |
194 |
251 |
195 <div class="alignleft actions"> |
252 <div class="alignleft actions"> |
196 <select name="action"> |
253 <select name="action"> |
197 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> |
254 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> |
|
255 <?php if ( $is_trash ) { ?> |
|
256 <option value="untrash"><?php _e('Restore'); ?></option> |
|
257 <?php } else { ?> |
198 <option value="edit"><?php _e('Edit'); ?></option> |
258 <option value="edit"><?php _e('Edit'); ?></option> |
199 <option value="delete"><?php _e('Delete'); ?></option> |
259 <?php } if ( $is_trash || !EMPTY_TRASH_DAYS ) { ?> |
|
260 <option value="delete"><?php _e('Delete Permanently'); ?></option> |
|
261 <?php } else { ?> |
|
262 <option value="trash"><?php _e('Move to Trash'); ?></option> |
|
263 <?php } ?> |
200 </select> |
264 </select> |
201 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" /> |
265 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" /> |
202 <?php wp_nonce_field('bulk-posts'); ?> |
266 <?php wp_nonce_field('bulk-posts'); ?> |
203 |
267 |
204 <?php // view filters |
268 <?php // view filters |
273 ?> |
340 ?> |
274 |
341 |
275 <div class="alignleft actions"> |
342 <div class="alignleft actions"> |
276 <select name="action2"> |
343 <select name="action2"> |
277 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> |
344 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> |
|
345 <?php if ( $is_trash ) { ?> |
|
346 <option value="untrash"><?php _e('Restore'); ?></option> |
|
347 <?php } else { ?> |
278 <option value="edit"><?php _e('Edit'); ?></option> |
348 <option value="edit"><?php _e('Edit'); ?></option> |
279 <option value="delete"><?php _e('Delete'); ?></option> |
349 <?php } if ( $is_trash || !EMPTY_TRASH_DAYS ) { ?> |
|
350 <option value="delete"><?php _e('Delete Permanently'); ?></option> |
|
351 <?php } else { ?> |
|
352 <option value="trash"><?php _e('Move to Trash'); ?></option> |
|
353 <?php } ?> |
280 </select> |
354 </select> |
281 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> |
355 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> |
|
356 <?php if ( $is_trash && current_user_can('edit_others_posts') ) { ?> |
|
357 <input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> |
|
358 <?php } ?> |
282 <br class="clear" /> |
359 <br class="clear" /> |
283 </div> |
360 </div> |
284 <br class="clear" /> |
361 <br class="clear" /> |
285 </div> |
362 </div> |
286 |
363 |
287 <?php } else { // have_posts() ?> |
364 <?php } else { // have_posts() ?> |
288 <div class="clear"></div> |
365 <div class="clear"></div> |
289 <p><?php _e('No posts found') ?></p> |
366 <p><?php |
|
367 if ( isset($_GET['post_status']) && 'trash' == $_GET['post_status'] ) |
|
368 _e('No posts found in the trash'); |
|
369 else |
|
370 _e('No posts found'); |
|
371 ?></p> |
290 <?php } ?> |
372 <?php } ?> |
291 |
373 |
292 </form> |
374 </form> |
293 |
375 |
294 <?php inline_edit_row( 'post' ); ?> |
376 <?php inline_edit_row( 'post' ); ?> |
295 |
377 |
296 <div id="ajax-response"></div> |
378 <div id="ajax-response"></div> |
297 |
|
298 <br class="clear" /> |
379 <br class="clear" /> |
299 |
|
300 </div> |
380 </div> |
301 |
381 |
302 <?php |
382 <?php |
303 include('admin-footer.php'); |
383 include('admin-footer.php'); |