WordPress.org

Plugin Directory

Changeset 612226 for automatic-updater


Ignore:
Timestamp:
10/14/12 11:01:19 (18 months ago)
Author:
pento
Message:

Added support for automatically updating a nightly build every 24 hours

Location:
automatic-updater/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • automatic-updater/trunk/automatic-updater.php

    r612113 r612226  
    4848                    'svn' => false, 
    4949                    'debug' => false, 
     50                    'next-development-update' => time(), 
    5051                ); 
    5152        update_option( 'automatic-updater', $options ); 
     
    6162    if ( ! array_key_exists( 'svn', $options ) ) { 
    6263        $options['svn'] = false; 
     64        update_option( 'automatic-updater', $options ); 
     65    } 
     66 
     67    // Development version updates added in version 0.6 
     68    if ( ! array_key_exists( 'next-development-update', $options ) ) { 
     69        $options['next-development-update'] = time(); 
    6370        update_option( 'automatic-updater', $options ); 
    6471    } 
     
    124131        return; 
    125132 
    126     $update = apply_filters( 'auto_updater_core_updates', find_core_update( $updates[0]->current, $updates[0]->locale ) ); 
     133    if ( 'development' == $updates[0]->response ) 
     134        $update = $updates[0]; 
     135    else 
     136        $update = find_core_update( $updates[0]->current, $updates[0]->locale ); 
     137 
     138    $update = apply_filters( 'auto_updater_core_updates', $update ); 
    127139    if ( empty( $update ) ) 
    128140        return; 
     
    131143 
    132144    // Sanity check that the new upgrade is actually an upgrade 
    133     if ( version_compare( $old_version, $update->current, '>=' ) ) 
    134         return; 
     145    if ( 'development' != $update->response && version_compare( $old_version, $update->current, '>=' ) ) 
     146        return; 
     147 
     148    // Only do development version updates once every 24 hours 
     149    if ( 'development' == $update->response ) { 
     150        if ( time() < $options['next-development-update'] ) 
     151            return; 
     152 
     153        $options['next-development-update'] = strtotime( '+24 hours' ); 
     154        update_option( 'automatic-updater', $options ); 
     155    } 
    135156 
    136157    $auto_updater_running = true; 
     
    148169        $message .= "\r\n\r\n" . $result->get_error_message() . "\r\n\r\n"; 
    149170        $message .= __( "We're sorry it didn't work out. Please try upgrading manually, instead.", 'automatic-updater' ); 
     171    } 
     172    else if( 'development' == $update->response ) { 
     173        $message = __( "We've successfully upgraded WordPress to the latest nightly build!", 'automatic-updater' ); 
     174        $message .= "\r\n\r\n" . __( 'Have fun!', 'automatic-updater' ); 
    150175    } 
    151176    else { 
     
    351376    if ( function_exists( 'get_core_updates' ) ) { 
    352377        $update_wordpress = get_core_updates( array( 'dismissed' => false ) ); 
    353         if ( ! empty( $update_wordpress ) && ! in_array( $update_wordpress[0]->response, array( 'development', 'latest' ) ) ) 
     378        if ( ! empty( $update_wordpress ) && 'latest' != $update_wordpress[0]->response ) 
    354379            $counts['wordpress'] = 1; 
    355380    } 
  • automatic-updater/trunk/readme.txt

    r612111 r612226  
    4242== Changelog == 
    4343 
    44 = 0.5.1 = 
    45 * ADDED: Dutch (nl_NL) translation. Props Trifon Rijksen. 
     44= 0.6 = 
     45* ADDED: Support for nightly builds 
     46* ADDED: Dutch (nl_NL) translation. Props Trifon Rijksen 
    4647 
    4748= 0.5 = 
Note: See TracChangeset for help on using the changeset viewer.