WordPress.org

Make WordPress Core

Ticket #12498: 12498.diff

File 12498.diff, 955 bytes (added by scribu, 4 years ago)

fix wp_write_post() cap check

  • wp-admin/includes/post.php

     
    482482function wp_write_post() { 
    483483        global $user_ID; 
    484484 
    485         if ( isset( $_POST['post_type'] ) && 'page' == $_POST['post_type'] ) { 
    486                 if ( !current_user_can( 'edit_pages' ) ) 
    487                         return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this blog.' ) ); 
     485        if ( isset( $_POST['post_type'] ) ) { 
     486                $post_type_obj = get_post_type_object($_POST['post_type']); 
     487                if ( !current_user_can($post_type_obj->edit_type_cap) ) 
     488                        return new WP_Error( $post_type_obj->edit_type_cap, sprintf(__( 'You are not allowed to create %s on this blog.'), $post_type_obj->label) ); 
    488489        } else { 
    489490                if ( !current_user_can( 'edit_posts' ) ) 
    490491                        return new WP_Error( 'edit_posts', __( 'You are not allowed to create posts or drafts on this blog.' ) );