]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/edit.php
Wordpress 2.8.3
[autoinstalls/wordpress.git] / wp-admin / edit.php
1 <?php
2 /**
3  * Edit Posts Administration Panel.
4  *
5  * @package WordPress
6  * @subpackage Administration
7  */
8
9 /** WordPress Administration Bootstrap */
10 require_once('admin.php');
11
12 if ( !current_user_can('edit_posts') )
13         wp_die(__('Cheatin&#8217; uh?'));
14
15 // Back-compat for viewing comments of an entry
16 if ( $_redirect = intval( max( @$_GET['p'], @$_GET['attachment_id'], @$_GET['page_id'] ) ) ) {
17         wp_redirect( admin_url('edit-comments.php?p=' . $_redirect ) );
18         exit;
19 } else {
20         unset( $_redirect );
21 }
22
23 // Handle bulk actions
24 if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) {
25         $doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2'];
26
27         switch ( $doaction ) {
28                 case 'delete':
29                         if ( isset($_GET['post']) && ! isset($_GET['bulk_edit']) && (isset($_GET['doaction']) || isset($_GET['doaction2'])) ) {
30                                 check_admin_referer('bulk-posts');
31                                 $deleted = 0;
32                                 foreach( (array) $_GET['post'] as $post_id_del ) {
33                                         $post_del = & get_post($post_id_del);
34
35                                         if ( !current_user_can('delete_post', $post_id_del) )
36                                                 wp_die( __('You are not allowed to delete this post.') );
37
38                                         if ( $post_del->post_type == 'attachment' ) {
39                                                 if ( ! wp_delete_attachment($post_id_del) )
40                                                         wp_die( __('Error in deleting...') );
41                                         } else {
42                                                 if ( !wp_delete_post($post_id_del) )
43                                                         wp_die( __('Error in deleting...') );
44                                         }
45                                         $deleted++;
46                                 }
47                         }
48                         break;
49                 case 'edit':
50                         if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) {
51                                 check_admin_referer('bulk-posts');
52
53                                 if ( -1 == $_GET['_status'] ) {
54                                         $_GET['post_status'] = null;
55                                         unset($_GET['_status'], $_GET['post_status']);
56                                 } else {
57                                         $_GET['post_status'] = $_GET['_status'];
58                                 }
59
60                                 $done = bulk_edit_posts($_GET);
61                         }
62                         break;
63         }
64
65         $sendback = wp_get_referer();
66         if ( strpos($sendback, 'post.php') !== false ) $sendback = admin_url('post-new.php');
67         elseif ( strpos($sendback, 'attachments.php') !== false ) $sendback = admin_url('attachments.php');
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);
77         exit();
78 } 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']) ) );
80          exit;
81 }
82
83 if ( empty($title) )
84         $title = __('Edit Posts');
85 $parent_file = 'edit.php';
86 wp_enqueue_script('inline-edit-post');
87
88 list($post_stati, $avail_post_stati) = wp_edit_posts_query();
89
90 require_once('admin-header.php');
91
92 if ( !isset( $_GET['paged'] ) )
93         $_GET['paged'] = 1;
94
95 if ( empty($_GET['mode']) )
96         $mode = 'list';
97 else
98         $mode = esc_attr($_GET['mode']); ?>
99
100 <div class="wrap">
101 <?php screen_icon(); ?>
102 <h2><?php echo esc_html( $title );
103 if ( isset($_GET['s']) && $_GET['s'] )
104         printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( get_search_query() ) ); ?>
105 </h2>
106
107 <?php
108 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>
110 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
111 endif; ?>
112
113 <?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) ) { ?>
114 <div id="message" class="updated fade"><p>
115 <?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) {
116         printf( _n( '%s post updated.', '%s posts updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) );
117         unset($_GET['updated']);
118 }
119
120 if ( isset($_GET['skipped']) && (int) $_GET['skipped'] )
121         unset($_GET['skipped']);
122
123 if ( isset($_GET['locked']) && (int) $_GET['locked'] ) {
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'] ) );
125         unset($_GET['locked']);
126 }
127
128 if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) {
129         printf( _n( 'Post deleted.', '%s posts deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
130         unset($_GET['deleted']);
131 }
132
133 $_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted'), $_SERVER['REQUEST_URI'] );
134 ?>
135 </p></div>
136 <?php } ?>
137
138 <form id="posts-filter" action="" method="get">
139
140 <ul class="subsubsub">
141 <?php
142 if ( empty($locked_post_status) ) :
143 $status_links = array();
144 $num_posts = wp_count_posts( 'post', 'readable' );
145 $total_posts = array_sum( (array) $num_posts );
146 $class = empty( $_GET['post_status'] ) ? ' class="current"' : '';
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>';
148
149
150 foreach ( $post_stati as $status => $label ) {
151         $class = '';
152
153         if ( !in_array( $status, $avail_post_stati ) )
154                 continue;
155
156         if ( empty( $num_posts->$status ) )
157                 continue;
158         if ( isset($_GET['post_status']) && $status == $_GET['post_status'] )
159                 $class = ' class="current"';
160
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>';
162 }
163 echo implode( " |</li>\n", $status_links ) . '</li>';
164 unset( $status_links );
165 endif;
166 ?>
167 </ul>
168
169 <p class="search-box">
170         <label class="screen-reader-text" for="post-search-input"><?php _e( 'Search Posts' ); ?>:</label>
171         <input type="text" id="post-search-input" name="s" value="<?php the_search_query(); ?>" />
172         <input type="submit" value="<?php esc_attr_e( 'Search Posts' ); ?>" class="button" />
173 </p>
174
175 <?php if ( isset($_GET['post_status'] ) ) : ?>
176 <input type="hidden" name="post_status" value="<?php echo esc_attr($_GET['post_status']) ?>" />
177 <?php endif; ?>
178 <input type="hidden" name="mode" value="<?php echo esc_attr($mode); ?>" />
179
180 <?php if ( have_posts() ) { ?>
181
182 <div class="tablenav">
183 <?php
184 $page_links = paginate_links( array(
185         'base' => add_query_arg( 'paged', '%#%' ),
186         'format' => '',
187         'prev_text' => __('&laquo;'),
188         'next_text' => __('&raquo;'),
189         'total' => $wp_query->max_num_pages,
190         'current' => $_GET['paged']
191 ));
192
193 ?>
194
195 <div class="alignleft actions">
196 <select name="action">
197 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
198 <option value="edit"><?php _e('Edit'); ?></option>
199 <option value="delete"><?php _e('Delete'); ?></option>
200 </select>
201 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
202 <?php wp_nonce_field('bulk-posts'); ?>
203
204 <?php // view filters
205 if ( !is_singular() ) {
206 $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC";
207
208 $arc_result = $wpdb->get_results( $arc_query );
209
210 $month_count = count($arc_result);
211
212 if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) {
213 $m = isset($_GET['m']) ? (int)$_GET['m'] : 0;
214 ?>
215 <select name='m'>
216 <option<?php selected( $m, 0 ); ?> value='0'><?php _e('Show all dates'); ?></option>
217 <?php
218 foreach ($arc_result as $arc_row) {
219         if ( $arc_row->yyear == 0 )
220                 continue;
221         $arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
222
223         if ( $arc_row->yyear . $arc_row->mmonth == $m )
224                 $default = ' selected="selected"';
225         else
226                 $default = '';
227
228         echo "<option$default value='" . esc_attr("$arc_row->yyear$arc_row->mmonth") . "'>";
229         echo $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear";
230         echo "</option>\n";
231 }
232 ?>
233 </select>
234 <?php } ?>
235
236 <?php
237 $dropdown_options = array('show_option_all' => __('View all categories'), 'hide_empty' => 0, 'hierarchical' => 1,
238         'show_count' => 0, 'orderby' => 'name', 'selected' => $cat);
239 wp_dropdown_categories($dropdown_options);
240 do_action('restrict_manage_posts');
241 ?>
242 <input type="submit" id="post-query-submit" value="<?php esc_attr_e('Filter'); ?>" class="button-secondary" />
243
244 <?php } ?>
245 </div>
246
247 <?php if ( $page_links ) { ?>
248 <div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
249         number_format_i18n( ( $_GET['paged'] - 1 ) * $wp_query->query_vars['posts_per_page'] + 1 ),
250         number_format_i18n( min( $_GET['paged'] * $wp_query->query_vars['posts_per_page'], $wp_query->found_posts ) ),
251         number_format_i18n( $wp_query->found_posts ),
252         $page_links
253 ); echo $page_links_text; ?></div>
254 <?php } ?>
255
256 <div class="view-switch">
257         <a href="<?php echo esc_url(add_query_arg('mode', 'list', $_SERVER['REQUEST_URI'])) ?>"><img <?php if ( 'list' == $mode ) echo 'class="current"'; ?> id="view-switch-list" src="../wp-includes/images/blank.gif" width="20" height="20" title="<?php _e('List View') ?>" alt="<?php _e('List View') ?>" /></a>
258         <a href="<?php echo esc_url(add_query_arg('mode', 'excerpt', $_SERVER['REQUEST_URI'])) ?>"><img <?php if ( 'excerpt' == $mode ) echo 'class="current"'; ?> id="view-switch-excerpt" src="../wp-includes/images/blank.gif" width="20" height="20" title="<?php _e('Excerpt View') ?>" alt="<?php _e('Excerpt View') ?>" /></a>
259 </div>
260
261 <div class="clear"></div>
262 </div>
263
264 <div class="clear"></div>
265
266 <?php include( 'edit-post-rows.php' ); ?>
267
268 <div class="tablenav">
269
270 <?php
271 if ( $page_links )
272         echo "<div class='tablenav-pages'>$page_links_text</div>";
273 ?>
274
275 <div class="alignleft actions">
276 <select name="action2">
277 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
278 <option value="edit"><?php _e('Edit'); ?></option>
279 <option value="delete"><?php _e('Delete'); ?></option>
280 </select>
281 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
282 <br class="clear" />
283 </div>
284 <br class="clear" />
285 </div>
286
287 <?php } else { // have_posts() ?>
288 <div class="clear"></div>
289 <p><?php _e('No posts found') ?></p>
290 <?php } ?>
291
292 </form>
293
294 <?php inline_edit_row( 'post' ); ?>
295
296 <div id="ajax-response"></div>
297
298 <br class="clear" />
299
300 </div>
301
302 <?php
303 include('admin-footer.php');