+ if ( $extra_stats ) {
+ $options['body']['update_stats'] = wp_json_encode( $extra_stats );
+ }
+
+ $url = $http_url = 'http://api.wordpress.org/themes/update-check/1.1/';
+ if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
+ $url = set_url_scheme( $url, 'https' );
+
+ $raw_response = wp_remote_post( $url, $options );
+ if ( $ssl && is_wp_error( $raw_response ) ) {
+ trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE );
+ $raw_response = wp_remote_post( $http_url, $options );
+ }
+
+ if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) {
+ return;
+ }
+
+ $new_update = new stdClass;
+ $new_update->last_checked = time();
+ $new_update->checked = $checked;
+
+ $response = json_decode( wp_remote_retrieve_body( $raw_response ), true );
+
+ if ( is_array( $response ) ) {
+ $new_update->response = $response['themes'];
+ $new_update->translations = $response['translations'];
+ }
+
+ set_site_transient( 'update_themes', $new_update );
+}
+
+/**
+ * Performs WordPress automatic background updates.
+ *
+ * @since 3.7.0
+ */
+function wp_maybe_auto_update() {
+ include_once( ABSPATH . '/wp-admin/includes/admin.php' );
+ include_once( ABSPATH . '/wp-admin/includes/class-wp-upgrader.php' );
+
+ $upgrader = new WP_Automatic_Updater;
+ $upgrader->run();
+}
+
+/**
+ * Retrieves a list of all language updates available.
+ *
+ * @since 3.7.0
+ *
+ * @return array
+ */
+function wp_get_translation_updates() {
+ $updates = array();
+ $transients = array( 'update_core' => 'core', 'update_plugins' => 'plugin', 'update_themes' => 'theme' );
+ foreach ( $transients as $transient => $type ) {
+ $transient = get_site_transient( $transient );
+ if ( empty( $transient->translations ) )
+ continue;
+
+ foreach ( $transient->translations as $translation ) {
+ $updates[] = (object) $translation;
+ }
+ }
+ return $updates;
+}
+
+/**
+ * Collect counts and UI strings for available updates
+ *
+ * @since 3.3.0
+ *
+ * @return array
+ */
+function wp_get_update_data() {
+ $counts = array( 'plugins' => 0, 'themes' => 0, 'wordpress' => 0, 'translations' => 0 );