/json-endpoints/jetpack/class.jetpack-json-api-themes-delete-endpoint.php

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