From 455462be392953fb56961257d5bb6441d11dfb20 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Fri, 14 Nov 2008 17:13:08 +0000 Subject: [PATCH] Handle both post and page caps in get_editable_user_id(). Props DD32. fixes #8208 git-svn-id: https://develop.svn.wordpress.org/trunk@9683 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/edit-page-form.php | 4 ++-- wp-admin/includes/user.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/wp-admin/edit-page-form.php b/wp-admin/edit-page-form.php index 81145f5f32..3ba05c4e94 100644 --- a/wp-admin/edit-page-form.php +++ b/wp-admin/edit-page-form.php @@ -356,7 +356,7 @@ function page_slug_meta_box($post){ } add_meta_box('pageslugdiv', __('Page Slug'), 'page_slug_meta_box', 'page', 'normal', 'core'); -$authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM +$authors = get_editable_user_ids( $current_user->id, true, 'page' ); // TODO: ROLE SYSTEM if ( $post->post_author && !in_array($post->post_author, $authors) ) $authors[] = $post->post_author; if ( $authors && count( $authors ) > 1 ) { @@ -369,7 +369,7 @@ if ( $authors && count( $authors ) > 1 ) { */ function page_author_meta_box($post){ global $current_user, $user_ID; - $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM + $authors = get_editable_user_ids( $current_user->id, true, 'page' ); // TODO: ROLE SYSTEM if ( $post->post_author && !in_array($post->post_author, $authors) ) $authors[] = $post->post_author; ?> diff --git a/wp-admin/includes/user.php b/wp-admin/includes/user.php index c7b6f6b173..6a89cb9806 100644 --- a/wp-admin/includes/user.php +++ b/wp-admin/includes/user.php @@ -220,13 +220,13 @@ function get_editable_authors( $user_id ) { * @param bool $exclude_zeros Optional, default is true. Whether to exclude zeros. * @return unknown */ -function get_editable_user_ids( $user_id, $exclude_zeros = true ) { +function get_editable_user_ids( $user_id, $exclude_zeros = true, $post_type = 'post' ) { global $wpdb; $user = new WP_User( $user_id ); - if ( ! $user->has_cap('edit_others_posts') ) { - if ( $user->has_cap('edit_posts') || $exclude_zeros == false ) + if ( ! $user->has_cap("edit_others_{$post_type}s") ) { + if ( $user->has_cap("edit_{$post_type}s") || $exclude_zeros == false ) return array($user->id); else return false;