WordPress.org

Plugin Directory

Changeset 615006


Ignore:
Timestamp:
10/20/12 18:44:52 (18 months ago)
Author:
willmot
Message:

2.0.5 bug fix release

Location:
backupwordpress/tags/2.0.5
Files:
2 edited
11 copied

Legend:

Unmodified
Added
Removed
  • backupwordpress/tags/2.0.5/admin/actions.php

    r614508 r615006  
    165165function hmbkp_ajax_cron_test() { 
    166166 
    167     $response = wp_remote_get( site_url( 'wp-cron.php' ) ); 
     167    $response = wp_remote_head( site_url( 'wp-cron.php' ) ); 
    168168 
    169169    if ( is_wp_error( $response ) ) 
    170170        echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __( 'BackUpWordPress has detected a problem.', 'hmbkp' ) . '</strong> ' . sprintf( __( '%1$s is returning a %2$s response which could mean cron jobs aren\'t getting fired properly. BackUpWordPress relies on wp-cron to run scheduled back ups. See the %3$s for more details.', 'hmbkp' ), '<code>wp-cron.php</code>', '<code>' . $response->get_error_message() . '</code>', '<a href="http://wordpress.org/extend/plugins/backupwordpress/faq/">FAQ</a>' ) . '</p></div>'; 
    171171 
    172     else if ( $response['response']['code'] != 200 ) 
    173         echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __( 'BackUpWordPress has detected a problem.', 'hmbkp' ) . '</strong> ' . sprintf( __( '%1$s is returning a %2$s response which could mean cron jobs aren\'t getting fired properly. BackUpWordPress relies on wp-cron to run scheduled back ups. See the %3$s for more details.', 'hmbkp' ), '<code>wp-cron.php</code>', '<code>' . $response['response']['code'] . '</code>', '<a href="http://wordpress.org/extend/plugins/backupwordpress/faq/">FAQ</a>' ) . '</p></div>'; 
     172    elseif ( wp_remote_retrieve_response_code( $response ) != 200 ) 
     173        echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __( 'BackUpWordPress has detected a problem.', 'hmbkp' ) . '</strong> ' . sprintf( __( '%1$s is returning a %2$s response which could mean cron jobs aren\'t getting fired properly. BackUpWordPress relies on wp-cron to run scheduled back ups. See the %3$s for more details.', 'hmbkp' ), '<code>wp-cron.php</code>', '<code>' . wp_remote_retrieve_response_code( $response ) . ' ' . get_status_header_desc( wp_remote_retrieve_response_code( $response ) ) . '</code>', '<a href="http://wordpress.org/extend/plugins/backupwordpress/faq/">FAQ</a>' ) . '</p></div>'; 
    174174 
    175175    else 
  • backupwordpress/tags/2.0.5/admin/constants.php

    r602026 r615006  
    2626        <dd><p><?php printf( __( 'The root directory that is backed up. Defaults to %s.', 'hmbkp' ), '<code>' . HM_Backup::get_home_path() . '</code>' ); ?><p class="example"><?php _e( 'e.g.', 'hmbkp' ); ?> <code>define( 'HMBKP_ROOT', ABSPATH . 'wp/' );</code></p></dd> 
    2727 
     28        <dt<?php if ( defined( 'HMBKP_SCHEDULE_TIME' ) ) { ?> class="hmbkp_active"<?php } ?>><code>HMBKP_SCHEDULE_TIME</code></dt> 
     29        <dd><p><?php printf( __( 'The time that your schedules should run. Defaults to %s.', 'hmbkp' ), '<code>23:00</code>' ); ?><p class="example"><?php _e( 'e.g.', 'hmbkp' ); ?> <code>define( 'HMBKP_SCHEDULE_TIME', '07:30' );</code></p></dd> 
     30 
    2831    </dl> 
    2932 
  • backupwordpress/tags/2.0.5/admin/schedule.php

    r602026 r615006  
    88 
    99// Backup Time 
    10 $day = date_i18n( 'l', $schedule->get_next_occurrence() ); 
     10$day = date_i18n( 'l', $schedule->get_next_occurrence( false ) ); 
    1111 
    12 $next_backup = 'title="' . sprintf( __( 'The next backup will be on %1$s at %2$s', 'hmbkp' ), date_i18n( get_option( 'date_format' ), $schedule->get_next_occurrence() ), date_i18n( get_option( 'time_format' ), $schedule->get_next_occurrence() ) ) . '"'; 
     12$next_backup = 'title="' . sprintf( __( 'The next backup will be on %1$s at %2$s', 'hmbkp' ), date_i18n( get_option( 'date_format' ), $schedule->get_next_occurrence( false ) ), date_i18n( get_option( 'time_format' ), $schedule->get_next_occurrence( false ) ) ) . '"'; 
    1313 
    1414// Backup Re-occurrence 
     
    1717    case 'hourly' : 
    1818 
    19         $reoccurrence = date_i18n( get_option( 'time_format' ), $schedule->get_next_occurrence() ) === '00' ? sprintf( __( 'hourly on the hour', 'hmbkp' ) ) : sprintf( __( 'hourly at %s minutes past the hour', 'hmbkp' ), '<span ' . $next_backup . '>' . str_replace( '0', '', date_i18n( 'i', $schedule->get_next_occurrence() ) ) ) . '</span>'; 
     19        $reoccurrence = date_i18n( 'i', $schedule->get_next_occurrence( false ) ) === '00' ? sprintf( __( 'hourly on the hour', 'hmbkp' ) ) : sprintf( __( 'hourly at %s minutes past the hour', 'hmbkp' ), '<span ' . $next_backup . '>' . str_replace( '0', '', date_i18n( 'i', $schedule->get_next_occurrence( false ) ) ) ) . '</span>'; 
    2020 
    2121    break; 
     
    2323    case 'daily' : 
    2424 
    25         $reoccurrence = sprintf( __( 'daily at %s', 'hmbkp' ), '<span ' . $next_backup . '>' . date_i18n( get_option( 'time_format' ), $schedule->get_next_occurrence() ) . '</span>' ); 
     25        $reoccurrence = sprintf( __( 'daily at %s', 'hmbkp' ), '<span ' . $next_backup . '>' . date_i18n( get_option( 'time_format' ), $schedule->get_next_occurrence( false ) ) . '</span>' ); 
    2626 
    2727    break; 
     
    3030    case 'twicedaily' : 
    3131 
    32         $times[] = date_i18n( get_option( 'time_format' ), $schedule->get_next_occurrence() ); 
    33         $times[] = date_i18n( get_option( 'time_format' ), strtotime( '+ 12 hours', $schedule->get_next_occurrence() ) ); 
     32        $times[] = date_i18n( get_option( 'time_format' ), $schedule->get_next_occurrence( false ) ); 
     33        $times[] = date_i18n( get_option( 'time_format' ), strtotime( '+ 12 hours', $schedule->get_next_occurrence( false ) ) ); 
    3434 
    3535        sort( $times ); 
     
    4141    case 'weekly' : 
    4242 
    43         $reoccurrence = sprintf( __( 'weekly on %1$s at %2$s', 'hmbkp' ), '<span ' . $next_backup . '>' . $day . '</span>', '<span>' . date_i18n( get_option( 'time_format' ), $schedule->get_next_occurrence() ) . '</span>' ); 
     43        $reoccurrence = sprintf( __( 'weekly on %1$s at %2$s', 'hmbkp' ), '<span ' . $next_backup . '>' . $day . '</span>', '<span>' . date_i18n( get_option( 'time_format' ), $schedule->get_next_occurrence( false ) ) . '</span>' ); 
    4444 
    4545    break; 
     
    4747    case 'fortnightly' : 
    4848 
    49         $reoccurrence = sprintf( __( 'fortnightly on %1$s at %2$s', 'hmbkp' ), '<span ' . $next_backup . '>' . $day . '</span>', '<span>' . date_i18n( get_option( 'time_format' ), $schedule->get_next_occurrence() ) . '</span>' ); 
     49        $reoccurrence = sprintf( __( 'fortnightly on %1$s at %2$s', 'hmbkp' ), '<span ' . $next_backup . '>' . $day . '</span>', '<span>' . date_i18n( get_option( 'time_format' ), $schedule->get_next_occurrence( false ) ) . '</span>' ); 
    5050 
    5151    break; 
     
    5454    case 'monthly' : 
    5555 
    56         $reoccurrence = sprintf( __( 'on the %1$s of each month at %2$s', 'hmbkp' ), '<span ' . $next_backup . '>' . date_i18n( 'jS', $schedule->get_next_occurrence() ) . '</span>', '<span>' . date_i18n( get_option( 'time_format' ), $schedule->get_next_occurrence() ) . '</span>' ); 
     56        $reoccurrence = sprintf( __( 'on the %1$s of each month at %2$s', 'hmbkp' ), '<span ' . $next_backup . '>' . date_i18n( 'jS', $schedule->get_next_occurrence( false ) ) . '</span>', '<span>' . date_i18n( get_option( 'time_format' ), $schedule->get_next_occurrence( false ) ) . '</span>' ); 
    5757 
    5858    break; 
  • backupwordpress/tags/2.0.5/classes/schedule.php

    r614508 r615006  
    5050 
    5151    /** 
    52      * Take a file size and return a human readable 
    53      * version 
    54      * 
    55      * @access public 
    56      * @static 
    57      * @param int $size 
    58      * @param string $unit. (default: null) 
    59      * @param string $format. (default: '%01.2f %s') 
    60      * @param bool $si. (default: true) 
    61      * @return int 
    62      */ 
    63     public static function human_filesize( $size, $unit = null, $format = '%01.2f %s', $si = true ) { 
    64  
    65         // Units 
    66         if ( $si === true ) : 
    67             $sizes = array( 'B', 'kB', 'MB', 'GB', 'TB', 'PB' ); 
    68             $mod   = 1000; 
    69  
    70         else : 
    71             $sizes = array('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB'); 
    72             $mod   = 1024; 
    73  
    74         endif; 
    75  
    76         $ii = count( $sizes ) - 1; 
    77  
    78         // Max unit 
    79         $unit = array_search( (string) $unit, $sizes ); 
    80  
    81         if ( is_null( $unit ) || $unit === false ) 
    82             $unit = $ii; 
    83  
    84         // Loop 
    85         $i = 0; 
    86  
    87         while ( $unit != $i && $size >= 1024 && $i < $ii ) { 
    88             $size /= $mod; 
    89             $i++; 
    90         } 
    91  
    92         return sprintf( $format, $size, $sizes[$i] ); 
    93  
    94     } 
    95  
    96     /** 
    9752     * Setup the schedule object 
    9853     * 
     
    14297        $this->set_archive_filename( implode( '-', array( get_bloginfo( 'name' ), $this->get_id(), $this->get_type(), date( 'Y-m-d-H-i-s', current_time( 'timestamp' ) ) ) ) . '.zip' ); 
    14398 
     99        // Setup the schedule if it isn't set or TODO if it's changed 
     100        if ( ( ! $this->get_next_occurrence() && in_array( $this->get_reoccurrence(), array_keys( wp_get_schedules() ) ) ) || ( date( get_option( 'time_format' ), strtotime( HMBKP_SCHEDULE_TIME ) - ( get_option( 'gmt_offset' ) * 3600 ) ) !== date( get_option( 'time_format' ), $this->get_next_occurrence() ) ) ) 
     101            $this->schedule(); 
     102 
    144103    } 
    145104 
     
    366325        } 
    367326 
    368         return self::human_filesize( $filesize, null, '%01u %s' ); 
     327        return size_format( $filesize ); 
    369328 
    370329    } 
     
    404363        if ( ! $this->schedule_start_time ) { 
    405364 
    406             if ( strtotime( '11pm' ) < strtotime( 'now' ) ) 
    407                 $date = strtotime( 'tomorrow 11pm' ); 
    408             else 
    409                 $date = strtotime( '11pm' ); 
    410  
    411             $date -= ( get_option( 'gmt_offset' ) * 3600 ); 
    412              
     365            $date = strtotime( HMBKP_SCHEDULE_TIME ); 
     366 
     367            // Convert to UTC 
     368            $date -= get_option( 'gmt_offset' ) * 3600; 
     369 
     370            // if the scheduled time already passed today then start at the next interval instead 
     371            if ( $date <= strtotime( 'now' ) ) 
     372                $date += $this->get_interval(); 
     373 
    413374            $this->set_schedule_start_time( $date ); 
    414375        } 
     376 
    415377        return $this->schedule_start_time; 
    416378 
     
    421383     * 
    422384     * @access public 
    423      * @param int $timestamp 
     385     * @param int $timestamp in UTC 
    424386     * @return void 
    425387     */ 
     
    495457     * @access public 
    496458     */ 
    497     public function get_next_occurrence() { 
    498  
    499         return wp_next_scheduled( 'hmbkp_schedule_hook', array( 'id' => $this->get_id() ) ); 
    500  
    501     } 
    502  
     459    public function get_next_occurrence( $gmt = true ) { 
     460 
     461        $time = wp_next_scheduled( 'hmbkp_schedule_hook', array( 'id' => $this->get_id() ) ); 
     462 
     463        if ( ! $time ) 
     464            $time = 0; 
     465 
     466        if ( ! $gmt ) 
     467            $time += get_option( 'gmt_offset' ) * 3600; 
     468 
     469        return $time; 
     470 
     471    } 
     472 
     473 
     474    /** 
     475     * Get the path to the backup running file that stores the running backup status 
     476     * 
     477     * @access private 
     478     * @return string 
     479     */ 
    503480    private function get_schedule_running_path() { 
    504481        return $this->get_path() . '/.schedule-' . $this->get_id() . '-running'; 
     
    506483 
    507484    /** 
    508      * Schedule the cron 
     485     * Schedule the backup cron 
    509486     * 
    510487     * @access public 
     
    516493 
    517494        wp_schedule_event( $this->get_schedule_start_time(), $this->get_reoccurrence(), 'hmbkp_schedule_hook', array( 'id' => $this->get_id() ) ); 
    518     } 
    519  
     495 
     496    } 
     497 
     498 
     499    /** 
     500     * Unschedule the backup cron. 
     501     * 
     502     * @access public 
     503     * @return void 
     504     */ 
    520505    public function unschedule() { 
    521506        wp_clear_scheduled_hook( 'hmbkp_schedule_hook', array( 'id' => $this->get_id() ) ); 
  • backupwordpress/tags/2.0.5/functions/core.php

    r614508 r615006  
    3434    delete_transient( 'hmbkp_estimated_filesize' ); 
    3535 
    36     // Clear cron 
    37     wp_clear_scheduled_hook( 'hmbkp_schedule_backup_hook' ); 
    38     wp_clear_scheduled_hook( 'hmbkp_schedule_single_backup_hook' ); 
     36    // Clear hmbkp crons 
     37    foreach( get_option( 'cron' ) as $cron ) 
     38        foreach( $cron as $key => $value ) 
     39            if ( strpos( $key, 'hmbkp' ) !== false ) 
     40                wp_clear_scheduled_hook( $key ); 
    3941 
    4042    hmbkp_cleanup(); 
     
    8890 
    8991    // Version 1 to 2 
    90     if ( version_compare ( '2.0' , get_option( 'hmbkp_plugin_version' ) ) ) { 
     92    if ( version_compare( '2.0' , get_option( 'hmbkp_plugin_version' ), '>' ) ) { 
    9193 
    9294        /** 
     
    140142 
    141143        // Remove the legacy options 
    142         foreach ( array( 'hmbkp_email', 'hmbkp_database_only', 'hmbkp_files_only', 'hmbkp_max_backups', 'hmbkp_email_address', 'hmbkp_email', 'hmbkp_schedule_frequency', 'hmbkp_disable_automatic_backup' ) as $option_name ) 
     144        foreach ( array( 'hmbkp_database_only', 'hmbkp_files_only', 'hmbkp_max_backups', 'hmbkp_email_address', 'hmbkp_email', 'hmbkp_schedule_frequency', 'hmbkp_disable_automatic_backup' ) as $option_name ) 
    143145            delete_option( $option_name ); 
    144146 
  • backupwordpress/tags/2.0.5/functions/interface.php

    r611550 r615006  
    99 
    1010    $encoded_file = urlencode( base64_encode( $file ) ); 
    11     $offset = current_time( 'timestamp' ) - time(); ?> 
     11    $offset = get_option( 'gmt_offset' ) * 3600; ?> 
    1212 
    1313    <tr class="hmbkp_manage_backups_row<?php if ( file_exists( hmbkp_path() . '/.backup_complete' ) ) : ?> completed<?php unlink( hmbkp_path() . '/.backup_complete' ); endif; ?>"> 
     
    1818 
    1919        <td class="code"> 
    20             <?php echo esc_attr( HMBKP_Scheduled_Backup::human_filesize( @filesize( $file ) ) ); ?> 
     20            <?php echo esc_attr( size_format( @filesize( $file ) ) ); ?> 
    2121        </td> 
    2222 
  • backupwordpress/tags/2.0.5/plugin.php

    r614647 r615006  
    66Description: Simple automated backups of your WordPress powered website. Once activated you'll find me under <strong>Tools &rarr; Backups</strong>. 
    77Author: Human Made Limited 
    8 Version: 2.0.4 
     8Version: 2.0.5 
    99Author URI: http://hmn.md/ 
    1010*/ 
     
    4545if ( ! defined( 'WP_MAX_MEMORY_LIMIT' ) ) 
    4646    define( 'WP_MAX_MEMORY_LIMIT', '256M' ); 
     47 
     48if ( ! defined( 'HMBKP_SCHEDULE_TIME' ) ) 
     49    define( 'HMBKP_SCHEDULE_TIME', '11pm' ); 
    4750 
    4851// Don't activate on anything less than PHP 5.2.4 
  • backupwordpress/tags/2.0.5/readme.txt

    r614647 r615006  
    44Requires at least: 3.3.3 
    55Tested up to: 3.5 
    6 Stable tag: 2.0.4 
     6Stable tag: 2.0.5 
    77 
    88Simple automated back ups of your WordPress powered website. 
     
    103103 
    104104== Changelog == 
     105 
     106#### 2.0.5 
     107 
     108* Re-setup the cron schedules if they get deleted somehow. 
     109* Delete all BackUpWordPress cron entries when the plugin is deactivated. 
     110* Introduce the `HMBKP_SCHEDULE_TIME` constant to allow control over the time schedules run. 
     111* Make sure the schedule times and times of previous backups are shown in local time. 
     112* Fix a bug that could cause the legacy backup schedule to be created on every update, not just when going from 1.x to 2.x. 
     113* Improve the usefulness of the `wp-cron.php` response code check. 
     114* Use the built in `site_format` function for human readable filesizes instead of defining our own function. 
     115 
    105116 
    106117#### 2.0.4 
Note: See TracChangeset for help on using the changeset viewer.