/json-endpoints/jetpack/class.jetpack-json-api-updates-status-endpoint.php

  1. <?php 
  2.  
  3. class Jetpack_JSON_API_Updates_Status extends Jetpack_JSON_API_Endpoint { 
  4. // GET /sites/%s/updates 
  5. protected $needed_capabilities = 'manage_options'; 
  6.  
  7. protected function result() { 
  8.  
  9. wp_update_themes(); 
  10. wp_update_plugins(); 
  11.  
  12. $update_data = wp_get_update_data(); 
  13. if ( ! isset( $update_data['counts'] ) ) { 
  14. return new WP_Error( 'get_update_data_error', __( 'There was an error while getting the update data for this site.', 'jetpack' ), 500 ); 
  15.  
  16. $result = $update_data['counts']; 
  17.  
  18. include( ABSPATH . WPINC . '/version.php' ); // $wp_version; 
  19. $result['wp_version'] = isset( $wp_version ) ? $wp_version : null; 
  20.  
  21. if ( ! empty( $result['wordpress'] ) ) { 
  22. $cur = get_preferred_from_update_core(); 
  23. if ( isset( $cur->response ) && $cur->response === 'upgrade' ) { 
  24. $result['wp_update_version'] = $cur->current; 
  25.  
  26. $result['jp_version'] = JETPACK__VERSION; 
  27.  
  28. return $result; 
  29.  
.