Changeset 25421 for trunk/src/wp-includes/update.php
- Timestamp:
- 09/13/2013 06:18:16 AM (13 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/update.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/update.php
r25308 r25421 121 121 $updates->version_checked = $wp_version; 122 122 set_site_transient( 'update_core', $updates); 123 124 wp_auto_updates_maybe_queue( 'core' ); 123 125 } 124 126 … … 222 224 223 225 set_site_transient( 'update_plugins', $new_option ); 226 227 wp_auto_updates_maybe_queue( 'plugins' ); 224 228 } 225 229 … … 332 336 333 337 set_site_transient( 'update_themes', $new_update ); 338 339 wp_auto_updates_maybe_queue( 'themes' ); 340 } 341 342 /** 343 * Queues a cron entry if a potentially upgrade is detected. 344 * 345 * @since 3.7.0 346 * 347 * @param string $type The type of update to check for, may be 'core', 'plugins', or, 'themes'. 348 */ 349 function wp_auto_updates_maybe_queue( $type = 'core' ) { 350 include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php'; 351 include_once ABSPATH . '/wp-admin/includes/update.php'; 352 353 if ( WP_Automatic_Upgrader::upgrader_disabled() ) 354 return; 355 356 $updates_available = false; 357 if ( 'core' == $type ) { 358 $updates_available = (bool) find_core_auto_update(); 359 } elseif ( 'plugins' == $type ) { 360 $plugin_updates = get_site_transient( 'update_plugins' ); 361 $updates_available = !empty( $plugin_updates->response ); 362 } elseif ( 'themes' == $type ) { 363 $theme_updates = get_site_transient( 'update_themes' ); 364 $updates_available = empty( $theme_updates->response ); 365 } 366 367 if ( $updates_available && ! wp_next_scheduled( 'wp_auto_updates_execute' ) ) { 368 // If the transient update was triggered by a user pageview, update in an hours time, else, now. 369 $when_to_update = get_current_user_id() ? time() + HOUR_IN_SECONDS : time(); 370 $when_to_update = apply_filters( 'auto_upgrade_when_to_upgrade', $when_to_update ); 371 372 wp_schedule_single_event( $when_to_update, 'wp_auto_updates_execute' ); 373 } 374 375 } 376 377 function wp_auto_updates_execute() { 378 include_once ABSPATH . '/wp-admin/includes/admin.php'; 379 include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php'; 380 381 if ( WP_Automatic_Upgrader::upgrader_disabled() ) 382 return; 383 384 WP_Automatic_Upgrader::perform_auto_updates(); 334 385 } 335 386 … … 457 508 add_action( 'wp_update_themes', 'wp_update_themes' ); 458 509 510 // Automatic Updates - Cron callback 511 add_action( 'wp_auto_updates_execute', 'wp_auto_updates_execute' ); 512 459 513 add_action('init', 'wp_schedule_update_checks');
Note: See TracChangeset
for help on using the changeset viewer.