Jetpack_JSON_API_Themes_Delete_Endpoint

The Jetpack by WordPress.com Jetpack JSON API Themes Delete Endpoint class.

Defined (1)

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

/json-endpoints/jetpack/class.jetpack-json-api-themes-delete-endpoint.php  
  1. class Jetpack_JSON_API_Themes_Delete_Endpoint extends Jetpack_JSON_API_Themes_Endpoint { 
  2.  
  3. // POST /sites/%s/plugins/%s/delete 
  4. protected $needed_capabilities = 'delete_themes'; 
  5. protected $action = 'delete'; 
  6.  
  7. protected function delete() { 
  8.  
  9. foreach( $this->themes as $theme ) { 
  10.  
  11. // Don't delete an active child theme 
  12. if ( is_child_theme() && $theme == get_stylesheet() ) { 
  13. $error = $this->log[ $theme ]['error'] = 'You cannot delete a theme while it is active on the main site.'; 
  14. continue; 
  15.  
  16. if( $theme == get_template() ) { 
  17. $error = $this->log[ $theme ]['error'] = 'You cannot delete a theme while it is active on the main site.'; 
  18. continue; 
  19.  
  20. $result = delete_theme( $theme ); 
  21.  
  22. if ( is_wp_error( $result ) ) { 
  23. $error = $this->log[ $theme ]['error'] = $result->get_error_messages; 
  24. } else { 
  25. $this->log[ $theme ][] = 'Theme deleted'; 
  26.  
  27.  
  28. if( ! $this->bulk && isset( $error ) ) { 
  29. return new WP_Error( 'delete_theme_error', $error, 400 ); 
  30.  
  31. return true; 
  32.