Jetpack_JSON_API_Core_Modify_Endpoint

The Jetpack by WordPress.com Jetpack JSON API Core Modify Endpoint class.

Defined (1)

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

/json-endpoints/jetpack/class.jetpack-json-api-core-modify-endpoint.php  
  1. class Jetpack_JSON_API_Core_Modify_Endpoint extends Jetpack_JSON_API_Core_Endpoint { 
  2. // POST /sites/%s/core 
  3. // POST /sites/%s/core/update 
  4. protected $needed_capabilities = 'update_core'; 
  5. protected $action = 'default_action'; 
  6. protected $new_version; 
  7. protected $log; 
  8.  
  9. public function default_action() { 
  10. $args = $this->input(); 
  11.  
  12. if ( isset( $args['autoupdate'] ) && is_bool( $args['autoupdate'] ) ) { 
  13. Jetpack_Options::update_option( 'autoupdate_core', $args['autoupdate'] ); 
  14.  
  15. return true; 
  16.  
  17. protected function update( $version, $locale ) { 
  18. $args = $this->input(); 
  19. $version = isset( $args['version'] ) ? $args['version'] : false; 
  20. $locale = isset( $args['locale'] ) ? $args['locale'] : get_locale(); 
  21.  
  22. include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; 
  23.  
  24. delete_site_transient( 'update_core' ); 
  25. wp_version_check( array(), true ); 
  26.  
  27. if ( $version ) { 
  28. $update = find_core_update( $version, $locale ); 
  29. } else { 
  30. $update = $this->find_latest_update_offer(); 
  31.  
  32. $skin = new Automatic_Upgrader_Skin(); 
  33. $upgrader = new Core_Upgrader( $skin ); 
  34.  
  35. $this->new_version = $upgrader->upgrade( $update ); 
  36.  
  37. $this->log = $upgrader->skin->get_upgrade_messages(); 
  38.  
  39. if ( is_wp_error( $this->new_version ) ) { 
  40. return $this->new_version; 
  41.  
  42. return $this->new_version; 
  43.  
  44. protected function find_latest_update_offer() { 
  45. // Select the latest update. 
  46. // Remove filters to bypass automattic updates. 
  47. add_filter( 'request_filesystem_credentials', '__return_true' ); 
  48. add_filter( 'automatic_updates_is_vcs_checkout', '__return_false' ); 
  49. add_filter( 'allow_major_auto_core_updates', '__return_true' ); 
  50. add_filter( 'send_core_update_notification_email', '__return_false' ); 
  51. $update = find_core_auto_update(); 
  52. remove_filter( 'request_filesystem_credentials', '__return_true' ); 
  53. remove_filter( 'automatic_updates_is_vcs_checkout', '__return_false' ); 
  54. remove_filter( 'allow_major_auto_core_updates', '__return_true' ); 
  55. remove_filter( 'send_core_update_notification_email', '__return_false' ); 
  56. return $update; 
  57.