3 * Edit Posts Administration Panel.
6 * @subpackage Administration
9 /** WordPress Administration Bootstrap */
10 require_once('admin.php');
12 if ( !current_user_can('edit_posts') )
13 wp_die(__('Cheatin’ uh?'));
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 ) );
23 // Handle bulk actions
24 if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) {
25 $doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2'];
27 switch ( $doaction ) {
29 if ( isset($_GET['post']) && ! isset($_GET['bulk_edit']) && (isset($_GET['doaction']) || isset($_GET['doaction2'])) ) {
30 check_admin_referer('bulk-posts');
32 foreach( (array) $_GET['post'] as $post_id_del ) {
33 $post_del = & get_post($post_id_del);
35 if ( !current_user_can('delete_post', $post_id_del) )
36 wp_die( __('You are not allowed to delete this post.') );
38 if ( $post_del->post_type == 'attachment' ) {
39 if ( ! wp_delete_attachment($post_id_del) )
40 wp_die( __('Error in deleting...') );
42 if ( !wp_delete_post($post_id_del) )
43 wp_die( __('Error in deleting...') );
50 if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) {
51 check_admin_referer('bulk-posts');
53 if ( -1 == $_GET['_status'] ) {
54 $_GET['post_status'] = null;
55 unset($_GET['_status'], $_GET['post_status']);
57 $_GET['post_status'] = $_GET['_status'];
60 $done = bulk_edit_posts($_GET);
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');
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 );
74 if ( isset($deleted) )
75 $sendback = add_query_arg('deleted', $deleted, $sendback);
76 wp_redirect($sendback);
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']) ) );
84 $title = __('Edit Posts');
85 $parent_file = 'edit.php';
86 wp_enqueue_script('inline-edit-post');
88 list($post_stati, $avail_post_stati) = wp_edit_posts_query();
90 require_once('admin-header.php');
92 if ( !isset( $_GET['paged'] ) )
95 if ( empty($_GET['mode']) )
98 $mode = esc_attr($_GET['mode']); ?>
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 “%s”') . '</span>', esc_html( get_search_query() ) ); ?>
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']);
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']);
120 if ( isset($_GET['skipped']) && (int) $_GET['skipped'] )
121 unset($_GET['skipped']);
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']);
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']);
133 $_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted'), $_SERVER['REQUEST_URI'] );
138 <form id="posts-filter" action="" method="get">
140 <ul class="subsubsub">
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>';
150 foreach ( $post_stati as $status => $label ) {
153 if ( !in_array( $status, $avail_post_stati ) )
156 if ( empty( $num_posts->$status ) )
158 if ( isset($_GET['post_status']) && $status == $_GET['post_status'] )
159 $class = ' class="current"';
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>';
163 echo implode( " |</li>\n", $status_links ) . '</li>';
164 unset( $status_links );
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" />
175 <?php if ( isset($_GET['post_status'] ) ) : ?>
176 <input type="hidden" name="post_status" value="<?php echo esc_attr($_GET['post_status']) ?>" />
178 <input type="hidden" name="mode" value="<?php echo esc_attr($mode); ?>" />
180 <?php if ( have_posts() ) { ?>
182 <div class="tablenav">
184 $page_links = paginate_links( array(
185 'base' => add_query_arg( 'paged', '%#%' ),
187 'prev_text' => __('«'),
188 'next_text' => __('»'),
189 'total' => $wp_query->max_num_pages,
190 'current' => $_GET['paged']
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>
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'); ?>
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";
208 $arc_result = $wpdb->get_results( $arc_query );
210 $month_count = count($arc_result);
212 if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) {
213 $m = isset($_GET['m']) ? (int)$_GET['m'] : 0;
216 <option<?php selected( $m, 0 ); ?> value='0'><?php _e('Show all dates'); ?></option>
218 foreach ($arc_result as $arc_row) {
219 if ( $arc_row->yyear == 0 )
221 $arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
223 if ( $arc_row->yyear . $arc_row->mmonth == $m )
224 $default = ' selected="selected"';
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";
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');
242 <input type="submit" id="post-query-submit" value="<?php esc_attr_e('Filter'); ?>" class="button-secondary" />
247 <?php if ( $page_links ) { ?>
248 <div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%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 ),
253 ); echo $page_links_text; ?></div>
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>
261 <div class="clear"></div>
264 <div class="clear"></div>
266 <?php include( 'edit-post-rows.php' ); ?>
268 <div class="tablenav">
272 echo "<div class='tablenav-pages'>$page_links_text</div>";
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>
281 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
287 <?php } else { // have_posts() ?>
288 <div class="clear"></div>
289 <p><?php _e('No posts found') ?></p>
294 <?php inline_edit_row( 'post' ); ?>
296 <div id="ajax-response"></div>
303 include('admin-footer.php');