| @@ 711-723 (lines=13) @@ | ||
| 708 | * |
|
| 709 | * @return bool Whether user has capability 'manage_options' or a blog token is used. |
|
| 710 | */ |
|
| 711 | public static function verify_default_permissions() { |
|
| 712 | if ( current_user_can( 'manage_options' ) ) { // TODO || check for valid blog token. |
|
| 713 | return true; |
|
| 714 | } |
|
| 715 | ||
| 716 | $error_msg = esc_html__( |
|
| 717 | 'You do not have the correct user permissions to perform this action. |
|
| 718 | Please contact your site admin if you think this is a mistake.', |
|
| 719 | 'jetpack' |
|
| 720 | ); |
|
| 721 | ||
| 722 | return new WP_Error( 'invalid_user_permission_sync', $error_msg, array( 'status' => rest_authorization_required_code() ) ); |
|
| 723 | } |
|
| 724 | ||
| 725 | /** |
|
| 726 | * Validate Queue name. |
|
| @@ 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. |
|