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_Embeds_Endpoint( array( |
||
| 4 | 'description' => "Get a list of embeds available on a site. Note: The current user must have publishing access.", |
||
| 5 | 'group' => 'sites', |
||
| 6 | 'stat' => 'embeds', |
||
| 7 | 'method' => 'GET', |
||
| 8 | 'path' => '/sites/%s/embeds', |
||
| 9 | 'path_labels' => array( |
||
| 10 | '$site' => '(int|string) Site ID or domain', |
||
| 11 | ), |
||
| 12 | 'response_format' => array( |
||
| 13 | 'embeds' => '(array) A list of supported embeds by their regex pattern.', |
||
| 14 | ), |
||
| 15 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/82974409/embeds', |
||
| 16 | 'example_request_data' => array( |
||
| 17 | 'headers' => array( |
||
| 18 | 'authorization' => 'Bearer YOUR_API_TOKEN' |
||
| 19 | ), |
||
| 20 | ) |
||
| 21 | ) ); |
||
| 22 | |||
| 23 | class WPCOM_JSON_API_List_Embeds_Endpoint extends WPCOM_JSON_API_Endpoint { |
||
| 24 | // /sites/%s/embeds -> $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 | $output = array( 'embeds' => array() ); |
||
| 38 | |||
| 39 | if ( ! function_exists( '_wp_oembed_get_object' ) ) { |
||
| 40 | require_once( ABSPATH . WPINC . '/class-oembed.php' ); |
||
| 41 | } |
||
| 42 | |||
| 43 | global $wp_embed; |
||
| 44 | $oembed = _wp_oembed_get_object(); |
||
| 45 | |||
| 46 | foreach( $wp_embed->handlers as $priority => $handlers ) { |
||
| 47 | foreach( $handlers as $handler ) { |
||
| 48 | if ( ! empty( $handler['regex'] ) ) |
||
| 49 | $output['embeds'][] = $handler['regex']; |
||
| 50 | } |
||
| 51 | } |
||
| 52 | |||
| 53 | foreach ( $oembed->providers as $regex => $oembed_info ) { |
||
| 54 | if ( ! empty( $regex ) ) |
||
| 55 | $output['embeds'][] = $regex; |
||
| 56 | } |
||
| 57 | |||
| 58 | return $output; |
||
| 59 | } |
||
| 60 | } |
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.