WPCOM_JSON_API_List_Page_Templates_Endpoint

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

Defined (1)

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

/json-endpoints/class.wpcom-json-api-get-site-endpoint.php  
  1. class WPCOM_JSON_API_List_Page_Templates_Endpoint extends WPCOM_JSON_API_Endpoint { 
  2. // /sites/%s/page-templates -> $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. if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { 
  9. $this->load_theme_functions(); 
  10.  
  11. $response = array(); 
  12. $page_templates = array(); 
  13.  
  14. $templates = get_page_templates(); 
  15. ksort( $templates ); 
  16.  
  17. foreach ( array_keys( $templates ) as $label ) { 
  18. $page_templates[] = array( 
  19. 'label' => $label,  
  20. 'file' => $templates[ $label ] 
  21. ); 
  22.  
  23. $response['templates'] = $page_templates; 
  24.  
  25. return $response;