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_genesis 21 if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) {
mp-wp_genesis 22 $doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2'];
mp-wp_genesis 23
mp-wp_genesis 24 switch ( $doaction ) {
mp-wp_genesis 25 case 'delete':
mp-wp_genesis 26 if ( isset($_GET['post']) && ! isset($_GET['bulk_edit']) && (isset($_GET['doaction']) || isset($_GET['doaction2'])) ) {
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 wp_enqueue_script('inline-edit-post');
mp-wp_genesis 84
mp-wp_genesis 85 list($post_stati, $avail_post_stati) = wp_edit_posts_query();
mp-wp_genesis 86
mp-wp_genesis 87 require_once('admin-header.php');
mp-wp_genesis 88
mp-wp_genesis 89 if ( !isset( $_GET['paged'] ) )
mp-wp_genesis 90 $_GET['paged'] = 1;
mp-wp_genesis 91
mp-wp_genesis 92 if ( empty($_GET['mode']) )
mp-wp_genesis 93 $mode = 'list';
mp-wp_genesis 94 else
mp-wp_genesis 95 $mode = attribute_escape($_GET['mode']); ?>
mp-wp_genesis 96
mp-wp_genesis 97 <div class="wrap">
mp-wp_genesis 98 <?php screen_icon(); ?>
mp-wp_genesis 99 <h2><?php echo wp_specialchars( $title );
mp-wp_genesis 100 if ( isset($_GET['s']) && $_GET['s'] )
mp-wp_genesis 101 printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', wp_specialchars( get_search_query() ) ); ?>
mp-wp_genesis 102 </h2>
mp-wp_genesis 103
mp-wp_genesis 104 <?php
mp-wp_genesis 105 if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?>
mp-wp_genesis 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>
mp-wp_genesis 107 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
mp-wp_genesis 108 endif; ?>
mp-wp_genesis 109
mp-wp_genesis 110 <?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) ) { ?>
mp-wp_genesis 111 <div id="message" class="updated fade"><p>
mp-wp_genesis 112 <?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) {
mp-wp_genesis 113 printf( __ngettext( '%s post updated.', '%s posts updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) );
mp-wp_genesis 114 unset($_GET['updated']);
mp-wp_genesis 115 }
mp-wp_genesis 116
mp-wp_genesis 117 if ( isset($_GET['skipped']) && (int) $_GET['skipped'] )
mp-wp_genesis 118 unset($_GET['skipped']);
mp-wp_genesis 119
mp-wp_genesis 120 if ( isset($_GET['locked']) && (int) $_GET['locked'] ) {
mp-wp_genesis 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'] ) );
mp-wp_genesis 122 unset($_GET['locked']);
mp-wp_genesis 123 }
mp-wp_genesis 124
mp-wp_genesis 125 if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) {
mp-wp_genesis 126 printf( __ngettext( 'Post deleted.', '%s posts deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
mp-wp_genesis 127 unset($_GET['deleted']);
mp-wp_genesis 128 }
mp-wp_genesis 129
mp-wp_genesis 130 $_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted'), $_SERVER['REQUEST_URI'] );
mp-wp_genesis 131 ?>
mp-wp_genesis 132 </p></div>
mp-wp_genesis 133 <?php } ?>
mp-wp_genesis 134
mp-wp_genesis 135 <form id="posts-filter" action="" method="get">
mp-wp_genesis 136
mp-wp_genesis 137 <ul class="subsubsub">
mp-wp_genesis 138 <?php
mp-wp_genesis 139 if ( empty($locked_post_status) ) :
mp-wp_genesis 140 $status_links = array();
mp-wp_genesis 141 $num_posts = wp_count_posts( 'post', 'readable' );
mp-wp_genesis 142 $total_posts = array_sum( (array) $num_posts );
mp-wp_genesis 143 $class = empty( $_GET['post_status'] ) ? ' class="current"' : '';
mp-wp_genesis 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>';
mp-wp_genesis 145
mp-wp_genesis 146
mp-wp_genesis 147 foreach ( $post_stati as $status => $label ) {
mp-wp_genesis 148 $class = '';
mp-wp_genesis 149
mp-wp_genesis 150 if ( !in_array( $status, $avail_post_stati ) )
mp-wp_genesis 151 continue;
mp-wp_genesis 152
mp-wp_genesis 153 if ( empty( $num_posts->$status ) )
mp-wp_genesis 154 continue;
mp-wp_genesis 155 if ( isset($_GET['post_status']) && $status == $_GET['post_status'] )
mp-wp_genesis 156 $class = ' class="current"';
mp-wp_genesis 157
mp-wp_genesis 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>';
mp-wp_genesis 159 }
mp-wp_genesis 160 echo implode( " |</li>\n", $status_links ) . '</li>';
mp-wp_genesis 161 unset( $status_links );
mp-wp_genesis 162 endif;
mp-wp_genesis 163 ?>
mp-wp_genesis 164 </ul>
mp-wp_genesis 165
mp-wp_genesis 166 <p class="search-box">
mp-wp_genesis 167 <label class="hidden" for="post-search-input"><?php _e( 'Search Posts' ); ?>:</label>
mp-wp_genesis 168 <input type="text" class="search-input" id="post-search-input" name="s" value="<?php the_search_query(); ?>" />
mp-wp_genesis 169 <input type="submit" value="<?php _e( 'Search Posts' ); ?>" class="button" />
mp-wp_genesis 170 </p>
mp-wp_genesis 171
mp-wp_genesis 172 <?php if ( isset($_GET['post_status'] ) ) : ?>
mp-wp_genesis 173 <input type="hidden" name="post_status" value="<?php echo attribute_escape($_GET['post_status']) ?>" />
mp-wp_genesis 174 <?php endif; ?>
mp-wp_genesis 175 <input type="hidden" name="mode" value="<?php echo $mode; ?>" />
mp-wp_genesis 176
mp-wp_genesis 177 <?php if ( have_posts() ) { ?>
mp-wp_genesis 178
mp-wp_genesis 179 <div class="tablenav">
mp-wp_genesis 180 <?php
mp-wp_genesis 181 $page_links = paginate_links( array(
mp-wp_genesis 182 'base' => add_query_arg( 'paged', '%#%' ),
mp-wp_genesis 183 'format' => '',
mp-wp_genesis 184 'prev_text' => __('&laquo;'),
mp-wp_genesis 185 'next_text' => __('&raquo;'),
mp-wp_genesis 186 'total' => $wp_query->max_num_pages,
mp-wp_genesis 187 'current' => $_GET['paged']
mp-wp_genesis 188 ));
mp-wp_genesis 189
mp-wp_genesis 190 ?>
mp-wp_genesis 191
mp-wp_genesis 192 <div class="alignleft actions">
mp-wp_genesis 193 <select name="action">
mp-wp_genesis 194 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
mp-wp_genesis 195 <option value="edit"><?php _e('Edit'); ?></option>
mp-wp_genesis 196 <option value="delete"><?php _e('Delete'); ?></option>
mp-wp_genesis 197 </select>
mp-wp_genesis 198 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
mp-wp_genesis 199 <?php wp_nonce_field('bulk-posts'); ?>
mp-wp_genesis 200
mp-wp_genesis 201 <?php // view filters
mp-wp_genesis 202 if ( !is_singular() ) {
mp-wp_genesis 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";
mp-wp_genesis 204
mp-wp_genesis 205 $arc_result = $wpdb->get_results( $arc_query );
mp-wp_genesis 206
mp-wp_genesis 207 $month_count = count($arc_result);
mp-wp_genesis 208
mp-wp_genesis 209 if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) {
mp-wp_genesis 210 $m = isset($_GET['m']) ? (int)$_GET['m'] : 0;
mp-wp_genesis 211 ?>
mp-wp_genesis 212 <select name='m'>
mp-wp_genesis 213 <option<?php selected( $m, 0 ); ?> value='0'><?php _e('Show all dates'); ?></option>
mp-wp_genesis 214 <?php
mp-wp_genesis 215 foreach ($arc_result as $arc_row) {
mp-wp_genesis 216 if ( $arc_row->yyear == 0 )
mp-wp_genesis 217 continue;
mp-wp_genesis 218 $arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
mp-wp_genesis 219
mp-wp_genesis 220 if ( $arc_row->yyear . $arc_row->mmonth == $m )
mp-wp_genesis 221 $default = ' selected="selected"';
mp-wp_genesis 222 else
mp-wp_genesis 223 $default = '';
mp-wp_genesis 224
mp-wp_genesis 225 echo "<option$default value='$arc_row->yyear$arc_row->mmonth'>";
mp-wp_genesis 226 echo $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear";
mp-wp_genesis 227 echo "</option>\n";
mp-wp_genesis 228 }
mp-wp_genesis 229 ?>
mp-wp_genesis 230 </select>
mp-wp_genesis 231 <?php } ?>
mp-wp_genesis 232
mp-wp_genesis 233 <?php
mp-wp_genesis 234 $dropdown_options = array('show_option_all' => __('View all categories'), 'hide_empty' => 0, 'hierarchical' => 1,
mp-wp_genesis 235 'show_count' => 0, 'orderby' => 'name', 'selected' => $cat);
mp-wp_genesis 236 wp_dropdown_categories($dropdown_options);
mp-wp_genesis 237 do_action('restrict_manage_posts');
mp-wp_genesis 238 ?>
mp-wp_genesis 239 <input type="submit" id="post-query-submit" value="<?php _e('Filter'); ?>" class="button-secondary" />
mp-wp_genesis 240
mp-wp_genesis 241 <?php } ?>
mp-wp_genesis 242 </div>
mp-wp_genesis 243
mp-wp_genesis 244 <?php if ( $page_links ) { ?>
mp-wp_genesis 245 <div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
mp-wp_genesis 246 number_format_i18n( ( $_GET['paged'] - 1 ) * $wp_query->query_vars['posts_per_page'] + 1 ),
mp-wp_genesis 247 number_format_i18n( min( $_GET['paged'] * $wp_query->query_vars['posts_per_page'], $wp_query->found_posts ) ),
mp-wp_genesis 248 number_format_i18n( $wp_query->found_posts ),
mp-wp_genesis 249 $page_links
mp-wp_genesis 250 ); echo $page_links_text; ?></div>
mp-wp_genesis 251 <?php } ?>
mp-wp_genesis 252
mp-wp_genesis 253 <div class="view-switch">
mp-wp_genesis 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>
mp-wp_genesis 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>
mp-wp_genesis 256 </div>
mp-wp_genesis 257
mp-wp_genesis 258 <div class="clear"></div>
mp-wp_genesis 259 </div>
mp-wp_genesis 260
mp-wp_genesis 261 <div class="clear"></div>
mp-wp_genesis 262
mp-wp_genesis 263 <?php include( 'edit-post-rows.php' ); ?>
mp-wp_genesis 264
mp-wp_genesis 265 <div class="tablenav">
mp-wp_genesis 266
mp-wp_genesis 267 <?php
mp-wp_genesis 268 if ( $page_links )
mp-wp_genesis 269 echo "<div class='tablenav-pages'>$page_links_text</div>";
mp-wp_genesis 270 ?>
mp-wp_genesis 271
mp-wp_genesis 272 <div class="alignleft actions">
mp-wp_genesis 273 <select name="action2">
mp-wp_genesis 274 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
mp-wp_genesis 275 <option value="edit"><?php _e('Edit'); ?></option>
mp-wp_genesis 276 <option value="delete"><?php _e('Delete'); ?></option>
mp-wp_genesis 277 </select>
mp-wp_genesis 278 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
mp-wp_genesis 279 <br class="clear" />
mp-wp_genesis 280 </div>
mp-wp_genesis 281 <br class="clear" />
mp-wp_genesis 282 </div>
mp-wp_genesis 283
mp-wp_genesis 284 <?php } else { // have_posts() ?>
mp-wp_genesis 285 <div class="clear"></div>
mp-wp_genesis 286 <p><?php _e('No posts found') ?></p>
mp-wp_genesis 287 <?php } ?>
mp-wp_genesis 288
mp-wp_genesis 289 </form>
mp-wp_genesis 290
mp-wp_genesis 291 <?php inline_edit_row( 'post' ); ?>
mp-wp_genesis 292
mp-wp_genesis 293 <div id="ajax-response"></div>
mp-wp_genesis 294
mp-wp_genesis 295 <br class="clear" />
mp-wp_genesis 296
mp-wp_genesis 297 </div>
mp-wp_genesis 298
mp-wp_genesis 299 <script type="text/javascript">
mp-wp_genesis 300 /* <![CDATA[ */
mp-wp_genesis 301 (function($){
mp-wp_genesis 302 $(document).ready(function(){
mp-wp_genesis 303 $('#doaction, #doaction2').click(function(){
mp-wp_genesis 304 if ( $('select[name^="action"]').val() == 'delete' ) {
mp-wp_genesis 305 var m = '<?php echo js_escape(__("You are about to delete the selected posts.\n 'Cancel' to stop, 'OK' to delete.")); ?>';
mp-wp_genesis 306 return showNotice.warn(m);
mp-wp_genesis 307 }
mp-wp_genesis 308 });
mp-wp_genesis 309 });
mp-wp_genesis 310 })(jQuery);
mp-wp_genesis 311 columns.init('edit');
mp-wp_genesis 312 /* ]]> */
mp-wp_genesis 313 </script>
mp-wp_genesis 314
mp-wp_genesis 315 <?php include('admin-footer.php'); ?>