WPCOM_JSON_API_List_Shortcodes_Endpoint

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

Defined (1)

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

/json-endpoints/class.wpcom-json-api-list-shortcodes-endpoint.php  
  1. class WPCOM_JSON_API_List_Shortcodes_Endpoint extends WPCOM_JSON_API_Endpoint { 
  2. // /sites/%s/shortcodes -> $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. global $shortcode_tags; 
  14. $output = array( 'shortcodes' => array() ); 
  15.  
  16. foreach ( $shortcode_tags as $tag => $class ) { 
  17. if ( '__return_false' == $class ) 
  18. continue; 
  19. $output['shortcodes'][] = $tag; 
  20.  
  21. return $output;