WordPress.org

Make WordPress Core

Ticket #18429: wp.newPost3.patch

File wp.newPost3.patch, 3.2 KB (added by nprasath002, 6 years ago)
  • class-wp-xmlrpc-server.php

    # This patch file was generated by NetBeans IDE
    # Following Index: paths are relative to: C:\xampp\htdocs\wordtrunk\wp-includes
    # This patch can be applied using context Tools: Patch action on respective folder.
    # It uses platform neutral UTF-8 encoding and \n newlines.
    # Above lines and this line are ignored by the patching process.
     
    621621                if( ! ( (bool) $post_type ) )
    622622                        return new IXR_Error( 403, __( 'Invalid post type' ) );
    623623
     624                $update = false;
     625                if ( !empty( $post_data['ID'] ) )
     626                        $update = true;
     627                if( $update ) {
     628
     629                        if( ! current_user_can( $post_type->cap->edit_post, $post_data['ID'] ) )
     630                                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
     631
     632                        switch ( $post_data['post_status'] ) {
     633                                case 'draft':
     634                                case 'pending':
     635                                        break;
     636                                case 'private':
     637                                        if( ! current_user_can( $post_type->cap->publish_post, $post_data['ID'] ) )
     638                                                return new IXR_Error( 401, __( 'Sorry, you are not allowed set this post as private.' ));
     639                                        break;
     640                                case 'publish':
     641                                case 'future':
     642                                        if( ! current_user_can( $post_type->cap->publish_post, $post_data['ID'] ) )
     643                                                return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ));
     644                                        break;
     645                                default:
     646                                        $post_data['post_status'] = 'draft';
     647                                break;
     648                        }
     649
     650                        if ( ! empty( $post_data['post_password'] ) && ! current_user_can( $post_type->cap->publish_post, $post_data['ID'] ) )
     651                                return new IXR_Error( 401, __( 'Sorry, you are not allowed to set password to this post' ) );
     652
     653                } else {
     654
    624655                if( ! current_user_can( $post_type->cap->edit_posts ) )
    625                         return new IXR_Error( 401, __( 'Sorry, you are not allowed to post on this site.' ) );
     656                                return new IXR_Error( 401, __( 'Sorry, you are not allowed to post in this post type.' ) );
    626657
    627658                switch ( $post_data['post_status'] ) {
    628659                        case 'draft':
     
    645676                if ( ! empty( $post_data['post_password'] ) && ! current_user_can( $post_type->cap->publish_posts ) )
    646677                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to create password protected posts in this post type' ) );
    647678
     679                }
    648680
    649681                $post_data['post_author'] = absint( $post_data['post_author'] );
    650682                if( ! empty( $post_data['post_author'] ) && $post_data['post_author'] != $user->ID ) {