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