| @@ 59-69 (lines=11) @@ | ||
| 56 | * @param WP_REST_Request $request Full details about the request. |
|
| 57 | * @return true|WP_Error True if the request has read access for the item, WP_Error object otherwise. |
|
| 58 | */ |
|
| 59 | public function get_item_permissions_check( $request ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter, VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
|
| 60 | if ( ! current_user_can( 'read' ) ) { |
|
| 61 | return new WP_Error( |
|
| 62 | 'rest_forbidden', |
|
| 63 | __( 'Sorry, you are not allowed to view menus on this site.', 'jetpack' ), |
|
| 64 | array( 'status' => rest_authorization_required_code() ) |
|
| 65 | ); |
|
| 66 | } |
|
| 67 | ||
| 68 | return true; |
|
| 69 | } |
|
| 70 | ||
| 71 | /** |
|
| 72 | * Retrieves the admin menu. |
|
| @@ 69-81 (lines=13) @@ | ||
| 66 | * @param WP_REST_Request $request Full details about the request. |
|
| 67 | * @return true|WP_Error True if the request has read access for the item, WP_Error object otherwise. |
|
| 68 | */ |
|
| 69 | public function get_option_permissions_check( $request ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter, VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
|
| 70 | ||
| 71 | // https://wordpress.org/support/article/roles-and-capabilities/#read |
|
| 72 | if ( ! current_user_can( 'read' ) ) { |
|
| 73 | return new WP_Error( |
|
| 74 | 'rest_forbidden', |
|
| 75 | __( 'Sorry, you are not allowed to read user options on this site.', 'jetpack' ), |
|
| 76 | array( 'status' => rest_authorization_required_code() ) |
|
| 77 | ); |
|
| 78 | } |
|
| 79 | ||
| 80 | return true; |
|
| 81 | } |
|
| 82 | ||
| 83 | ||
| 84 | ||