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 | new WPCOM_JSON_API_Bulk_Delete_Post_Endpoint( array( |
||
| 4 | 'description' => 'Delete multiple posts. Note: If the trash is enabled, this request will send non-trashed posts to the trash. Trashed posts will be permanently deleted.', |
||
| 5 | 'group' => 'posts', |
||
| 6 | 'stat' => 'posts:1:bulk-delete', |
||
| 7 | 'min_version' => '1.1', |
||
| 8 | 'max_version' => '1.1', |
||
| 9 | 'method' => 'POST', |
||
| 10 | 'path' => '/sites/%s/posts/delete', |
||
| 11 | 'path_labels' => array( |
||
| 12 | '$site' => '(int|string) Site ID or domain', |
||
| 13 | ), |
||
| 14 | 'request_format' => array( |
||
| 15 | 'post_ids' => '(array|string) An array, or comma-separated list, of Post IDs to delete or trash.', |
||
| 16 | ), |
||
| 17 | |||
| 18 | 'response_format' => array( |
||
| 19 | 'results' => '(object) An object containing results, ' |
||
| 20 | ), |
||
| 21 | |||
| 22 | 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/posts/delete', |
||
| 23 | |||
| 24 | 'example_request_data' => array( |
||
| 25 | 'headers' => array( |
||
| 26 | 'authorization' => 'Bearer YOUR_API_TOKEN' |
||
| 27 | ), |
||
| 28 | |||
| 29 | 'body' => array( |
||
| 30 | 'post_ids' => array( 881, 882 ), |
||
| 31 | ), |
||
| 32 | |||
| 33 | ) |
||
| 34 | ) ); |
||
| 35 | |||
| 36 | View Code Duplication | class WPCOM_JSON_API_Bulk_Delete_Post_Endpoint extends WPCOM_JSON_API_Update_Post_v1_1_Endpoint { |
|
| 37 | // /sites/%s/posts/delete |
||
| 38 | function callback( $path = '', $blog_id = 0, $post_id = 0 ) { |
||
| 39 | $blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) ); |
||
| 40 | if ( is_wp_error( $blog_id ) ) { |
||
| 41 | return $blog_id; |
||
| 42 | } |
||
| 43 | |||
| 44 | $input = $this->input(); |
||
| 45 | |||
| 46 | if ( is_array( $input['post_ids'] ) ) { |
||
| 47 | $post_ids = (array) $input['post_ids']; |
||
| 48 | } else if ( ! empty( $input['post_ids'] ) ) { |
||
| 49 | $post_ids = explode( ',', $input['post_ids'] ); |
||
| 50 | } else { |
||
| 51 | $post_ids = array(); |
||
| 52 | } |
||
| 53 | |||
| 54 | if ( count( $post_ids ) < 1 ) { |
||
| 55 | return new WP_Error( 'empty_post_ids', 'The request must include post_ids' ); |
||
|
0 ignored issues
–
show
|
|||
| 56 | } |
||
| 57 | |||
| 58 | $result = array( |
||
| 59 | 'results' => array(), |
||
| 60 | ); |
||
| 61 | |||
| 62 | foreach( $post_ids as $post_id ) { |
||
| 63 | $result['results'][ $post_id ] = $this->delete_post( $path, $blog_id, $post_id ); |
||
| 64 | } |
||
| 65 | |||
| 66 | return $result; |
||
| 67 | } |
||
| 68 | } |
||
| 69 |
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.