Changeset 21914 for trunk/wp-admin/includes/class-wp-posts-list-table.php
- Timestamp:
- 09/19/2012 12:43:31 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/class-wp-posts-list-table.php
r21806 r21914 46 46 var $sticky_posts_count = 0; 47 47 48 function __construct( ) {48 function __construct( $args = array() ) { 49 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 57 $post_type_object = get_post_type_object( $post_type ); 53 58 … … 67 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 76 function ajax_user_can() { 76 global $post_type_object; 77 78 return current_user_can( $post_type_object->cap->edit_posts ); 77 return current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_posts ); 79 78 } 80 79 81 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 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 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 90 $per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' ); 92 91 $per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type ); … … 113 112 114 113 function no_items() { 115 global $post_type_object;116 117 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 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 120 function get_views() { 124 global $ post_type_object, $locked_post_status, $avail_post_stati;125 126 $post_type = $ post_type_object->name;121 global $locked_post_status, $avail_post_stati; 122 123 $post_type = $this->screen->post_type; 127 124 128 125 if ( !empty($locked_post_status) ) … … 199 196 200 197 function extra_tablenav( $which ) { 201 global $ post_type_object, $cat;198 global $cat; 202 199 ?> 203 200 <div class="alignleft actions"> … … 205 202 if ( 'top' == $which && !is_singular() ) { 206 203 207 $this->months_dropdown( $ post_type_object->name );208 209 if ( is_object_in_taxonomy( $ post_type_object->name, 'category' ) ) {204 $this->months_dropdown( $this->screen->post_type ); 205 206 if ( is_object_in_taxonomy( $this->screen->post_type, 'category' ) ) { 210 207 $dropdown_options = array( 211 208 'show_option_all' => __( 'View all categories' ), … … 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 222 submit_button( __( 'Empty Trash' ), 'small apply', 'delete_all', false ); 226 223 } … … 238 235 239 236 function pagination( $which ) { 240 global $ post_type_object, $mode;237 global $mode; 241 238 242 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 242 $this->view_switcher( $mode ); 246 243 } 247 244 248 245 function get_table_classes() { 249 global $post_type_object; 250 251 return array( 'widefat', 'fixed', $post_type_object->hierarchical ? 'pages' : 'posts' ); 246 return array( 'widefat', 'fixed', is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' ); 252 247 } 253 248 254 249 function get_columns() { 255 $screen = get_current_screen(); 256 257 if ( empty( $screen ) ) 258 $post_type = 'post'; 259 else 260 $post_type = $screen->post_type; 250 $post_type = $this->screen->post_type; 261 251 262 252 $posts_columns = array(); … … 314 304 315 305 function display_rows( $posts = array(), $level = 0 ) { 316 global $wp_query, $p ost_type_object, $per_page;306 global $wp_query, $per_page; 317 307 318 308 if ( empty( $posts ) ) … … 702 692 global $mode; 703 693 704 $screen = get_current_screen();694 $screen = $this->screen; 705 695 706 696 $post = get_default_post_to_edit( $screen->post_type ); … … 734 724 while ( $bulk < 2 ) { ?> 735 725 736 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit- $screen->post_type ";737 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";726 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-" . $screen->post_type; 727 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}"; 738 728 ?>" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> 739 729
Note: See TracChangeset
for help on using the changeset viewer.