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 | class WPCOM_JSON_API_Get_Post_v1_1_Endpoint extends WPCOM_JSON_API_Post_v1_1_Endpoint { |
||
| 3 | // /sites/%s/posts/%d -> $blog_id, $post_id |
||
| 4 | // /sites/%s/posts/slug:%s -> $blog_id, $post_id |
||
| 5 | function callback( $path = '', $blog_id = 0, $post_id = 0 ) { |
||
| 6 | $blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) ); |
||
| 7 | if ( is_wp_error( $blog_id ) ) { |
||
| 8 | return $blog_id; |
||
| 9 | } |
||
| 10 | |||
| 11 | $args = $this->query_args(); |
||
| 12 | |||
| 13 | $site = $this->get_platform()->get_site( $blog_id ); |
||
| 14 | |||
| 15 | if ( false !== strpos( $path, '/posts/slug:' ) ) { |
||
| 16 | $post_id = $site->get_post_id_by_name( $post_id ); |
||
| 17 | if ( is_wp_error( $post_id ) ) { |
||
| 18 | return $post_id; |
||
| 19 | } |
||
| 20 | } |
||
| 21 | |||
| 22 | if ( defined( 'IS_WPCOM' ) && IS_WPCOM && |
||
| 23 | ! in_array( get_post_type( $post_id ), array( false, 'post', 'revision' ) ) ) { |
||
| 24 | $this->load_theme_functions(); |
||
| 25 | } |
||
| 26 | |||
| 27 | $return = $this->get_post_by( 'ID', $post_id, $args['context'] ); |
||
| 28 | |||
| 29 | if ( !$return || is_wp_error( $return ) ) { |
||
| 30 | return $return; |
||
| 31 | } |
||
| 32 | |||
| 33 | View Code Duplication | if ( ! $site->current_user_can_access_post_type( $return['type'], $args['context'] ) ) { |
|
|
0 ignored issues
–
show
|
|||
| 34 | return new WP_Error( 'unknown_post', 'Unknown post', 404 ); |
||
| 35 | } |
||
| 36 | |||
| 37 | /** This action is documented in json-endpoints/class.wpcom-json-api-site-settings-endpoint.php */ |
||
| 38 | do_action( 'wpcom_json_api_objects', 'posts' ); |
||
| 39 | |||
| 40 | return $return; |
||
| 41 | } |
||
| 42 | } |
||
| 43 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.