Make WordPress Core


Ignore:
Timestamp:
06/29/2016 03:15:40 PM (8 years ago)
Author:
ocean90
Message:

Text Changes: Unify permission error messages.

The new format looks like "Sorry, you are not allowed to <action>.". This provides a consistent experience for all error messages related to missing permissions. It also reduces the number of similar strings and allows translators to provide a consistent style in their language.

Props ramiy, Presskopp.
Fixes #34521.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-xmlrpc-server.php

    r37890 r37914  
    13411341        if ( ! empty( $post_data['post_author'] ) && $post_data['post_author'] != $user->ID ) {
    13421342            if ( ! current_user_can( $post_type->cap->edit_others_posts ) )
    1343                 return new IXR_Error( 401, __( 'You are not allowed to create posts as this user.' ) );
     1343                return new IXR_Error( 401, __( 'Sorry, you are not allowed to create posts as this user.' ) );
    13441344
    13451345            $author = get_userdata( $post_data['post_author'] );
     
    16351635
    16361636        if ( ! current_user_can( 'delete_post', $post_id ) ) {
    1637             return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete this post.' ) );
     1637            return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) );
    16381638        }
    16391639
     
    17931793
    17941794        if ( ! current_user_can( $post_type->cap->edit_posts ) )
    1795             return new IXR_Error( 401, __( 'You are not allowed to edit posts in this post type.' ));
     1795            return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts in this post type.' ));
    17961796
    17971797        $query['post_type'] = $post_type->name;
     
    18761876
    18771877        if ( ! current_user_can( $taxonomy->cap->manage_terms ) )
    1878             return new IXR_Error( 401, __( 'You are not allowed to create terms in this taxonomy.' ) );
     1878            return new IXR_Error( 401, __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) );
    18791879
    18801880        $taxonomy = (array) $taxonomy;
     
    19631963
    19641964        if ( ! current_user_can( $taxonomy->cap->edit_terms ) )
    1965             return new IXR_Error( 401, __( 'You are not allowed to edit terms in this taxonomy.' ) );
     1965            return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit terms in this taxonomy.' ) );
    19661966
    19671967        $taxonomy = (array) $taxonomy;
     
    20592059
    20602060        if ( ! current_user_can( $taxonomy->cap->delete_terms ) )
    2061             return new IXR_Error( 401, __( 'You are not allowed to delete terms in this taxonomy.' ) );
     2061            return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete terms in this taxonomy.' ) );
    20622062
    20632063        $term = get_term( $term_id, $taxonomy->name );
     
    21302130
    21312131        if ( ! current_user_can( $taxonomy->cap->assign_terms ) )
    2132             return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) );
     2132            return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) );
    21332133
    21342134        $term = get_term( $term_id , $taxonomy->name, ARRAY_A );
     
    21882188
    21892189        if ( ! current_user_can( $taxonomy->cap->assign_terms ) )
    2190             return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) );
     2190            return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) );
    21912191
    21922192        $query = array();
     
    22832283
    22842284        if ( ! current_user_can( $taxonomy->cap->assign_terms ) )
    2285             return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) );
     2285            return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) );
    22862286
    22872287        return $this->_prepare_taxonomy( $taxonomy, $fields );
     
    24712471
    24722472        if ( ! current_user_can( 'list_users' ) )
    2473             return new IXR_Error( 401, __( 'You are not allowed to browse users.' ) );
     2473            return new IXR_Error( 401, __( 'Sorry, you are not allowed to browse users.' ) );
    24742474
    24752475        $query = array( 'fields' => 'all_with_meta' );
     
    27952795        // Make sure the user can delete pages.
    27962796        if ( !current_user_can('delete_page', $page_id) )
    2797             return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete this page.' ) );
     2797            return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this page.' ) );
    27982798
    27992799        // Attempt to delete the page.
     
    28572857        // Make sure the user is allowed to edit pages.
    28582858        if ( !current_user_can('edit_page', $page_id) )
    2859             return new IXR_Error( 401, __( 'Sorry, you do not have the right to edit this page.' ) );
     2859            return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) );
    28602860
    28612861        // Mark this as content for a page.
     
    30543054        // Make sure the user is allowed to add a category.
    30553055        if ( !current_user_can('manage_categories') )
    3056             return new IXR_Error(401, __('Sorry, you do not have the right to add a category.'));
     3056            return new IXR_Error(401, __('Sorry, you are not allowed to add a category.'));
    30573057
    30583058        // If no slug was provided make it empty so that
     
    31293129
    31303130        if ( !current_user_can('manage_categories') )
    3131             return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete a category.' ) );
     3131            return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete a category.' ) );
    31323132
    31333133        $status = wp_delete_term( $category_id, 'category' );
     
    32273227
    32283228        if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
    3229             return new IXR_Error( 403, __( 'You are not allowed to moderate or edit this comment.' ) );
     3229            return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) );
    32303230        }
    32313231
     
    33593359
    33603360        if ( !current_user_can( 'edit_comment', $comment_ID ) ) {
    3361             return new IXR_Error( 403, __( 'You are not allowed to moderate or edit this comment.' ) );
     3361            return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) );
    33623362        }
    33633363
     
    34263426
    34273427        if ( ! current_user_can( 'edit_comment', $comment_ID ) ) {
    3428             return new IXR_Error( 403, __( 'You are not allowed to moderate or edit this comment.' ) );
     3428            return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) );
    34293429        }
    34303430
     
    36303630
    36313631        if ( ! current_user_can( 'publish_posts' ) ) {
    3632             return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) );
     3632            return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) );
    36333633        }
    36343634
     
    36713671
    36723672        if ( ! current_user_can( 'edit_post', $post_id ) ) {
    3673             return new IXR_Error( 403, __( 'You are not allowed access to details of this post.' ) );
     3673            return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details of this post.' ) );
    36743674        }
    36753675
     
    37113711
    37123712        if ( !current_user_can( 'edit_posts' ) )
    3713             return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) );
     3713            return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) );
    37143714
    37153715        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
     
    37433743
    37443744        if ( !current_user_can( 'edit_pages' ) )
    3745             return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) );
     3745            return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) );
    37463746
    37473747        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
     
    37753775
    37763776        if ( !current_user_can( 'edit_pages' ) )
    3777             return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) );
     3777            return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) );
    37783778
    37793779        $templates = get_page_templates();
     
    38693869
    38703870        if ( !current_user_can( 'manage_options' ) )
    3871             return new IXR_Error( 403, __( 'You are not allowed to update options.' ) );
     3871            return new IXR_Error( 403, __( 'Sorry, you are not allowed to update options.' ) );
    38723872
    38733873        $option_names = array();
     
    39213921
    39223922        if ( !current_user_can( 'upload_files' ) )
    3923             return new IXR_Error( 403, __( 'You do not have permission to upload files.' ) );
     3923            return new IXR_Error( 403, __( 'Sorry, you are not allowed to upload files.' ) );
    39243924
    39253925        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
     
    39693969
    39703970        if ( !current_user_can( 'upload_files' ) )
    3971             return new IXR_Error( 401, __( 'You do not have permission to upload files.' ) );
     3971            return new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) );
    39723972
    39733973        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
     
    40134013
    40144014        if ( !current_user_can( 'edit_posts' ) )
    4015             return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) );
     4015            return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) );
    40164016
    40174017        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
     
    46834683
    46844684        if ( ! current_user_can( 'edit_post', $post_ID ) ) {
    4685             return new IXR_Error(401, __('Sorry, you do not have the right to edit this post.'));
     4685            return new IXR_Error(401, __('Sorry, you are not allowed to edit this post.'));
    46864686        }
    46874687        if ( 'publish' == $actual_post['post_status'] && ! current_user_can( 'publish_posts' ) ) {
    4688             return new IXR_Error( 401, __( 'Sorry, you do not have the right to publish this post.' ) );
     4688            return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) );
    46894689        }
    46904690
     
    47534753
    47544754        if ( ! current_user_can( 'delete_post', $post_ID ) ) {
    4755             return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete this post.' ) );
     4755            return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) );
    47564756        }
    47574757
     
    49064906                case "post":
    49074907                    if ( !current_user_can( 'edit_others_posts' ) )
    4908                         return new IXR_Error( 401, __( 'You are not allowed to create posts as this user.' ) );
     4908                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to create posts as this user.' ) );
    49094909                    break;
    49104910                case "page":
    49114911                    if ( !current_user_can( 'edit_others_pages' ) )
    4912                         return new IXR_Error( 401, __( 'You are not allowed to create pages as this user.' ) );
     4912                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to create pages as this user.' ) );
    49134913                    break;
    49144914                default:
     
    51875187
    51885188        if ( ! current_user_can( 'edit_post', $post_ID ) )
    5189             return new IXR_Error( 401, __( 'Sorry, you do not have the right to edit this post.' ) );
     5189            return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
    51905190
    51915191        // Use wp.editPost to edit post types other than post and page.
     
    52465246                    case 'post':
    52475247                        if ( ! current_user_can( 'edit_others_posts' ) ) {
    5248                             return new IXR_Error( 401, __( 'You are not allowed to change the post author as this user.' ) );
     5248                            return new IXR_Error( 401, __( 'Sorry, you are not allowed to change the post author as this user.' ) );
    52495249                        }
    52505250                        break;
    52515251                    case 'page':
    52525252                        if ( ! current_user_can( 'edit_others_pages' ) ) {
    5253                             return new IXR_Error( 401, __( 'You are not allowed to change the page author as this user.' ) );
     5253                            return new IXR_Error( 401, __( 'Sorry, you are not allowed to change the page author as this user.' ) );
    52545254                        }
    52555255                        break;
     
    53585358        if ( 'publish' == $post_status || 'private' == $post_status ) {
    53595359            if ( 'page' == $post_type && ! current_user_can( 'publish_pages' ) ) {
    5360                 return new IXR_Error( 401, __( 'Sorry, you do not have the right to publish this page.' ) );
     5360                return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this page.' ) );
    53615361            } elseif ( ! current_user_can( 'publish_posts' ) ) {
    5362                 return new IXR_Error( 401, __( 'Sorry, you do not have the right to publish this post.' ) );
     5362                return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) );
    53635363            }
    53645364        }
     
    57915791
    57925792        if ( !current_user_can('upload_files') ) {
    5793             $this->error = new IXR_Error( 401, __( 'You do not have permission to upload files.' ) );
     5793            $this->error = new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) );
    57945794            return $this->error;
    57955795        }
Note: See TracChangeset for help on using the changeset viewer.