Make WordPress Core


Ignore:
Timestamp:
09/13/2013 06:18:16 AM (13 years ago)
Author:
dd32
Message:

WordPress Core Automatic Updates: Add the first slice of Automatic Upgrades, This is presently disabled, and requires a filter to enable ( 'auto_upgrade_core' ). See #22704

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/update.php

    r25307 r25421  
    5858}
    5959
     60/**
     61 * Gets the best available (and enabled) Auto-Update for WordPress Core.
     62 *
     63 * If there's 1.2.3 and 1.3 on offer, it'll choose 1.3 if the install allows it, else, 1.2.3
     64 *
     65 * @since 3.7.0
     66 *
     67 * @return bool|array False on failure, otherwise the core update offering.
     68 */
     69function find_core_auto_update() {
     70    $updates = get_site_transient( 'update_core' );
     71    if ( ! $updates || empty( $updates->updates ) )
     72        return false;
     73
     74    include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     75
     76    $auto_update = false;
     77    foreach ( $updates->updates as $update ) {
     78        if ( 'autoupdate' != $update->response )
     79            continue;
     80
     81        if ( ! WP_Automatic_Upgrader::should_auto_update( 'core', $update, ABSPATH ) )
     82            continue;
     83
     84        if ( ! $auto_update || version_compare( $update->current, $auto_update->current, '>' ) )
     85            $auto_update = $update;
     86    }
     87    return $auto_update;
     88}
     89
    6090function dismiss_core_update( $update ) {
    6191    $dismissed = get_site_option( 'dismissed_update_core' );
Note: See TracChangeset for help on using the changeset viewer.