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_List_Shortcodes_Endpoint( array( |
||
| 4 | 'description' => "Get a list of shortcodes available on a site. Note: The current user must have publishing access.", |
||
| 5 | 'group' => 'sites', |
||
| 6 | 'stat' => 'shortcodes', |
||
| 7 | 'method' => 'GET', |
||
| 8 | 'path' => '/sites/%s/shortcodes', |
||
| 9 | 'path_labels' => array( |
||
| 10 | '$site' => '(int|string) Site ID or domain', |
||
| 11 | ), |
||
| 12 | 'response_format' => array( |
||
| 13 | 'shortcodes' => '(array) A list of supported shortcodes by their handle.', |
||
| 14 | ), |
||
| 15 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/82974409/shortcodes', |
||
| 16 | 'example_request_data' => array( |
||
| 17 | 'headers' => array( |
||
| 18 | 'authorization' => 'Bearer YOUR_API_TOKEN' |
||
| 19 | ), |
||
| 20 | ) |
||
| 21 | ) ); |
||
| 22 | |||
| 23 | class WPCOM_JSON_API_List_Shortcodes_Endpoint extends WPCOM_JSON_API_Endpoint { |
||
| 24 | // /sites/%s/shortcodes -> $blog_id |
||
| 25 | function callback( $path = '', $blog_id = 0 ) { |
||
| 26 | $blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) ); |
||
| 27 | if ( is_wp_error( $blog_id ) ) { |
||
| 28 | return $blog_id; |
||
| 29 | } |
||
| 30 | |||
| 31 | // permissions check |
||
| 32 | if ( ! current_user_can( 'edit_posts' ) ) { |
||
| 33 | return new WP_Error( 'unauthorized', 'Your token must have permission to post on this blog.', 403 ); |
||
|
0 ignored issues
–
show
|
|||
| 34 | } |
||
| 35 | |||
| 36 | // list em |
||
| 37 | global $shortcode_tags; |
||
| 38 | $output = array( 'shortcodes' => array() ); |
||
| 39 | |||
| 40 | foreach ( $shortcode_tags as $tag => $class ) { |
||
| 41 | if ( '__return_false' == $class ) |
||
| 42 | continue; |
||
| 43 | $output['shortcodes'][] = $tag; |
||
| 44 | } |
||
| 45 | |||
| 46 | return $output; |
||
| 47 | } |
||
| 48 | } |
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.