| @@ 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. |
|
| @@ 138-149 (lines=12) @@ | ||
| 135 | * |
|
| 136 | * @return bool Whether user has capability 'jetpack_disconnect'. |
|
| 137 | */ |
|
| 138 | public static function identity_crisis_mitigation_permission_check() { |
|
| 139 | if ( current_user_can( 'jetpack_disconnect' ) ) { |
|
| 140 | return true; |
|
| 141 | } |
|
| 142 | $error_msg = esc_html__( |
|
| 143 | 'You do not have the correct user permissions to perform this action. |
|
| 144 | Please contact your site admin if you think this is a mistake.', |
|
| 145 | 'jetpack' |
|
| 146 | ); |
|
| 147 | ||
| 148 | return new WP_Error( 'invalid_user_permission_identity_crisis', $error_msg, array( 'status' => rest_authorization_required_code() ) ); |
|
| 149 | } |
|
| 150 | ||
| 151 | } |
|
| 152 | ||