mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-16 23:00:21 +00:00
Use the create_posts post type cap in more places. Remove the janky create_posts meta cap. see #16714.
git-svn-id: https://develop.svn.wordpress.org/trunk@22908 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -363,13 +363,16 @@ function wp_admin_bar_my_sites_menu( $wp_admin_bar ) {
|
||||
'href' => admin_url(),
|
||||
) );
|
||||
|
||||
if ( current_user_can( 'edit_posts' ) ) {
|
||||
if ( current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) {
|
||||
$wp_admin_bar->add_menu( array(
|
||||
'parent' => $menu_id,
|
||||
'id' => $menu_id . '-n',
|
||||
'title' => __( 'New Post' ),
|
||||
'href' => admin_url( 'post-new.php' ),
|
||||
) );
|
||||
}
|
||||
|
||||
if ( current_user_can( 'edit_posts' ) ) {
|
||||
$wp_admin_bar->add_menu( array(
|
||||
'parent' => $menu_id,
|
||||
'id' => $menu_id . '-c',
|
||||
|
||||
@@ -1060,14 +1060,6 @@ function map_meta_cap( $cap, $user_id ) {
|
||||
$caps[] = $post_type->cap->delete_private_posts;
|
||||
}
|
||||
break;
|
||||
// current_user_can( 'create_posts', $post_type )
|
||||
case 'create_posts':
|
||||
$post_type = isset( $args[0] ) ? $args[0] : 'post';
|
||||
$post_type_object = get_post_type_object( $post_type );
|
||||
|
||||
$caps[] = $post_type_object->cap->create_posts;
|
||||
|
||||
break;
|
||||
// edit_post breaks down to edit_posts, edit_published_posts, or
|
||||
// edit_others_posts
|
||||
case 'edit_post':
|
||||
|
||||
@@ -1016,7 +1016,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
if ( $post_data['post_type'] != get_post_type( $post_data['ID'] ) )
|
||||
return new IXR_Error( 401, __( 'The post type may not be changed.' ) );
|
||||
} else {
|
||||
if ( ! current_user_can( $post_type->cap->edit_posts ) )
|
||||
if ( ! current_user_can( $post_type->cap->create_posts ) || ! current_user_can( $post_type->cap->edit_posts ) )
|
||||
return new IXR_Error( 401, __( 'Sorry, you are not allowed to post on this site.' ) );
|
||||
}
|
||||
|
||||
@@ -3928,7 +3928,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
do_action('xmlrpc_call', 'blogger.newPost');
|
||||
|
||||
$cap = ($publish) ? 'publish_posts' : 'edit_posts';
|
||||
if ( !current_user_can($cap) )
|
||||
if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || !current_user_can($cap) )
|
||||
return new IXR_Error(401, __('Sorry, you are not allowed to post on this site.'));
|
||||
|
||||
$post_status = ($publish) ? 'publish' : 'draft';
|
||||
@@ -4143,6 +4143,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
$post_type = 'post';
|
||||
}
|
||||
|
||||
if ( ! current_user_can( get_post_type_object( $post_type )->cap->create_posts ) )
|
||||
return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish posts on this site.' ) );
|
||||
if ( !current_user_can( $cap ) )
|
||||
return new IXR_Error( 401, $error_message );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user