true ) ) ) ) $post_type = $_REQUEST['post_type']; else wp_die( __( 'Invalid post type' ) ); $_REQUEST['post_type'] = $post_type; $post_type_object = get_post_type_object( $post_type ); if ( !current_user_can( $post_type_object->cap->edit_others_posts ) ) { $this->user_posts_count = $wpdb->get_var( $wpdb->prepare( " SELECT COUNT( 1 ) FROM $wpdb->posts WHERE post_type = %s AND post_status NOT IN ( 'trash', 'auto-draft' ) AND post_author = %d ", $post_type, get_current_user_id() ) ); if ( $this->user_posts_count && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) ) $_GET['author'] = get_current_user_id(); } if ( $sticky_posts = get_option( 'sticky_posts' ) ) { $sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) ); $this->sticky_posts_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( 1 ) FROM $wpdb->posts WHERE post_type = %s AND ID IN ($sticky_posts)", $post_type ) ); } parent::WP_List_Table( array( 'screen' => $current_screen, 'plural' => 'posts', ) ); } function check_permissions() { global $post_type_object; if ( !current_user_can( $post_type_object->cap->edit_posts ) ) wp_die( __( 'Cheatin’ uh?' ) ); } function prepare_items() { global $post_type_object, $post_type, $avail_post_stati, $wp_query, $per_page, $mode; $avail_post_stati = wp_edit_posts_query(); $this->hierarchical_display = ( $post_type_object->hierarchical && 'menu_order title' == $wp_query->query['orderby'] ); $total_items = $this->hierarchical_display ? $wp_query->post_count : $wp_query->found_posts; $per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' ); $per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type ); if ( $this->hierarchical_display ) $total_pages = ceil( $total_items / $per_page ); else $total_pages = $wp_query->max_num_pages; $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; $this->is_trash = isset( $_REQUEST['post_status'] ) && $_REQUEST['post_status'] == 'trash'; $this->set_pagination_args( array( 'total_items' => $total_items, 'total_pages' => $total_pages, 'per_page' => $per_page ) ); } function has_items() { return have_posts(); } function no_items() { global $post_type_object; if ( isset( $_REQUEST['post_status'] ) && 'trash' == $_REQUEST['post_status'] ) echo $post_type_object->labels->not_found_in_trash; else echo $post_type_object->labels->not_found; } function get_views() { global $post_type, $post_type_object, $locked_post_status, $avail_post_stati; if ( !empty($locked_post_status) ) return array(); $status_links = array(); $num_posts = wp_count_posts( $post_type, 'readable' ); $class = ''; $allposts = ''; $current_user_id = get_current_user_id(); if ( $this->user_posts_count ) { if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user_id ) ) $class = ' class="current"'; $status_links['mine'] = "