3 * Edit Posts Administration Panel.
6 * @subpackage Administration
9 /** WordPress Administration Bootstrap */
10 require_once('admin.php');
12 // Back-compat for viewing comments of an entry
13 if ( $_redirect = intval( max( @$_GET['p'], @$_GET['attachment_id'], @$_GET['page_id'] ) ) ) {
14 wp_redirect( admin_url('edit-comments.php?p=' . $_redirect ) );
20 // Handle bulk actions
21 if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) {
22 $doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2'];
24 switch ( $doaction ) {
26 if ( isset($_GET['post']) && ! isset($_GET['bulk_edit']) && (isset($_GET['doaction']) || isset($_GET['doaction2'])) ) {
27 check_admin_referer('bulk-posts');
29 foreach( (array) $_GET['post'] as $post_id_del ) {
30 $post_del = & get_post($post_id_del);
32 if ( !current_user_can('delete_post', $post_id_del) )
33 wp_die( __('You are not allowed to delete this post.') );
35 if ( $post_del->post_type == 'attachment' ) {
36 if ( ! wp_delete_attachment($post_id_del) )
37 wp_die( __('Error in deleting...') );
39 if ( !wp_delete_post($post_id_del) )
40 wp_die( __('Error in deleting...') );
47 if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) {
48 check_admin_referer('bulk-posts');
50 if ( -1 == $_GET['_status'] ) {
51 $_GET['post_status'] = null;
52 unset($_GET['_status'], $_GET['post_status']);
54 $_GET['post_status'] = $_GET['_status'];
57 $done = bulk_edit_posts($_GET);
62 $sendback = wp_get_referer();
63 if ( strpos($sendback, 'post.php') !== false ) $sendback = admin_url('post-new.php');
64 elseif ( strpos($sendback, 'attachments.php') !== false ) $sendback = admin_url('attachments.php');
66 $done['updated'] = count( $done['updated'] );
67 $done['skipped'] = count( $done['skipped'] );
68 $done['locked'] = count( $done['locked'] );
69 $sendback = add_query_arg( $done, $sendback );
71 if ( isset($deleted) )
72 $sendback = add_query_arg('deleted', $deleted, $sendback);
73 wp_redirect($sendback);
75 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
76 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
81 $title = __('Edit Posts');
82 $parent_file = 'edit.php';
83 wp_enqueue_script('inline-edit-post');
85 list($post_stati, $avail_post_stati) = wp_edit_posts_query();
87 require_once('admin-header.php');
89 if ( !isset( $_GET['paged'] ) )
92 if ( empty($_GET['mode']) )
95 $mode = attribute_escape($_GET['mode']); ?>
98 <?php screen_icon(); ?>
99 <h2><?php echo wp_specialchars( $title );
100 if ( isset($_GET['s']) && $_GET['s'] )
101 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', wp_specialchars( get_search_query() ) ); ?>
105 if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?>
106 <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>
107 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
110 <?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) ) { ?>
111 <div id="message" class="updated fade"><p>
112 <?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) {
113 printf( __ngettext( '%s post updated.', '%s posts updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) );
114 unset($_GET['updated']);
117 if ( isset($_GET['skipped']) && (int) $_GET['skipped'] )
118 unset($_GET['skipped']);
120 if ( isset($_GET['locked']) && (int) $_GET['locked'] ) {
121 printf( __ngettext( '%s post not updated, somebody is editing it.', '%s posts not updated, somebody is editing them.', $_GET['locked'] ), number_format_i18n( $_GET['locked'] ) );
122 unset($_GET['locked']);
125 if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) {
126 printf( __ngettext( 'Post deleted.', '%s posts deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
127 unset($_GET['deleted']);
130 $_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted'), $_SERVER['REQUEST_URI'] );
135 <form id="posts-filter" action="" method="get">
137 <ul class="subsubsub">
139 if ( empty($locked_post_status) ) :
140 $status_links = array();
141 $num_posts = wp_count_posts( 'post', 'readable' );
142 $total_posts = array_sum( (array) $num_posts );
143 $class = empty( $_GET['post_status'] ) ? ' class="current"' : '';
144 $status_links[] = "<li><a href='edit.php' $class>" . sprintf( __ngettext( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts ), number_format_i18n( $total_posts ) ) . '</a>';
147 foreach ( $post_stati as $status => $label ) {
150 if ( !in_array( $status, $avail_post_stati ) )
153 if ( empty( $num_posts->$status ) )
155 if ( isset($_GET['post_status']) && $status == $_GET['post_status'] )
156 $class = ' class="current"';
158 $status_links[] = "<li><a href='edit.php?post_status=$status' $class>" . sprintf( __ngettext( $label[2][0], $label[2][1], $num_posts->$status ), number_format_i18n( $num_posts->$status ) ) . '</a>';
160 echo implode( " |</li>\n", $status_links ) . '</li>';
161 unset( $status_links );
166 <p class="search-box">
167 <label class="hidden" for="post-search-input"><?php _e( 'Search Posts' ); ?>:</label>
168 <input type="text" class="search-input" id="post-search-input" name="s" value="<?php the_search_query(); ?>" />
169 <input type="submit" value="<?php _e( 'Search Posts' ); ?>" class="button" />
172 <?php if ( isset($_GET['post_status'] ) ) : ?>
173 <input type="hidden" name="post_status" value="<?php echo attribute_escape($_GET['post_status']) ?>" />
175 <input type="hidden" name="mode" value="<?php echo $mode; ?>" />
177 <?php if ( have_posts() ) { ?>
179 <div class="tablenav">
181 $page_links = paginate_links( array(
182 'base' => add_query_arg( 'paged', '%#%' ),
184 'prev_text' => __('«'),
185 'next_text' => __('»'),
186 'total' => $wp_query->max_num_pages,
187 'current' => $_GET['paged']
192 <div class="alignleft actions">
193 <select name="action">
194 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
195 <option value="edit"><?php _e('Edit'); ?></option>
196 <option value="delete"><?php _e('Delete'); ?></option>
198 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
199 <?php wp_nonce_field('bulk-posts'); ?>
201 <?php // view filters
202 if ( !is_singular() ) {
203 $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";
205 $arc_result = $wpdb->get_results( $arc_query );
207 $month_count = count($arc_result);
209 if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) {
210 $m = isset($_GET['m']) ? (int)$_GET['m'] : 0;
213 <option<?php selected( $m, 0 ); ?> value='0'><?php _e('Show all dates'); ?></option>
215 foreach ($arc_result as $arc_row) {
216 if ( $arc_row->yyear == 0 )
218 $arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
220 if ( $arc_row->yyear . $arc_row->mmonth == $m )
221 $default = ' selected="selected"';
225 echo "<option$default value='$arc_row->yyear$arc_row->mmonth'>";
226 echo $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear";
234 $dropdown_options = array('show_option_all' => __('View all categories'), 'hide_empty' => 0, 'hierarchical' => 1,
235 'show_count' => 0, 'orderby' => 'name', 'selected' => $cat);
236 wp_dropdown_categories($dropdown_options);
237 do_action('restrict_manage_posts');
239 <input type="submit" id="post-query-submit" value="<?php _e('Filter'); ?>" class="button-secondary" />
244 <?php if ( $page_links ) { ?>
245 <div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
246 number_format_i18n( ( $_GET['paged'] - 1 ) * $wp_query->query_vars['posts_per_page'] + 1 ),
247 number_format_i18n( min( $_GET['paged'] * $wp_query->query_vars['posts_per_page'], $wp_query->found_posts ) ),
248 number_format_i18n( $wp_query->found_posts ),
250 ); echo $page_links_text; ?></div>
253 <div class="view-switch">
254 <a href="<?php echo clean_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>
255 <a href="<?php echo clean_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>
258 <div class="clear"></div>
261 <div class="clear"></div>
263 <?php include( 'edit-post-rows.php' ); ?>
265 <div class="tablenav">
269 echo "<div class='tablenav-pages'>$page_links_text</div>";
272 <div class="alignleft actions">
273 <select name="action2">
274 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
275 <option value="edit"><?php _e('Edit'); ?></option>
276 <option value="delete"><?php _e('Delete'); ?></option>
278 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
284 <?php } else { // have_posts() ?>
285 <div class="clear"></div>
286 <p><?php _e('No posts found') ?></p>
291 <?php inline_edit_row( 'post' ); ?>
293 <div id="ajax-response"></div>
299 <script type="text/javascript">
302 $(document).ready(function(){
303 $('#doaction, #doaction2').click(function(){
304 if ( $('select[name^="action"]').val() == 'delete' ) {
305 var m = '<?php echo js_escape(__("You are about to delete the selected posts.\n 'Cancel' to stop, 'OK' to delete.")); ?>';
306 return showNotice.warn(m);
311 columns.init('edit');
315 <?php include('admin-footer.php'); ?>