WPCOM_JSON_API_Get_Sharing_Button_Endpoint

The Jetpack by WordPress.com WPCOM JSON API Get Sharing Button Endpoint class.

Defined (1)

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

/json-endpoints/class.wpcom-json-api-sharing-buttons-endpoint.php  
  1. class WPCOM_JSON_API_Get_Sharing_Button_Endpoint extends WPCOM_JSON_API_Sharing_Button_Endpoint { 
  2.  
  3. // GET /sites/%s/sharing-buttons/%s -> $blog_id, $button_id 
  4. public function callback( $path = '', $blog_id = 0, $button_id = 0 ) { 
  5. // Validate request 
  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. $continue = $this->setup(); 
  11. if ( is_wp_error( $continue ) ) { 
  12. return $continue; 
  13.  
  14. // Search existing services for button 
  15. $all_buttons = $this->sharing_service->get_all_services_blog(); 
  16. if ( ! array_key_exists( $button_id, $all_buttons ) ) { 
  17. return new WP_Error( 'not_found', 'The specified sharing button was not found', 404 ); 
  18. } else { 
  19. return $this->format_sharing_button( $all_buttons[ $button_id ] ); 
  20.