summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-updates-status-endpoint.php')
-rw-r--r--plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-updates-status-endpoint.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-updates-status-endpoint.php b/plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-updates-status-endpoint.php
new file mode 100644
index 00000000..48f9ae9d
--- /dev/null
+++ b/plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-updates-status-endpoint.php
@@ -0,0 +1,34 @@
+<?php
+
+class Jetpack_JSON_API_Updates_Status extends Jetpack_JSON_API_Endpoint {
+ // GET /sites/%s/updates
+ protected $needed_capabilities = 'manage_options';
+
+ protected function result() {
+
+ wp_update_themes();
+ wp_update_plugins();
+
+ $update_data = wp_get_update_data();
+ if ( ! isset( $update_data['counts'] ) ) {
+ return new WP_Error( 'get_update_data_error', __( 'There was an error while getting the update data for this site.', 'jetpack' ), 500 );
+ }
+
+ $result = $update_data['counts'];
+
+ include( ABSPATH . WPINC . '/version.php' ); // $wp_version;
+ $result['wp_version'] = isset( $wp_version ) ? $wp_version : null;
+
+ if ( ! empty( $result['wordpress'] ) ) {
+ $cur = get_preferred_from_update_core();
+ if ( isset( $cur->response ) && $cur->response === 'upgrade' ) {
+ $result['wp_update_version'] = $cur->current;
+ }
+ }
+
+ $result['jp_version'] = JETPACK__VERSION;
+
+ return $result;
+
+ }
+}