X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/f6364df6999f38896cc58171ec4a503f4f2dedcf..8f374b7233bc2815ccc387e448d208c5434eb961:/wp-admin/includes/class-wp-posts-list-table.php diff --git a/wp-admin/includes/class-wp-posts-list-table.php b/wp-admin/includes/class-wp-posts-list-table.php index c1b4c344..613cff82 100644 --- a/wp-admin/includes/class-wp-posts-list-table.php +++ b/wp-admin/includes/class-wp-posts-list-table.php @@ -45,17 +45,10 @@ class WP_Posts_List_Table extends WP_List_Table { */ var $sticky_posts_count = 0; - function WP_Posts_List_Table() { - global $post_type_object, $post_type, $wpdb; - - if ( !isset( $_REQUEST['post_type'] ) ) - $post_type = 'post'; - elseif ( in_array( $_REQUEST['post_type'], get_post_types( array( 'show_ui' => true ) ) ) ) - $post_type = $_REQUEST['post_type']; - else - wp_die( __( 'Invalid post type' ) ); - $_REQUEST['post_type'] = $post_type; + function __construct() { + global $post_type_object, $wpdb; + $post_type = get_current_screen()->post_type; $post_type_object = get_post_type_object( $post_type ); if ( !current_user_can( $post_type_object->cap->edit_others_posts ) ) { @@ -74,7 +67,7 @@ class WP_Posts_List_Table extends WP_List_Table { $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 ) ); } - parent::WP_List_Table( array( + parent::__construct( array( 'plural' => 'posts', ) ); } @@ -86,7 +79,7 @@ class WP_Posts_List_Table extends WP_List_Table { } function prepare_items() { - global $post_type_object, $post_type, $avail_post_stati, $wp_query, $per_page, $mode; + global $post_type_object, $avail_post_stati, $wp_query, $per_page, $mode; $avail_post_stati = wp_edit_posts_query(); @@ -94,6 +87,7 @@ class WP_Posts_List_Table extends WP_List_Table { $total_items = $this->hierarchical_display ? $wp_query->post_count : $wp_query->found_posts; + $post_type = $post_type_object->name; $per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' ); $per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type ); @@ -127,7 +121,9 @@ class WP_Posts_List_Table extends WP_List_Table { } function get_views() { - global $post_type, $post_type_object, $locked_post_status, $avail_post_stati; + global $post_type_object, $locked_post_status, $avail_post_stati; + + $post_type = $post_type_object->name; if ( !empty($locked_post_status) ) return array(); @@ -202,15 +198,15 @@ class WP_Posts_List_Table extends WP_List_Table { } function extra_tablenav( $which ) { - global $post_type, $post_type_object, $cat; + global $post_type_object, $cat; ?>
months_dropdown( $post_type ); + $this->months_dropdown( $post_type_object->name ); - if ( is_object_in_taxonomy( $post_type, 'category' ) ) { + if ( is_object_in_taxonomy( $post_type_object->name, 'category' ) ) { $dropdown_options = array( 'show_option_all' => __( 'View all categories' ), 'hide_empty' => 0, @@ -281,7 +277,7 @@ class WP_Posts_List_Table extends WP_List_Table { $post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all'; if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) ) - $posts_columns['comments'] = '
' . esc_attr__( 'Comments' ) . '
'; + $posts_columns['comments'] = '' . esc_attr__( 'Comments' ) . ''; $posts_columns['date'] = __( 'Date' ); @@ -364,7 +360,7 @@ class WP_Posts_List_Table extends WP_List_Table { if ( $page->post_parent == $page->ID ) { $page->post_parent = 0; $wpdb->update( $wpdb->posts, array( 'post_parent' => 0 ), array( 'ID' => $page->ID ) ); - clean_page_cache( $page->ID ); + clean_post_cache( $page ); } if ( 0 == $page->post_parent ) @@ -463,23 +459,22 @@ class WP_Posts_List_Table extends WP_List_Table { } function single_row( $a_post, $level = 0 ) { - global $post, $current_screen, $mode; - static $rowclass; + global $post, $mode; + static $alternate; $global_post = $post; $post = $a_post; setup_postdata( $post ); - $rowclass = 'alternate' == $rowclass ? '' : 'alternate'; - $post_owner = ( get_current_user_id() == $post->post_author ? 'self' : 'other' ); $edit_link = get_edit_post_link( $post->ID ); $title = _draft_or_post_title(); $post_type_object = get_post_type_object( $post->post_type ); $can_edit_post = current_user_can( $post_type_object->cap->edit_post, $post->ID ); - $post_format = get_post_format( $post->ID ); - $post_format_class = ( $post_format && !is_wp_error($post_format) ) ? 'format-' . sanitize_html_class( $post_format ) : 'format-default'; + + $alternate = 'alternate' == $alternate ? '' : 'alternate'; + $classes = $alternate . ' iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' ); ?> - post_status . ' ' . $post_format_class); ?> iedit' valign="top"> + get_column_info(); @@ -532,9 +527,8 @@ class WP_Posts_List_Table extends WP_List_Table { ?> >post_status != 'trash' ) { ?> ID ) ) the_excerpt(); - } } $actions = array(); @@ -550,11 +544,13 @@ class WP_Posts_List_Table extends WP_List_Table { if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS ) $actions['delete'] = "" . __( 'Delete Permanently' ) . ""; } - if ( in_array( $post->post_status, array( 'pending', 'draft' ) ) ) { - if ( $can_edit_post ) - $actions['view'] = '' . __( 'Preview' ) . ''; - } elseif ( 'trash' != $post->post_status ) { - $actions['view'] = '' . __( 'View' ) . ''; + if ( $post_type_object->public ) { + if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) { + if ( $can_edit_post ) + $actions['view'] = '' . __( 'Preview' ) . ''; + } elseif ( 'trash' != $post->post_status ) { + $actions['view'] = '' . __( 'View' ) . ''; + } } $actions = apply_filters( is_post_type_hierarchical( $post->post_type ) ? 'page_row_actions' : 'post_row_actions', $actions, $post ); @@ -612,7 +608,8 @@ class WP_Posts_List_Table extends WP_List_Table { esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'category', 'display' ) ) ); } - echo join( ', ', $out ); + /* translators: used between list items, there is a space after the comma */ + echo join( __( ', ' ), $out ); } else { _e( 'Uncategorized' ); } @@ -632,7 +629,8 @@ class WP_Posts_List_Table extends WP_List_Table { esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'tag', 'display' ) ) ); } - echo join( ', ', $out ); + /* translators: used between list items, there is a space after the comma */ + echo join( __( ', ' ), $out ); } else { _e( 'No Tags' ); } @@ -837,14 +835,23 @@ class WP_Posts_List_Table extends WP_List_Table { post_type, 'author' ) && $bulk ) echo $authors_dropdown; - ?> - hierarchical ) : ?> + if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) : + if ( $post_type_object->hierarchical ) : + ?> - post_type, 'page-attributes' ) ) : + - + post_type ) : + ?> hierarchical ?> + endif; // page post_type + endif; // page-attributes + ?> - + cap->assign_terms ) ) : ?> + @@ -979,6 +993,31 @@ class WP_Posts_List_Table extends WP_List_Table {
+ post_type, 'post-formats' ) && current_theme_supports( 'post-formats' ) ) : + $post_formats = get_theme_support( 'post-formats' ); + if ( isset( $post_formats[0] ) && is_array( $post_formats[0] ) ) : + $all_post_formats = get_post_format_strings(); + unset( $all_post_formats['standard'] ); ?> +
+ +
+ + +

- + - + 's' ) ); } ?> +

@@ -1014,5 +1054,3 @@ class WP_Posts_List_Table extends WP_List_Table {