11 * |
11 * |
12 * The WordPress version, PHP version, and Locale is sent. Checks against the |
12 * The WordPress version, PHP version, and Locale is sent. Checks against the |
13 * WordPress server at api.wordpress.org server. Will only check if WordPress |
13 * WordPress server at api.wordpress.org server. Will only check if WordPress |
14 * isn't installing. |
14 * isn't installing. |
15 * |
15 * |
16 * @package WordPress |
|
17 * @since 2.3.0 |
16 * @since 2.3.0 |
18 * @uses $wp_version Used to check against the newest WordPress version. |
17 * @uses $wp_version Used to check against the newest WordPress version. |
19 * |
18 * |
20 * @param array $extra_stats Extra statistics to report to the WordPress.org API. |
19 * @param array $extra_stats Extra statistics to report to the WordPress.org API. |
21 * @return mixed Returns null if update is unsupported. Returns false if check is too soon. |
20 * @param bool $force_check Whether to bypass the transient cache and force a fresh update check. Defaults to false, true if $extra_stats is set. |
22 */ |
21 * @return null|false Returns null if update is unsupported. Returns false if check is too soon. |
23 function wp_version_check( $extra_stats = array() ) { |
22 */ |
|
23 function wp_version_check( $extra_stats = array(), $force_check = false ) { |
24 if ( defined('WP_INSTALLING') ) |
24 if ( defined('WP_INSTALLING') ) |
25 return; |
25 return; |
26 |
26 |
27 global $wpdb, $wp_local_package; |
27 global $wpdb, $wp_local_package; |
28 include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version |
28 include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version |
29 $php_version = phpversion(); |
29 $php_version = phpversion(); |
30 |
30 |
31 $current = get_site_transient( 'update_core' ); |
31 $current = get_site_transient( 'update_core' ); |
32 $translations = wp_get_installed_translations( 'core' ); |
32 $translations = wp_get_installed_translations( 'core' ); |
|
33 |
|
34 // Invalidate the transient when $wp_version changes |
|
35 if ( is_object( $current ) && $wp_version != $current->version_checked ) |
|
36 $current = false; |
33 |
37 |
34 if ( ! is_object($current) ) { |
38 if ( ! is_object($current) ) { |
35 $current = new stdClass; |
39 $current = new stdClass; |
36 $current->updates = array(); |
40 $current->updates = array(); |
37 $current->version_checked = $wp_version; |
41 $current->version_checked = $wp_version; |
38 } |
42 } |
39 |
43 |
|
44 if ( ! empty( $extra_stats ) ) |
|
45 $force_check = true; |
|
46 |
40 // Wait 60 seconds between multiple version check requests |
47 // Wait 60 seconds between multiple version check requests |
41 $timeout = 60; |
48 $timeout = 60; |
42 $time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked ); |
49 $time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked ); |
43 if ( $time_not_changed && empty( $extra_stats ) ) |
50 if ( ! $force_check && $time_not_changed ) |
44 return false; |
51 return false; |
45 |
52 |
46 $locale = get_locale(); |
53 $locale = get_locale(); |
47 /** |
54 /** |
48 * Filter the locale requested for WordPress core translations. |
55 * Filter the locale requested for WordPress core translations. |
85 'users' => $user_count, |
92 'users' => $user_count, |
86 'multisite_enabled' => $multisite_enabled, |
93 'multisite_enabled' => $multisite_enabled, |
87 ); |
94 ); |
88 |
95 |
89 $post_body = array( |
96 $post_body = array( |
90 'translations' => json_encode( $translations ), |
97 'translations' => wp_json_encode( $translations ), |
91 ); |
98 ); |
92 |
99 |
93 if ( $extra_stats ) |
100 if ( is_array( $extra_stats ) ) |
94 $post_body = array_merge( $post_body, $extra_stats ); |
101 $post_body = array_merge( $post_body, $extra_stats ); |
95 |
102 |
96 $url = $http_url = 'http://api.wordpress.org/core/version-check/1.7/?' . http_build_query( $query, null, '&' ); |
103 $url = $http_url = 'http://api.wordpress.org/core/version-check/1.7/?' . http_build_query( $query, null, '&' ); |
97 if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) |
104 if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) |
98 $url = set_url_scheme( $url, 'https' ); |
105 $url = set_url_scheme( $url, 'https' ); |
107 'body' => $post_body, |
114 'body' => $post_body, |
108 ); |
115 ); |
109 |
116 |
110 $response = wp_remote_post( $url, $options ); |
117 $response = wp_remote_post( $url, $options ); |
111 if ( $ssl && is_wp_error( $response ) ) { |
118 if ( $ssl && is_wp_error( $response ) ) { |
112 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="http://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 ); |
119 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 ); |
113 $response = wp_remote_post( $http_url, $options ); |
120 $response = wp_remote_post( $http_url, $options ); |
114 } |
121 } |
115 |
122 |
116 if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) |
123 if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) |
117 return false; |
124 return false; |
133 $offer['download'] = esc_url( $value ); |
140 $offer['download'] = esc_url( $value ); |
134 else |
141 else |
135 $offer[ $offer_key ] = esc_html( $value ); |
142 $offer[ $offer_key ] = esc_html( $value ); |
136 } |
143 } |
137 $offer = (object) array_intersect_key( $offer, array_fill_keys( array( 'response', 'download', 'locale', |
144 $offer = (object) array_intersect_key( $offer, array_fill_keys( array( 'response', 'download', 'locale', |
138 'packages', 'current', 'version', 'php_version', 'mysql_version', 'new_bundled', 'partial_version', 'notify_email' ), '' ) ); |
145 'packages', 'current', 'version', 'php_version', 'mysql_version', 'new_bundled', 'partial_version', 'notify_email', 'support_email', 'new_files' ), '' ) ); |
139 } |
146 } |
140 |
147 |
141 $updates = new stdClass(); |
148 $updates = new stdClass(); |
142 $updates->updates = $offers; |
149 $updates->updates = $offers; |
143 $updates->last_checked = time(); |
150 $updates->last_checked = time(); |
144 $updates->version_checked = $wp_version; |
151 $updates->version_checked = $wp_version; |
145 |
152 |
146 if ( isset( $body['translations'] ) ) |
153 if ( isset( $body['translations'] ) ) |
147 $updates->translations = $body['translations']; |
154 $updates->translations = $body['translations']; |
148 |
155 |
149 set_site_transient( 'update_core', $updates); |
156 set_site_transient( 'update_core', $updates ); |
|
157 |
|
158 if ( ! empty( $body['ttl'] ) ) { |
|
159 $ttl = (int) $body['ttl']; |
|
160 if ( $ttl && ( time() + $ttl < wp_next_scheduled( 'wp_version_check' ) ) ) { |
|
161 // Queue an event to re-run the update check in $ttl seconds. |
|
162 wp_schedule_single_event( time() + $ttl, 'wp_version_check' ); |
|
163 } |
|
164 } |
|
165 |
|
166 // Trigger a background updates check if running non-interactively, and we weren't called from the update handler. |
|
167 if ( defined( 'DOING_CRON' ) && DOING_CRON && ! doing_action( 'wp_maybe_auto_update' ) ) { |
|
168 do_action( 'wp_maybe_auto_update' ); |
|
169 } |
150 } |
170 } |
151 |
171 |
152 /** |
172 /** |
153 * Check plugin versions against the latest versions hosted on WordPress.org. |
173 * Check plugin versions against the latest versions hosted on WordPress.org. |
154 * |
174 * |
155 * The WordPress version, PHP version, and Locale is sent along with a list of |
175 * The WordPress version, PHP version, and Locale is sent along with a list of |
156 * all plugins installed. Checks against the WordPress server at |
176 * all plugins installed. Checks against the WordPress server at |
157 * api.wordpress.org. Will only check if WordPress isn't installing. |
177 * api.wordpress.org. Will only check if WordPress isn't installing. |
158 * |
178 * |
159 * @package WordPress |
|
160 * @since 2.3.0 |
179 * @since 2.3.0 |
161 * @uses $wp_version Used to notify the WordPress version. |
180 * @uses $wp_version Used to notify the WordPress version. |
162 * |
181 * |
163 * @return mixed Returns null if update is unsupported. Returns false if check is too soon. |
182 * @param array $extra_stats Extra statistics to report to the WordPress.org API. |
164 */ |
183 * @return false|null Returns null if update is unsupported. Returns false if check is too soon. |
165 function wp_update_plugins() { |
184 */ |
166 include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version |
185 function wp_update_plugins( $extra_stats = array() ) { |
|
186 include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version |
167 |
187 |
168 if ( defined('WP_INSTALLING') ) |
188 if ( defined('WP_INSTALLING') ) |
169 return false; |
189 return false; |
170 |
190 |
171 // If running blog-side, bail unless we've not checked in the last 12 hours |
191 // If running blog-side, bail unless we've not checked in the last 12 hours |
194 case 'load-plugins.php' : |
214 case 'load-plugins.php' : |
195 case 'load-update.php' : |
215 case 'load-update.php' : |
196 $timeout = HOUR_IN_SECONDS; |
216 $timeout = HOUR_IN_SECONDS; |
197 break; |
217 break; |
198 default : |
218 default : |
199 $timeout = 12 * HOUR_IN_SECONDS; |
219 if ( defined( 'DOING_CRON' ) && DOING_CRON ) { |
|
220 $timeout = 0; |
|
221 } else { |
|
222 $timeout = 12 * HOUR_IN_SECONDS; |
|
223 } |
200 } |
224 } |
201 |
225 |
202 $time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked ); |
226 $time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked ); |
203 |
227 |
204 if ( $time_not_changed ) { |
228 if ( $time_not_changed && ! $extra_stats ) { |
205 $plugin_changed = false; |
229 $plugin_changed = false; |
206 foreach ( $plugins as $file => $p ) { |
230 foreach ( $plugins as $file => $p ) { |
207 $new_option->checked[ $file ] = $p['Version']; |
231 $new_option->checked[ $file ] = $p['Version']; |
208 |
232 |
209 if ( !isset( $current->checked[ $file ] ) || strval($current->checked[ $file ]) !== strval($p['Version']) ) |
233 if ( !isset( $current->checked[ $file ] ) || strval($current->checked[ $file ]) !== strval($p['Version']) ) |
238 * |
262 * |
239 * @param array $locales Plugin locale. Default is current locale of the site. |
263 * @param array $locales Plugin locale. Default is current locale of the site. |
240 */ |
264 */ |
241 $locales = apply_filters( 'plugins_update_check_locales', $locales ); |
265 $locales = apply_filters( 'plugins_update_check_locales', $locales ); |
242 |
266 |
|
267 if ( defined( 'DOING_CRON' ) && DOING_CRON ) { |
|
268 $timeout = 30; |
|
269 } else { |
|
270 // Three seconds, plus one extra second for every 10 plugins |
|
271 $timeout = 3 + (int) ( count( $plugins ) / 10 ); |
|
272 } |
|
273 |
243 $options = array( |
274 $options = array( |
244 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3), |
275 'timeout' => $timeout, |
245 'body' => array( |
276 'body' => array( |
246 'plugins' => json_encode( $to_send ), |
277 'plugins' => wp_json_encode( $to_send ), |
247 'translations' => json_encode( $translations ), |
278 'translations' => wp_json_encode( $translations ), |
248 'locale' => json_encode( $locales ), |
279 'locale' => wp_json_encode( $locales ), |
|
280 'all' => wp_json_encode( true ), |
249 ), |
281 ), |
250 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) |
282 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) |
251 ); |
283 ); |
252 |
284 |
|
285 if ( $extra_stats ) { |
|
286 $options['body']['update_stats'] = wp_json_encode( $extra_stats ); |
|
287 } |
|
288 |
253 $url = $http_url = 'http://api.wordpress.org/plugins/update-check/1.1/'; |
289 $url = $http_url = 'http://api.wordpress.org/plugins/update-check/1.1/'; |
254 if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) |
290 if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) |
255 $url = set_url_scheme( $url, 'https' ); |
291 $url = set_url_scheme( $url, 'https' ); |
256 |
292 |
257 $raw_response = wp_remote_post( $url, $options ); |
293 $raw_response = wp_remote_post( $url, $options ); |
258 if ( $ssl && is_wp_error( $raw_response ) ) { |
294 if ( $ssl && is_wp_error( $raw_response ) ) { |
259 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="http://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 ); |
295 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 ); |
260 $raw_response = wp_remote_post( $http_url, $options ); |
296 $raw_response = wp_remote_post( $http_url, $options ); |
261 } |
297 } |
262 |
298 |
263 if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) |
299 if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) |
264 return false; |
300 return false; |
266 $response = json_decode( wp_remote_retrieve_body( $raw_response ), true ); |
302 $response = json_decode( wp_remote_retrieve_body( $raw_response ), true ); |
267 foreach ( $response['plugins'] as &$plugin ) { |
303 foreach ( $response['plugins'] as &$plugin ) { |
268 $plugin = (object) $plugin; |
304 $plugin = (object) $plugin; |
269 } |
305 } |
270 unset( $plugin ); |
306 unset( $plugin ); |
|
307 foreach ( $response['no_update'] as &$plugin ) { |
|
308 $plugin = (object) $plugin; |
|
309 } |
|
310 unset( $plugin ); |
271 |
311 |
272 if ( is_array( $response ) ) { |
312 if ( is_array( $response ) ) { |
273 $new_option->response = $response['plugins']; |
313 $new_option->response = $response['plugins']; |
274 $new_option->translations = $response['translations']; |
314 $new_option->translations = $response['translations']; |
|
315 // TODO: Perhaps better to store no_update in a separate transient with an expiry? |
|
316 $new_option->no_update = $response['no_update']; |
275 } else { |
317 } else { |
276 $new_option->response = array(); |
318 $new_option->response = array(); |
277 $new_option->translations = array(); |
319 $new_option->translations = array(); |
|
320 $new_option->no_update = array(); |
278 } |
321 } |
279 |
322 |
280 set_site_transient( 'update_plugins', $new_option ); |
323 set_site_transient( 'update_plugins', $new_option ); |
281 } |
324 } |
282 |
325 |
285 * |
328 * |
286 * A list of all themes installed in sent to WP. Checks against the |
329 * A list of all themes installed in sent to WP. Checks against the |
287 * WordPress server at api.wordpress.org. Will only check if WordPress isn't |
330 * WordPress server at api.wordpress.org. Will only check if WordPress isn't |
288 * installing. |
331 * installing. |
289 * |
332 * |
290 * @package WordPress |
|
291 * @since 2.7.0 |
333 * @since 2.7.0 |
292 * @uses $wp_version Used to notify the WordPress version. |
334 * @uses $wp_version Used to notify the WordPress version. |
293 * |
335 * |
294 * @return mixed Returns null if update is unsupported. Returns false if check is too soon. |
336 * @param array $extra_stats Extra statistics to report to the WordPress.org API. |
295 */ |
337 * @return false|null Returns null if update is unsupported. Returns false if check is too soon. |
296 function wp_update_themes() { |
338 */ |
297 include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version |
339 function wp_update_themes( $extra_stats = array() ) { |
|
340 include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version |
298 |
341 |
299 if ( defined( 'WP_INSTALLING' ) ) |
342 if ( defined( 'WP_INSTALLING' ) ) |
300 return false; |
343 return false; |
301 |
344 |
302 $installed_themes = wp_get_themes(); |
345 $installed_themes = wp_get_themes(); |
336 case 'load-themes.php' : |
379 case 'load-themes.php' : |
337 case 'load-update.php' : |
380 case 'load-update.php' : |
338 $timeout = HOUR_IN_SECONDS; |
381 $timeout = HOUR_IN_SECONDS; |
339 break; |
382 break; |
340 default : |
383 default : |
341 $timeout = 12 * HOUR_IN_SECONDS; |
384 if ( defined( 'DOING_CRON' ) && DOING_CRON ) { |
|
385 $timeout = 0; |
|
386 } else { |
|
387 $timeout = 12 * HOUR_IN_SECONDS; |
|
388 } |
342 } |
389 } |
343 |
390 |
344 $time_not_changed = isset( $last_update->last_checked ) && $timeout > ( time() - $last_update->last_checked ); |
391 $time_not_changed = isset( $last_update->last_checked ) && $timeout > ( time() - $last_update->last_checked ); |
345 |
392 |
346 if ( $time_not_changed ) { |
393 if ( $time_not_changed && ! $extra_stats ) { |
347 $theme_changed = false; |
394 $theme_changed = false; |
348 foreach ( $checked as $slug => $v ) { |
395 foreach ( $checked as $slug => $v ) { |
349 if ( !isset( $last_update->checked[ $slug ] ) || strval($last_update->checked[ $slug ]) !== strval($v) ) |
396 if ( !isset( $last_update->checked[ $slug ] ) || strval($last_update->checked[ $slug ]) !== strval($v) ) |
350 $theme_changed = true; |
397 $theme_changed = true; |
351 } |
398 } |
378 * |
425 * |
379 * @param array $locales Theme locale. Default is current locale of the site. |
426 * @param array $locales Theme locale. Default is current locale of the site. |
380 */ |
427 */ |
381 $locales = apply_filters( 'themes_update_check_locales', $locales ); |
428 $locales = apply_filters( 'themes_update_check_locales', $locales ); |
382 |
429 |
|
430 if ( defined( 'DOING_CRON' ) && DOING_CRON ) { |
|
431 $timeout = 30; |
|
432 } else { |
|
433 // Three seconds, plus one extra second for every 10 themes |
|
434 $timeout = 3 + (int) ( count( $themes ) / 10 ); |
|
435 } |
|
436 |
383 $options = array( |
437 $options = array( |
384 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3), |
438 'timeout' => $timeout, |
385 'body' => array( |
439 'body' => array( |
386 'themes' => json_encode( $request ), |
440 'themes' => wp_json_encode( $request ), |
387 'translations' => json_encode( $translations ), |
441 'translations' => wp_json_encode( $translations ), |
388 'locale' => json_encode( $locales ), |
442 'locale' => wp_json_encode( $locales ), |
389 ), |
443 ), |
390 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) |
444 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) |
391 ); |
445 ); |
392 |
446 |
|
447 if ( $extra_stats ) { |
|
448 $options['body']['update_stats'] = wp_json_encode( $extra_stats ); |
|
449 } |
|
450 |
393 $url = $http_url = 'http://api.wordpress.org/themes/update-check/1.1/'; |
451 $url = $http_url = 'http://api.wordpress.org/themes/update-check/1.1/'; |
394 if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) |
452 if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) |
395 $url = set_url_scheme( $url, 'https' ); |
453 $url = set_url_scheme( $url, 'https' ); |
396 |
454 |
397 $raw_response = wp_remote_post( $url, $options ); |
455 $raw_response = wp_remote_post( $url, $options ); |
398 if ( $ssl && is_wp_error( $raw_response ) ) { |
456 if ( $ssl && is_wp_error( $raw_response ) ) { |
399 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="http://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 ); |
457 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 ); |
400 $raw_response = wp_remote_post( $http_url, $options ); |
458 $raw_response = wp_remote_post( $http_url, $options ); |
401 } |
459 } |
402 |
460 |
403 if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) |
461 if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) |
404 return false; |
462 return false; |
582 // Find the next instance of 7 a.m. or 7 p.m., but skip it if it is within 3 hours from now. |
640 // Find the next instance of 7 a.m. or 7 p.m., but skip it if it is within 3 hours from now. |
583 while ( ( $now + 3 * HOUR_IN_SECONDS ) > $next ) { |
641 while ( ( $now + 3 * HOUR_IN_SECONDS ) > $next ) { |
584 $next += 12 * HOUR_IN_SECONDS; |
642 $next += 12 * HOUR_IN_SECONDS; |
585 } |
643 } |
586 $next = $next - get_option( 'gmt_offset' ) * HOUR_IN_SECONDS; |
644 $next = $next - get_option( 'gmt_offset' ) * HOUR_IN_SECONDS; |
|
645 // Add a random number of minutes, so we don't have all sites trying to update exactly on the hour |
|
646 $next = $next + rand( 0, 59 ) * MINUTE_IN_SECONDS; |
587 wp_schedule_event( $next, 'twicedaily', 'wp_maybe_auto_update' ); |
647 wp_schedule_event( $next, 'twicedaily', 'wp_maybe_auto_update' ); |
588 } |
648 } |
589 } |
649 } |
590 |
650 |
591 if ( ( ! is_main_site() && ! is_network_admin() ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) |
651 /** |
|
652 * Clear existing update caches for plugins, themes, and core. |
|
653 * |
|
654 * @since 4.1.0 |
|
655 */ |
|
656 function wp_clean_update_cache() { |
|
657 if ( function_exists( 'wp_clean_plugins_cache' ) ) { |
|
658 wp_clean_plugins_cache(); |
|
659 } else { |
|
660 delete_site_transient( 'update_plugins' ); |
|
661 } |
|
662 wp_clean_themes_cache(); |
|
663 delete_site_transient( 'update_core' ); |
|
664 } |
|
665 |
|
666 if ( ( ! is_main_site() && ! is_network_admin() ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { |
592 return; |
667 return; |
|
668 } |
593 |
669 |
594 add_action( 'admin_init', '_maybe_update_core' ); |
670 add_action( 'admin_init', '_maybe_update_core' ); |
595 add_action( 'wp_version_check', 'wp_version_check' ); |
671 add_action( 'wp_version_check', 'wp_version_check' ); |
596 add_action( 'upgrader_process_complete', 'wp_version_check', 10, 0 ); |
672 add_action( 'upgrader_process_complete', 'wp_version_check', 10, 0 ); |
597 |
673 |
598 add_action( 'load-plugins.php', 'wp_update_plugins' ); |
674 add_action( 'load-plugins.php', 'wp_update_plugins' ); |
599 add_action( 'load-update.php', 'wp_update_plugins' ); |
675 add_action( 'load-update.php', 'wp_update_plugins' ); |
600 add_action( 'load-update-core.php', 'wp_update_plugins' ); |
676 add_action( 'load-update-core.php', 'wp_update_plugins' ); |
601 add_action( 'admin_init', '_maybe_update_plugins' ); |
677 add_action( 'admin_init', '_maybe_update_plugins' ); |
602 add_action( 'wp_update_plugins', 'wp_update_plugins' ); |
678 add_action( 'wp_update_plugins', 'wp_update_plugins' ); |
603 add_action( 'upgrader_process_complete', 'wp_update_plugins' ); |
679 add_action( 'upgrader_process_complete', 'wp_update_plugins', 10, 0 ); |
604 |
680 |
605 add_action( 'load-themes.php', 'wp_update_themes' ); |
681 add_action( 'load-themes.php', 'wp_update_themes' ); |
606 add_action( 'load-update.php', 'wp_update_themes' ); |
682 add_action( 'load-update.php', 'wp_update_themes' ); |
607 add_action( 'load-update-core.php', 'wp_update_themes' ); |
683 add_action( 'load-update-core.php', 'wp_update_themes' ); |
608 add_action( 'admin_init', '_maybe_update_themes' ); |
684 add_action( 'admin_init', '_maybe_update_themes' ); |
609 add_action( 'wp_update_themes', 'wp_update_themes' ); |
685 add_action( 'wp_update_themes', 'wp_update_themes' ); |
610 add_action( 'upgrader_process_complete', 'wp_update_themes' ); |
686 add_action( 'upgrader_process_complete', 'wp_update_themes', 10, 0 ); |
|
687 |
|
688 add_action( 'update_option_WPLANG', 'wp_clean_update_cache' , 10, 0 ); |
611 |
689 |
612 add_action( 'wp_maybe_auto_update', 'wp_maybe_auto_update' ); |
690 add_action( 'wp_maybe_auto_update', 'wp_maybe_auto_update' ); |
613 |
691 |
614 add_action('init', 'wp_schedule_update_checks'); |
692 add_action( 'init', 'wp_schedule_update_checks' ); |