WordPress.org

Make WordPress Core

Ticket #47443: 47443.diff

File 47443.diff, 1.3 KB (added by derweili, 6 months ago)

Patch V1

  • src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

    diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
    index ee8af5b3ad..9301bed4e1 100644
    a b class WP_REST_Posts_Controller extends WP_REST_Controller { 
    11471147                                break;
    11481148                        case 'publish':
    11491149                        case 'future':
    1150                                 if ( ! current_user_can( $post_type->cap->publish_posts ) ) {
     1150                                if ( ! current_user_can( $post_type->cap->publish_posts ) && ! current_user_can( $post_type->cap->edit_published_posts ) ) {
    11511151                                        return new WP_Error( 'rest_cannot_publish', __( 'Sorry, you are not allowed to publish posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) );
    11521152                                }
    11531153                                break;
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    18171817
    18181818                $post_type = get_post_type_object( $post->post_type );
    18191819
    1820                 if ( 'attachment' !== $this->post_type && current_user_can( $post_type->cap->publish_posts ) ) {
     1820                if ( 'attachment' !== $this->post_type && ( ( 'publish' == $post->post_status && current_user_can( $post_type->cap->edit_published_posts ) ) || current_user_can( $post_type->cap->publish_posts ) ) ) {
    18211821                        $rels[] = 'https://api.w.org/action-publish';
    18221822                }
    18231823