Jetpack_JSON_API_Plugins_Delete_Endpoint

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

Defined (1)

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

/json-endpoints/jetpack/class.jetpack-json-api-plugins-delete-endpoint.php  
  1. class Jetpack_JSON_API_Plugins_Delete_Endpoint extends Jetpack_JSON_API_Plugins_Endpoint { 
  2.  
  3. // POST /sites/%s/plugins/%s/delete 
  4. protected $needed_capabilities = 'delete_plugins'; 
  5. protected $action = 'delete'; 
  6.  
  7. protected function delete() { 
  8.  
  9. foreach( $this->plugins as $plugin ) { 
  10.  
  11. if ( Jetpack::is_plugin_active( $plugin ) ) { 
  12. $error = $this->log[ $plugin ][] ='You cannot delete a plugin while it is active on the main site.'; 
  13. continue; 
  14.  
  15. $result = delete_plugins ( array( $plugin ) ); 
  16. if ( is_wp_error( $result ) ) { 
  17. $error = $this->log[ $plugin ][] = $result->get_error_message(); 
  18. } else { 
  19. $this->log[ $plugin ][] = 'Plugin deleted'; 
  20.  
  21. if( ! $this->bulk && isset( $error ) ) { 
  22. return new WP_Error( 'delete_plugin_error', $error, 400 ); 
  23.  
  24. return true; 
  25.