WPCOM_JSON_API_Get_Post_v1_1_Endpoint

The Jetpack by WordPress.com WPCOM JSON API Get Post v1 1 Endpoint class.

Defined (1)

The class is defined in the following location(s).

/json-endpoints/class.wpcom-json-api-get-post-v1-1-endpoint.php  
  1. class WPCOM_JSON_API_Get_Post_v1_1_Endpoint extends WPCOM_JSON_API_Post_v1_1_Endpoint { 
  2. // /sites/%s/posts/%d -> $blog_id, $post_id 
  3. // /sites/%s/posts/slug:%s -> $blog_id, $post_id 
  4. function callback( $path = '', $blog_id = 0, $post_id = 0 ) { 
  5. $blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) ); 
  6. if ( is_wp_error( $blog_id ) ) { 
  7. return $blog_id; 
  8.  
  9. $args = $this->query_args(); 
  10.  
  11. if ( false === strpos( $path, '/posts/slug:' ) ) { 
  12. $get_by = 'ID'; 
  13. } else { 
  14. $get_by = 'name'; 
  15.  
  16. $return = $this->get_post_by( $get_by, $post_id, $args['context'] ); 
  17. if ( !$return || is_wp_error( $return ) ) { 
  18. return $return; 
  19.  
  20. /** This action is documented in json-endpoints/class.wpcom-json-api-site-settings-endpoint.php */ 
  21. do_action( 'wpcom_json_api_objects', 'posts' ); 
  22.  
  23. return $return;