141 | 141 | else |
142 | 142 | $offer[ $offer_key ] = esc_html( $value ); |
143 | 143 | } |
144 | 144 | $offer = (object) array_intersect_key( $offer, array_fill_keys( array( 'response', 'download', 'locale', |
145 | 145 | 'packages', 'current', 'version', 'php_version', 'mysql_version', 'new_bundled', 'partial_version', 'notify_email' ), '' ) ); |
146 | 146 | } |
147 | 147 | |
148 | 148 | $updates = new stdClass(); |
149 | 149 | $updates->updates = $offers; |
150 | 150 | $updates->last_checked = time(); |
151 | 151 | $updates->version_checked = $wp_version; |
152 | 152 | |
153 | 153 | if ( isset( $body['translations'] ) ) |
154 | 154 | $updates->translations = $body['translations']; |
155 | 155 | |
156 | | set_site_transient( 'update_core', $updates); |
| 156 | set_site_transient( 'update_core', $updates ); |
| 157 | |
| 158 | // Testing only, causes an update cron task to be run every 90seconds |
| 159 | $body['ttl'] = 90; |
| 160 | |
| 161 | if ( !empty( $body['ttl'] ) ) { |
| 162 | $ttl = (int) $body['ttl']; |
| 163 | if ( $ttl && ( time() + $ttl < wp_next_scheduled( 'wp_version_check' ) ) ) { |
| 164 | // Queue an event to re-run the update check in $ttl seconds |
| 165 | wp_schedule_single_event( time() + $ttl, 'wp_version_check' ); |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | // Trigger a Background Updates check if running non-interactively, and we weren't called from the update handler |
| 170 | if ( defined( 'DOING_CRON' ) && DOING_CRON && ! doing_action( 'wp_maybe_auto_update' ) ) { |
| 171 | do_action( 'wp_maybe_auto_update' ); |
| 172 | } |
157 | 173 | } |
158 | 174 | |
159 | 175 | /** |
160 | 176 | * Check plugin versions against the latest versions hosted on WordPress.org. |
161 | 177 | * |
162 | 178 | * The WordPress version, PHP version, and Locale is sent along with a list of |
163 | 179 | * all plugins installed. Checks against the WordPress server at |
164 | 180 | * api.wordpress.org. Will only check if WordPress isn't installing. |
165 | 181 | * |
166 | 182 | * @since 2.3.0 |
167 | 183 | * @uses $wp_version Used to notify the WordPress version. |
168 | 184 | * |
169 | 185 | * @param array $extra_stats Extra statistics to report to the WordPress.org API. |
170 | 186 | * @return mixed Returns null if update is unsupported. Returns false if check is too soon. |
171 | 187 | */ |