43 * @var int |
43 * @var int |
44 * @access private |
44 * @access private |
45 */ |
45 */ |
46 var $sticky_posts_count = 0; |
46 var $sticky_posts_count = 0; |
47 |
47 |
48 function __construct() { |
48 function __construct( $args = array() ) { |
49 global $post_type_object, $wpdb; |
49 global $post_type_object, $wpdb; |
50 |
50 |
51 $post_type = get_current_screen()->post_type; |
51 parent::__construct( array( |
|
52 'plural' => 'posts', |
|
53 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
54 ) ); |
|
55 |
|
56 $post_type = $this->screen->post_type; |
52 $post_type_object = get_post_type_object( $post_type ); |
57 $post_type_object = get_post_type_object( $post_type ); |
53 |
58 |
54 if ( !current_user_can( $post_type_object->cap->edit_others_posts ) ) { |
59 if ( !current_user_can( $post_type_object->cap->edit_others_posts ) ) { |
55 $this->user_posts_count = $wpdb->get_var( $wpdb->prepare( " |
60 $this->user_posts_count = $wpdb->get_var( $wpdb->prepare( " |
56 SELECT COUNT( 1 ) FROM $wpdb->posts |
61 SELECT COUNT( 1 ) FROM $wpdb->posts |
64 |
69 |
65 if ( 'post' == $post_type && $sticky_posts = get_option( 'sticky_posts' ) ) { |
70 if ( 'post' == $post_type && $sticky_posts = get_option( 'sticky_posts' ) ) { |
66 $sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) ); |
71 $sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) ); |
67 $this->sticky_posts_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( 1 ) FROM $wpdb->posts WHERE post_type = %s AND post_status != 'trash' AND ID IN ($sticky_posts)", $post_type ) ); |
72 $this->sticky_posts_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( 1 ) FROM $wpdb->posts WHERE post_type = %s AND post_status != 'trash' AND ID IN ($sticky_posts)", $post_type ) ); |
68 } |
73 } |
69 |
|
70 parent::__construct( array( |
|
71 'plural' => 'posts', |
|
72 ) ); |
|
73 } |
74 } |
74 |
75 |
75 function ajax_user_can() { |
76 function ajax_user_can() { |
76 global $post_type_object; |
77 return current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_posts ); |
77 |
|
78 return current_user_can( $post_type_object->cap->edit_posts ); |
|
79 } |
78 } |
80 |
79 |
81 function prepare_items() { |
80 function prepare_items() { |
82 global $post_type_object, $avail_post_stati, $wp_query, $per_page, $mode; |
81 global $avail_post_stati, $wp_query, $per_page, $mode; |
83 |
82 |
84 $avail_post_stati = wp_edit_posts_query(); |
83 $avail_post_stati = wp_edit_posts_query(); |
85 |
84 |
86 $this->hierarchical_display = ( $post_type_object->hierarchical && 'menu_order title' == $wp_query->query['orderby'] ); |
85 $this->hierarchical_display = ( is_post_type_hierarchical( $this->screen->post_type ) && 'menu_order title' == $wp_query->query['orderby'] ); |
87 |
86 |
88 $total_items = $this->hierarchical_display ? $wp_query->post_count : $wp_query->found_posts; |
87 $total_items = $this->hierarchical_display ? $wp_query->post_count : $wp_query->found_posts; |
89 |
88 |
90 $post_type = $post_type_object->name; |
89 $post_type = $this->screen->post_type; |
91 $per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' ); |
90 $per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' ); |
92 $per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type ); |
91 $per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type ); |
93 |
92 |
94 if ( $this->hierarchical_display ) |
93 if ( $this->hierarchical_display ) |
95 $total_pages = ceil( $total_items / $per_page ); |
94 $total_pages = ceil( $total_items / $per_page ); |
110 function has_items() { |
109 function has_items() { |
111 return have_posts(); |
110 return have_posts(); |
112 } |
111 } |
113 |
112 |
114 function no_items() { |
113 function no_items() { |
115 global $post_type_object; |
|
116 |
|
117 if ( isset( $_REQUEST['post_status'] ) && 'trash' == $_REQUEST['post_status'] ) |
114 if ( isset( $_REQUEST['post_status'] ) && 'trash' == $_REQUEST['post_status'] ) |
118 echo $post_type_object->labels->not_found_in_trash; |
115 echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash; |
119 else |
116 else |
120 echo $post_type_object->labels->not_found; |
117 echo get_post_type_object( $this->screen->post_type )->labels->not_found; |
121 } |
118 } |
122 |
119 |
123 function get_views() { |
120 function get_views() { |
124 global $post_type_object, $locked_post_status, $avail_post_stati; |
121 global $locked_post_status, $avail_post_stati; |
125 |
122 |
126 $post_type = $post_type_object->name; |
123 $post_type = $this->screen->post_type; |
127 |
124 |
128 if ( !empty($locked_post_status) ) |
125 if ( !empty($locked_post_status) ) |
129 return array(); |
126 return array(); |
130 |
127 |
131 $status_links = array(); |
128 $status_links = array(); |
196 |
193 |
197 return $actions; |
194 return $actions; |
198 } |
195 } |
199 |
196 |
200 function extra_tablenav( $which ) { |
197 function extra_tablenav( $which ) { |
201 global $post_type_object, $cat; |
198 global $cat; |
202 ?> |
199 ?> |
203 <div class="alignleft actions"> |
200 <div class="alignleft actions"> |
204 <?php |
201 <?php |
205 if ( 'top' == $which && !is_singular() ) { |
202 if ( 'top' == $which && !is_singular() ) { |
206 |
203 |
207 $this->months_dropdown( $post_type_object->name ); |
204 $this->months_dropdown( $this->screen->post_type ); |
208 |
205 |
209 if ( is_object_in_taxonomy( $post_type_object->name, 'category' ) ) { |
206 if ( is_object_in_taxonomy( $this->screen->post_type, 'category' ) ) { |
210 $dropdown_options = array( |
207 $dropdown_options = array( |
211 'show_option_all' => __( 'View all categories' ), |
208 'show_option_all' => __( 'View all categories' ), |
212 'hide_empty' => 0, |
209 'hide_empty' => 0, |
213 'hierarchical' => 1, |
210 'hierarchical' => 1, |
214 'show_count' => 0, |
211 'show_count' => 0, |
216 'selected' => $cat |
213 'selected' => $cat |
217 ); |
214 ); |
218 wp_dropdown_categories( $dropdown_options ); |
215 wp_dropdown_categories( $dropdown_options ); |
219 } |
216 } |
220 do_action( 'restrict_manage_posts' ); |
217 do_action( 'restrict_manage_posts' ); |
221 submit_button( __( 'Filter' ), 'secondary', false, false, array( 'id' => 'post-query-submit' ) ); |
218 submit_button( __( 'Filter' ), 'button', false, false, array( 'id' => 'post-query-submit' ) ); |
222 } |
219 } |
223 |
220 |
224 if ( $this->is_trash && current_user_can( $post_type_object->cap->edit_others_posts ) ) { |
221 if ( $this->is_trash && current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) ) { |
225 submit_button( __( 'Empty Trash' ), 'button-secondary apply', 'delete_all', false ); |
222 submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); |
226 } |
223 } |
227 ?> |
224 ?> |
228 </div> |
225 </div> |
229 <?php |
226 <?php |
230 } |
227 } |
235 |
232 |
236 return parent::current_action(); |
233 return parent::current_action(); |
237 } |
234 } |
238 |
235 |
239 function pagination( $which ) { |
236 function pagination( $which ) { |
240 global $post_type_object, $mode; |
237 global $mode; |
241 |
238 |
242 parent::pagination( $which ); |
239 parent::pagination( $which ); |
243 |
240 |
244 if ( 'top' == $which && !$post_type_object->hierarchical ) |
241 if ( 'top' == $which && ! is_post_type_hierarchical( $this->screen->post_type ) ) |
245 $this->view_switcher( $mode ); |
242 $this->view_switcher( $mode ); |
246 } |
243 } |
247 |
244 |
248 function get_table_classes() { |
245 function get_table_classes() { |
249 global $post_type_object; |
246 return array( 'widefat', 'fixed', is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' ); |
250 |
|
251 return array( 'widefat', 'fixed', $post_type_object->hierarchical ? 'pages' : 'posts' ); |
|
252 } |
247 } |
253 |
248 |
254 function get_columns() { |
249 function get_columns() { |
255 $screen = get_current_screen(); |
250 $post_type = $this->screen->post_type; |
256 |
|
257 if ( empty( $screen ) ) |
|
258 $post_type = 'post'; |
|
259 else |
|
260 $post_type = $screen->post_type; |
|
261 |
251 |
262 $posts_columns = array(); |
252 $posts_columns = array(); |
263 |
253 |
264 $posts_columns['cb'] = '<input type="checkbox" />'; |
254 $posts_columns['cb'] = '<input type="checkbox" />'; |
265 |
255 |
267 $posts_columns['title'] = _x( 'Title', 'column name' ); |
257 $posts_columns['title'] = _x( 'Title', 'column name' ); |
268 |
258 |
269 if ( post_type_supports( $post_type, 'author' ) ) |
259 if ( post_type_supports( $post_type, 'author' ) ) |
270 $posts_columns['author'] = __( 'Author' ); |
260 $posts_columns['author'] = __( 'Author' ); |
271 |
261 |
272 if ( empty( $post_type ) || is_object_in_taxonomy( $post_type, 'category' ) ) |
262 $taxonomies = array(); |
273 $posts_columns['categories'] = __( 'Categories' ); |
263 |
274 |
264 $taxonomies = get_object_taxonomies( $post_type, 'objects' ); |
275 if ( empty( $post_type ) || is_object_in_taxonomy( $post_type, 'post_tag' ) ) |
265 $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' ); |
276 $posts_columns['tags'] = __( 'Tags' ); |
266 |
|
267 $taxonomies = apply_filters( "manage_taxonomies_for_{$post_type}_columns", $taxonomies, $post_type ); |
|
268 $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' ); |
|
269 |
|
270 foreach ( $taxonomies as $taxonomy ) { |
|
271 if ( 'category' == $taxonomy ) |
|
272 $column_key = 'categories'; |
|
273 elseif ( 'post_tag' == $taxonomy ) |
|
274 $column_key = 'tags'; |
|
275 else |
|
276 $column_key = 'taxonomy-' . $taxonomy; |
|
277 |
|
278 $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; |
|
279 } |
277 |
280 |
278 $post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all'; |
281 $post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all'; |
279 if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) ) |
282 if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) ) |
280 $posts_columns['comments'] = '<span class="vers"><img alt="' . esc_attr__( 'Comments' ) . '" src="' . esc_url( admin_url( 'images/comment-grey-bubble.png' ) ) . '" /></span>'; |
283 $posts_columns['comments'] = '<span class="vers"><div title="' . esc_attr__( 'Comments' ) . '" class="comment-grey-bubble"></div></span>'; |
281 |
284 |
282 $posts_columns['date'] = __( 'Date' ); |
285 $posts_columns['date'] = __( 'Date' ); |
283 |
286 |
284 if ( 'page' == $post_type ) |
287 if ( 'page' == $post_type ) |
285 $posts_columns = apply_filters( 'manage_pages_columns', $posts_columns ); |
288 $posts_columns = apply_filters( 'manage_pages_columns', $posts_columns ); |
291 } |
294 } |
292 |
295 |
293 function get_sortable_columns() { |
296 function get_sortable_columns() { |
294 return array( |
297 return array( |
295 'title' => 'title', |
298 'title' => 'title', |
296 'author' => 'author', |
|
297 'parent' => 'parent', |
299 'parent' => 'parent', |
298 'comments' => 'comment_count', |
300 'comments' => 'comment_count', |
299 'date' => array( 'date', true ) |
301 'date' => array( 'date', true ) |
300 ); |
302 ); |
301 } |
303 } |
302 |
304 |
303 function display_rows( $posts = array() ) { |
305 function display_rows( $posts = array(), $level = 0 ) { |
304 global $wp_query, $post_type_object, $per_page; |
306 global $wp_query, $per_page; |
305 |
307 |
306 if ( empty( $posts ) ) |
308 if ( empty( $posts ) ) |
307 $posts = $wp_query->posts; |
309 $posts = $wp_query->posts; |
308 |
310 |
309 add_filter( 'the_title', 'esc_html' ); |
311 add_filter( 'the_title', 'esc_html' ); |
310 |
312 |
311 if ( $this->hierarchical_display ) { |
313 if ( $this->hierarchical_display ) { |
312 $this->_display_rows_hierarchical( $posts, $this->get_pagenum(), $per_page ); |
314 $this->_display_rows_hierarchical( $posts, $this->get_pagenum(), $per_page ); |
313 } else { |
315 } else { |
314 $this->_display_rows( $posts ); |
316 $this->_display_rows( $posts, $level ); |
315 } |
317 } |
316 } |
318 } |
317 |
319 |
318 function _display_rows( $posts ) { |
320 function _display_rows( $posts, $level = 0 ) { |
319 global $post, $mode; |
321 global $mode; |
320 |
322 |
321 // Create array of post IDs. |
323 // Create array of post IDs. |
322 $post_ids = array(); |
324 $post_ids = array(); |
323 |
325 |
324 foreach ( $posts as $a_post ) |
326 foreach ( $posts as $a_post ) |
325 $post_ids[] = $a_post->ID; |
327 $post_ids[] = $a_post->ID; |
326 |
328 |
327 $this->comment_pending_count = get_pending_comments_num( $post_ids ); |
329 $this->comment_pending_count = get_pending_comments_num( $post_ids ); |
328 |
330 |
329 foreach ( $posts as $post ) |
331 foreach ( $posts as $post ) |
330 $this->single_row( $post ); |
332 $this->single_row( $post, $level ); |
331 } |
333 } |
332 |
334 |
333 function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) { |
335 function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) { |
334 global $wpdb; |
336 global $wpdb; |
335 |
337 |
456 } |
458 } |
457 |
459 |
458 unset( $children_pages[$parent] ); //required in order to keep track of orphans |
460 unset( $children_pages[$parent] ); //required in order to keep track of orphans |
459 } |
461 } |
460 |
462 |
461 function single_row( $a_post, $level = 0 ) { |
463 function single_row( $post, $level = 0 ) { |
462 global $post, $mode; |
464 global $mode; |
463 static $alternate; |
465 static $alternate; |
464 |
466 |
465 $global_post = $post; |
467 $global_post = get_post(); |
466 $post = $a_post; |
468 $GLOBALS['post'] = $post; |
467 setup_postdata( $post ); |
469 setup_postdata( $post ); |
468 |
470 |
469 $edit_link = get_edit_post_link( $post->ID ); |
471 $edit_link = get_edit_post_link( $post->ID ); |
470 $title = _draft_or_post_title(); |
472 $title = _draft_or_post_title(); |
471 $post_type_object = get_post_type_object( $post->post_type ); |
473 $post_type_object = get_post_type_object( $post->post_type ); |
502 |
509 |
503 if ( 0 == $level && (int) $post->post_parent > 0 ) { |
510 if ( 0 == $level && (int) $post->post_parent > 0 ) { |
504 //sent level 0 by accident, by default, or because we don't know the actual level |
511 //sent level 0 by accident, by default, or because we don't know the actual level |
505 $find_main_page = (int) $post->post_parent; |
512 $find_main_page = (int) $post->post_parent; |
506 while ( $find_main_page > 0 ) { |
513 while ( $find_main_page > 0 ) { |
507 $parent = get_page( $find_main_page ); |
514 $parent = get_post( $find_main_page ); |
508 |
515 |
509 if ( is_null( $parent ) ) |
516 if ( is_null( $parent ) ) |
510 break; |
517 break; |
511 |
518 |
512 $level++; |
519 $level++; |
522 <td <?php echo $attributes ?>><strong><?php if ( $can_edit_post && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states( $post ); echo isset( $parent_name ) ? ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name ) : ''; ?></strong> |
529 <td <?php echo $attributes ?>><strong><?php if ( $can_edit_post && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states( $post ); echo isset( $parent_name ) ? ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name ) : ''; ?></strong> |
523 <?php |
530 <?php |
524 } |
531 } |
525 else { |
532 else { |
526 $attributes = 'class="post-title page-title column-title"' . $style; |
533 $attributes = 'class="post-title page-title column-title"' . $style; |
|
534 |
|
535 $pad = str_repeat( '— ', $level ); |
527 ?> |
536 ?> |
528 <td <?php echo $attributes ?>><strong><?php if ( $can_edit_post && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ); ?>"><?php echo $title ?></a><?php } else { echo $title; }; _post_states( $post ); ?></strong> |
537 <td <?php echo $attributes ?>><strong><?php if ( $can_edit_post && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states( $post ); ?></strong> |
529 <?php |
538 <?php |
530 if ( 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) ) |
539 if ( 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) ) |
531 the_excerpt(); |
540 the_excerpt(); |
532 } |
541 } |
533 |
542 |
536 $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '" title="' . esc_attr( __( 'Edit this item' ) ) . '">' . __( 'Edit' ) . '</a>'; |
545 $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '" title="' . esc_attr( __( 'Edit this item' ) ) . '">' . __( 'Edit' ) . '</a>'; |
537 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr( __( 'Edit this item inline' ) ) . '">' . __( 'Quick Edit' ) . '</a>'; |
546 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr( __( 'Edit this item inline' ) ) . '">' . __( 'Quick Edit' ) . '</a>'; |
538 } |
547 } |
539 if ( current_user_can( $post_type_object->cap->delete_post, $post->ID ) ) { |
548 if ( current_user_can( $post_type_object->cap->delete_post, $post->ID ) ) { |
540 if ( 'trash' == $post->post_status ) |
549 if ( 'trash' == $post->post_status ) |
541 $actions['untrash'] = "<a title='" . esc_attr( __( 'Restore this item from the Trash' ) ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-' . $post->post_type . '_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>"; |
550 $actions['untrash'] = "<a title='" . esc_attr( __( 'Restore this item from the Trash' ) ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>"; |
542 elseif ( EMPTY_TRASH_DAYS ) |
551 elseif ( EMPTY_TRASH_DAYS ) |
543 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr( __( 'Move this item to the Trash' ) ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>"; |
552 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr( __( 'Move this item to the Trash' ) ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>"; |
544 if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS ) |
553 if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS ) |
545 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr( __( 'Delete this item permanently' ) ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>"; |
554 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr( __( 'Delete this item permanently' ) ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>"; |
546 } |
555 } |
559 get_inline_data( $post ); |
568 get_inline_data( $post ); |
560 echo '</td>'; |
569 echo '</td>'; |
561 break; |
570 break; |
562 |
571 |
563 case 'date': |
572 case 'date': |
564 if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) { |
573 if ( '0000-00-00 00:00:00' == $post->post_date ) { |
565 $t_time = $h_time = __( 'Unpublished' ); |
574 $t_time = $h_time = __( 'Unpublished' ); |
566 $time_diff = 0; |
575 $time_diff = 0; |
567 } else { |
576 } else { |
568 $t_time = get_the_time( __( 'Y/m/d g:i:s A' ) ); |
577 $t_time = get_the_time( __( 'Y/m/d g:i:s A' ) ); |
569 $m_time = $post->post_date; |
578 $m_time = $post->post_date; |
570 $time = get_post_time( 'G', true, $post ); |
579 $time = get_post_time( 'G', true, $post ); |
571 |
580 |
572 $time_diff = time() - $time; |
581 $time_diff = time() - $time; |
573 |
582 |
574 if ( $time_diff > 0 && $time_diff < 24*60*60 ) |
583 if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) |
575 $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); |
584 $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); |
576 else |
585 else |
577 $h_time = mysql2date( __( 'Y/m/d' ), $m_time ); |
586 $h_time = mysql2date( __( 'Y/m/d' ), $m_time ); |
578 } |
587 } |
579 |
588 |
594 _e( 'Last Modified' ); |
603 _e( 'Last Modified' ); |
595 } |
604 } |
596 echo '</td>'; |
605 echo '</td>'; |
597 break; |
606 break; |
598 |
607 |
599 case 'categories': |
|
600 ?> |
|
601 <td <?php echo $attributes ?>><?php |
|
602 $categories = get_the_category(); |
|
603 if ( !empty( $categories ) ) { |
|
604 $out = array(); |
|
605 foreach ( $categories as $c ) { |
|
606 $out[] = sprintf( '<a href="%s">%s</a>', |
|
607 esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'category_name' => $c->slug ), 'edit.php' ) ), |
|
608 esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'category', 'display' ) ) |
|
609 ); |
|
610 } |
|
611 /* translators: used between list items, there is a space after the comma */ |
|
612 echo join( __( ', ' ), $out ); |
|
613 } else { |
|
614 _e( 'Uncategorized' ); |
|
615 } |
|
616 ?></td> |
|
617 <?php |
|
618 break; |
|
619 |
|
620 case 'tags': |
|
621 ?> |
|
622 <td <?php echo $attributes ?>><?php |
|
623 $tags = get_the_tags( $post->ID ); |
|
624 if ( !empty( $tags ) ) { |
|
625 $out = array(); |
|
626 foreach ( $tags as $c ) { |
|
627 $out[] = sprintf( '<a href="%s">%s</a>', |
|
628 esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'tag' => $c->slug ), 'edit.php' ) ), |
|
629 esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'tag', 'display' ) ) |
|
630 ); |
|
631 } |
|
632 /* translators: used between list items, there is a space after the comma */ |
|
633 echo join( __( ', ' ), $out ); |
|
634 } else { |
|
635 _e( 'No Tags' ); |
|
636 } |
|
637 ?></td> |
|
638 <?php |
|
639 break; |
|
640 |
|
641 case 'comments': |
608 case 'comments': |
642 ?> |
609 ?> |
643 <td <?php echo $attributes ?>><div class="post-com-count-wrapper"> |
610 <td <?php echo $attributes ?>><div class="post-com-count-wrapper"> |
644 <?php |
611 <?php |
645 $pending_comments = isset( $this->comment_pending_count[$post->ID] ) ? $this->comment_pending_count[$post->ID] : 0; |
612 $pending_comments = isset( $this->comment_pending_count[$post->ID] ) ? $this->comment_pending_count[$post->ID] : 0; |
660 ?></td> |
627 ?></td> |
661 <?php |
628 <?php |
662 break; |
629 break; |
663 |
630 |
664 default: |
631 default: |
|
632 if ( 'categories' == $column_name ) |
|
633 $taxonomy = 'category'; |
|
634 elseif ( 'tags' == $column_name ) |
|
635 $taxonomy = 'post_tag'; |
|
636 elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) |
|
637 $taxonomy = substr( $column_name, 9 ); |
|
638 else |
|
639 $taxonomy = false; |
|
640 |
|
641 if ( $taxonomy ) { |
|
642 $taxonomy_object = get_taxonomy( $taxonomy ); |
|
643 echo '<td ' . $attributes . '>'; |
|
644 if ( $terms = get_the_terms( $post->ID, $taxonomy ) ) { |
|
645 $out = array(); |
|
646 foreach ( $terms as $t ) { |
|
647 $posts_in_term_qv = array(); |
|
648 if ( 'post' != $post->post_type ) |
|
649 $posts_in_term_qv['post_type'] = $post->post_type; |
|
650 if ( $taxonomy_object->query_var ) { |
|
651 $posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug; |
|
652 } else { |
|
653 $posts_in_term_qv['taxonomy'] = $taxonomy; |
|
654 $posts_in_term_qv['term'] = $t->slug; |
|
655 } |
|
656 |
|
657 $out[] = sprintf( '<a href="%s">%s</a>', |
|
658 esc_url( add_query_arg( $posts_in_term_qv, 'edit.php' ) ), |
|
659 esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ) |
|
660 ); |
|
661 } |
|
662 /* translators: used between list items, there is a space after the comma */ |
|
663 echo join( __( ', ' ), $out ); |
|
664 } else { |
|
665 echo '—'; |
|
666 } |
|
667 echo '</td>'; |
|
668 break; |
|
669 } |
665 ?> |
670 ?> |
666 <td <?php echo $attributes ?>><?php |
671 <td <?php echo $attributes ?>><?php |
667 if ( is_post_type_hierarchical( $post->post_type ) ) |
672 if ( is_post_type_hierarchical( $post->post_type ) ) |
668 do_action( 'manage_pages_custom_column', $column_name, $post->ID ); |
673 do_action( 'manage_pages_custom_column', $column_name, $post->ID ); |
669 else |
674 else |
670 do_action( 'manage_posts_custom_column', $column_name, $post->ID ); |
675 do_action( 'manage_posts_custom_column', $column_name, $post->ID ); |
671 do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID ); |
676 do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID ); |
672 ?></td> |
677 ?></td> |
673 <?php |
678 <?php |
674 break; |
679 break; |
675 } |
680 } |
676 } |
681 } |
677 ?> |
682 ?> |
678 </tr> |
683 </tr> |
679 <?php |
684 <?php |
680 $post = $global_post; |
685 $GLOBALS['post'] = $global_post; |
681 } |
686 } |
682 |
687 |
683 /** |
688 /** |
684 * Outputs the hidden row displayed when inline editing |
689 * Outputs the hidden row displayed when inline editing |
685 * |
690 * |
686 * @since 3.1.0 |
691 * @since 3.1.0 |
687 */ |
692 */ |
688 function inline_edit() { |
693 function inline_edit() { |
689 global $mode; |
694 global $mode; |
690 |
695 |
691 $screen = get_current_screen(); |
696 $screen = $this->screen; |
692 |
697 |
693 $post = get_default_post_to_edit( $screen->post_type ); |
698 $post = get_default_post_to_edit( $screen->post_type ); |
694 $post_type_object = get_post_type_object( $screen->post_type ); |
699 $post_type_object = get_post_type_object( $screen->post_type ); |
695 |
700 |
696 $taxonomy_names = get_object_taxonomies( $screen->post_type ); |
701 $taxonomy_names = get_object_taxonomies( $screen->post_type ); |
718 <?php |
723 <?php |
719 $hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page'; |
724 $hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page'; |
720 $bulk = 0; |
725 $bulk = 0; |
721 while ( $bulk < 2 ) { ?> |
726 while ( $bulk < 2 ) { ?> |
722 |
727 |
723 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-$screen->post_type "; |
728 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-" . $screen->post_type; |
724 echo $bulk ? "bulk-edit-row bulk-edit-row-$hclass bulk-edit-$screen->post_type" : "quick-edit-row quick-edit-row-$hclass inline-edit-$screen->post_type"; |
729 echo $bulk ? " bulk-edit-row bulk-edit-row-$hclass bulk-edit-{$screen->post_type}" : " quick-edit-row quick-edit-row-$hclass inline-edit-{$screen->post_type}"; |
725 ?>" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> |
730 ?>" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> |
726 |
731 |
727 <fieldset class="inline-edit-col-left"><div class="inline-edit-col"> |
732 <fieldset class="inline-edit-col-left"><div class="inline-edit-col"> |
728 <h4><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></h4> |
733 <h4><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></h4> |
729 <?php |
734 <?php |
750 endif; // post_type_supports title ?> |
755 endif; // post_type_supports title ?> |
751 |
756 |
752 <?php if ( !$bulk ) : ?> |
757 <?php if ( !$bulk ) : ?> |
753 <label><span class="title"><?php _e( 'Date' ); ?></span></label> |
758 <label><span class="title"><?php _e( 'Date' ); ?></span></label> |
754 <div class="inline-edit-date"> |
759 <div class="inline-edit-date"> |
755 <?php touch_time( 1, 1, 4, 1 ); ?> |
760 <?php touch_time( 1, 1, 0, 1 ); ?> |
756 </div> |
761 </div> |
757 <br class="clear" /> |
762 <br class="clear" /> |
758 <?php endif; // $bulk |
763 <?php endif; // $bulk |
759 |
764 |
760 if ( post_type_supports( $screen->post_type, 'author' ) ) : |
765 if ( post_type_supports( $screen->post_type, 'author' ) ) : |
1034 <?php if ( ! $bulk ) { |
1039 <?php if ( ! $bulk ) { |
1035 wp_nonce_field( 'inlineeditnonce', '_inline_edit', false ); |
1040 wp_nonce_field( 'inlineeditnonce', '_inline_edit', false ); |
1036 $update_text = __( 'Update' ); |
1041 $update_text = __( 'Update' ); |
1037 ?> |
1042 ?> |
1038 <a accesskey="s" href="#inline-edit" title="<?php esc_attr_e( 'Update' ); ?>" class="button-primary save alignright"><?php echo esc_attr( $update_text ); ?></a> |
1043 <a accesskey="s" href="#inline-edit" title="<?php esc_attr_e( 'Update' ); ?>" class="button-primary save alignright"><?php echo esc_attr( $update_text ); ?></a> |
1039 <img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /> |
1044 <span class="spinner"></span> |
1040 <?php } else { |
1045 <?php } else { |
1041 submit_button( __( 'Update' ), 'button-primary alignright', 'bulk_edit', false, array( 'accesskey' => 's' ) ); |
1046 submit_button( __( 'Update' ), 'button-primary alignright', 'bulk_edit', false, array( 'accesskey' => 's' ) ); |
1042 } ?> |
1047 } ?> |
1043 <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" /> |
1048 <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" /> |
1044 <input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" /> |
1049 <input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" /> |