From f38013229b9f4cdaae3d771edd27f73246b6f7ec Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Sun, 20 Sep 2015 17:28:24 +0000 Subject: [PATCH] Implement a 'Mine' link on post listing screens in the admin area for all users who have authored posts. This feature was previously only available to users who cannot edit other users' posts (namely Authors and Contributors). Props linuxologos, wonderboymusic Fixes #19609 Built from https://develop.svn.wordpress.org/trunk@34360 git-svn-id: http://core.svn.wordpress.org/trunk@34324 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../includes/class-wp-posts-list-table.php | 30 +++++++++++-------- wp-includes/version.php | 2 +- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/wp-admin/includes/class-wp-posts-list-table.php b/wp-admin/includes/class-wp-posts-list-table.php index 594df3d19f..0cb125527b 100644 --- a/wp-admin/includes/class-wp-posts-list-table.php +++ b/wp-admin/includes/class-wp-posts-list-table.php @@ -77,19 +77,21 @@ class WP_Posts_List_Table extends WP_List_Table { 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, ) ); - $post_type = $this->screen->post_type; + $post_type = $this->screen->post_type; $post_type_object = get_post_type_object( $post_type ); + $exclude_states = get_post_stati( array( + 'show_in_admin_all_list' => false, + ) ); + $this->user_posts_count = $wpdb->get_var( $wpdb->prepare( " + SELECT COUNT( 1 ) + FROM $wpdb->posts + WHERE post_type = %s + AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' ) + AND post_author = %d + ", $post_type, get_current_user_id() ) ); - if ( !current_user_can( $post_type_object->cap->edit_others_posts ) ) { - $exclude_states = get_post_stati( array( 'show_in_admin_all_list' => false ) ); - $this->user_posts_count = $wpdb->get_var( $wpdb->prepare( " - SELECT COUNT( 1 ) FROM $wpdb->posts - WHERE post_type = %s AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' ) - 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 ( $this->user_posts_count && ! current_user_can( $post_type_object->cap->edit_others_posts ) && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) ) { + $_GET['author'] = get_current_user_id(); } if ( 'post' == $post_type && $sticky_posts = get_option( 'sticky_posts' ) ) { @@ -262,6 +264,7 @@ class WP_Posts_List_Table extends WP_List_Table { $current_user_id = get_current_user_id(); $all_args = array( 'post_type' => $post_type ); + $mine = ''; if ( $this->user_posts_count ) { if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user_id ) ) { @@ -283,7 +286,7 @@ class WP_Posts_List_Table extends WP_List_Table { number_format_i18n( $this->user_posts_count ) ); - $status_links['mine'] = $this->get_edit_link( $mine_args, $mine_inner_html, $class ); + $mine = $this->get_edit_link( $mine_args, $mine_inner_html, $class ); $all_args['all_posts'] = 1; $class = ''; @@ -310,6 +313,9 @@ class WP_Posts_List_Table extends WP_List_Table { ); $status_links['all'] = $this->get_edit_link( $all_args, $all_inner_html, $class ); + if ( $mine ) { + $status_links['mine'] = $mine; + } foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) { $class = ''; diff --git a/wp-includes/version.php b/wp-includes/version.php index 49e311a00c..1467f5d827 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-34359'; +$wp_version = '4.4-alpha-34360'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.