Automattic /
jetpack
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | /* |
||
| 4 | * Plugin Name: Feedback CPT Permissions over-ride |
||
| 5 | */ |
||
| 6 | |||
| 7 | if ( class_exists( 'WP_REST_Posts_Controller' ) ) { |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Class Grunion_Contact_Form_Endpoint |
||
| 11 | * Used as 'rest_controller_class' parameter when 'feedback' post type is registered in modules/contact-form/grunion-contact-form.php. |
||
| 12 | */ |
||
| 13 | class Grunion_Contact_Form_Endpoint extends WP_REST_Posts_Controller { |
||
| 14 | /** |
||
| 15 | * Check whether a given request has proper authorization to view feedback items. |
||
| 16 | * |
||
| 17 | * @param WP_REST_Request $request Full details about the request. |
||
| 18 | * @return WP_Error|boolean |
||
| 19 | */ |
||
| 20 | View Code Duplication | public function get_items_permissions_check( $request ) { |
|
| 21 | if ( ! is_user_member_of_blog( get_current_user_id(), get_current_blog_id() ) ) { |
||
| 22 | return new WP_Error( |
||
| 23 | 'rest_cannot_view', |
||
|
0 ignored issues
–
show
|
|||
| 24 | esc_html__( 'Sorry, you cannot view this resource.', 'jetpack' ), |
||
| 25 | array( 'status' => 401 ) |
||
| 26 | ); |
||
| 27 | } |
||
| 28 | |||
| 29 | return true; |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Check whether a given request has proper authorization to view feedback item. |
||
| 34 | * |
||
| 35 | * @param WP_REST_Request $request Full details about the request. |
||
| 36 | * @return WP_Error|boolean |
||
| 37 | */ |
||
| 38 | View Code Duplication | public function get_item_permissions_check( $request ) { |
|
| 39 | if ( ! is_user_member_of_blog( get_current_user_id(), get_current_blog_id() ) ) { |
||
| 40 | return new WP_Error( |
||
| 41 | 'rest_cannot_view', |
||
|
0 ignored issues
–
show
The call to
WP_Error::__construct() has too many arguments starting with 'rest_cannot_view'.
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the Loading history...
|
|||
| 42 | esc_html__( 'Sorry, you cannot view this resource.', 'jetpack' ), |
||
| 43 | array( 'status' => 401 ) |
||
| 44 | ); |
||
| 45 | } |
||
| 46 | |||
| 47 | return true; |
||
| 48 | } |
||
| 49 | |||
| 50 | } |
||
| 51 | |||
| 52 | } |
||
| 53 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignorePhpDoc annotation to the duplicate definition and it will be ignored.