WPCOM_JSON_API_List_Embeds_Endpoint

The Jetpack by WordPress.com WPCOM JSON API List Embeds Endpoint class.

Defined (1)

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

/json-endpoints/class.wpcom-json-api-list-embeds-endpoint.php  
  1. class WPCOM_JSON_API_List_Embeds_Endpoint extends WPCOM_JSON_API_Endpoint { 
  2. // /sites/%s/embeds -> $blog_id 
  3. function callback( $path = '', $blog_id = 0 ) { 
  4. $blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) ); 
  5. if ( is_wp_error( $blog_id ) ) { 
  6. return $blog_id; 
  7.  
  8. // permissions check 
  9. if ( ! current_user_can( 'edit_posts' ) ) { 
  10. return new WP_Error( 'unauthorized', 'Your token must have permission to post on this blog.', 403 ); 
  11.  
  12. // list em 
  13. $output = array( 'embeds' => array() ); 
  14.  
  15. if ( ! function_exists( '_wp_oembed_get_object' ) ) { 
  16. require_once( ABSPATH . WPINC . '/class-oembed.php' ); 
  17.  
  18. global $wp_embed; 
  19. $oembed = _wp_oembed_get_object(); 
  20.  
  21. foreach( $wp_embed->handlers as $priority => $handlers ) { 
  22. foreach( $handlers as $handler ) { 
  23. if ( ! empty( $handler['regex'] ) ) 
  24. $output['embeds'][] = $handler['regex']; 
  25.  
  26. foreach ( $oembed->providers as $regex => $oembed_info ) { 
  27. if ( ! empty( $regex ) ) 
  28. $output['embeds'][] = $regex; 
  29.  
  30. return $output;