BackUpWordPress - Version 2.0.3

Version Description

Download this release

Release Info

Developer willmot
Plugin Icon 128x128 BackUpWordPress
Version 2.0.3
Comparing to
See all releases

Code changes from version 2.0.2 to 2.0.3

admin/actions.php CHANGED
@@ -166,7 +166,10 @@ function hmbkp_ajax_cron_test() {
166
 
167
  $response = wp_remote_get( site_url( 'wp-cron.php' ) );
168
 
169
- if ( is_wp_error( $response ) || $response['response']['code'] !== 200 )
 
 
 
170
  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>';
171
 
172
  else
166
 
167
  $response = wp_remote_get( site_url( 'wp-cron.php' ) );
168
 
169
+ if ( is_wp_error( $response ) )
170
+ 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>';
171
+
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>';
174
 
175
  else
classes/schedule.php CHANGED
@@ -31,14 +31,6 @@ class HMBKP_Scheduled_Backup extends HM_Backup {
31
  */
32
  private $options = array();
33
 
34
- /**
35
- * The unique hook name for this schedule
36
- *
37
- * @var string
38
- * @access private
39
- */
40
- private $schedule_hook = '';
41
-
42
  /**
43
  * The filepath for the .running file which
44
  * is used to track whether a backup is currently in
@@ -124,9 +116,6 @@ class HMBKP_Scheduled_Backup extends HM_Backup {
124
  // Load the options
125
  $this->options = array_filter( (array) get_option( 'hmbkp_schedule_' . $this->get_id() ) );
126
 
127
- // Setup the schedule hook
128
- $this->schedule_hook = 'hmbkp_schedule_' . $this->get_id() . '_hook';
129
-
130
  // Some properties can be overridden with defines
131
  if ( defined( 'HMBKP_ROOT' ) && HMBKP_ROOT )
132
  $this->set_root( HMBKP_ROOT );
@@ -412,9 +401,17 @@ class HMBKP_Scheduled_Backup extends HM_Backup {
412
  if ( $this->get_reoccurrence() === 'manually' )
413
  return 0;
414
 
415
- if ( ! $this->schedule_start_time )
416
- $this->set_schedule_start_time( current_time( 'timestamp' ) );
 
 
 
 
417
 
 
 
 
 
418
  return $this->schedule_start_time;
419
 
420
  }
@@ -499,7 +496,7 @@ class HMBKP_Scheduled_Backup extends HM_Backup {
499
  */
500
  public function get_next_occurrence() {
501
 
502
- return wp_next_scheduled( $this->schedule_hook );
503
 
504
  }
505
 
@@ -517,15 +514,11 @@ class HMBKP_Scheduled_Backup extends HM_Backup {
517
  // Clear any existing hooks
518
  $this->unschedule();
519
 
520
- wp_schedule_event( $this->get_schedule_start_time() + $this->get_interval(), $this->get_reoccurrence(), $this->schedule_hook );
521
-
522
- // Hook the backu into the schedule hook
523
- add_action( $this->schedule_hook, array( $this, 'run' ) );
524
-
525
  }
526
 
527
  public function unschedule() {
528
- wp_clear_scheduled_hook( $this->schedule_hook );
529
  }
530
 
531
  /**
@@ -668,6 +661,7 @@ class HMBKP_Scheduled_Backup extends HM_Backup {
668
  *
669
  * @todo look into using recursiveDirectoryIterator and recursiveRegexIterator
670
  * @access public
 
671
  */
672
  public function get_backups() {
673
 
31
  */
32
  private $options = array();
33
 
 
 
 
 
 
 
 
 
34
  /**
35
  * The filepath for the .running file which
36
  * is used to track whether a backup is currently in
116
  // Load the options
117
  $this->options = array_filter( (array) get_option( 'hmbkp_schedule_' . $this->get_id() ) );
118
 
 
 
 
119
  // Some properties can be overridden with defines
120
  if ( defined( 'HMBKP_ROOT' ) && HMBKP_ROOT )
121
  $this->set_root( HMBKP_ROOT );
401
  if ( $this->get_reoccurrence() === 'manually' )
402
  return 0;
403
 
404
+ if ( ! $this->schedule_start_time ) {
405
+
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
+
413
+ $this->set_schedule_start_time( $date );
414
+ }
415
  return $this->schedule_start_time;
416
 
417
  }
496
  */
497
  public function get_next_occurrence() {
498
 
499
+ return wp_next_scheduled( 'hmbkp_schedule_hook', array( 'id' => $this->get_id() ) );
500
 
501
  }
502
 
514
  // Clear any existing hooks
515
  $this->unschedule();
516
 
517
+ wp_schedule_event( $this->get_schedule_start_time(), $this->get_reoccurrence(), 'hmbkp_schedule_hook', array( 'id' => $this->get_id() ) );
 
 
 
 
518
  }
519
 
520
  public function unschedule() {
521
+ wp_clear_scheduled_hook( 'hmbkp_schedule_hook', array( 'id' => $this->get_id() ) );
522
  }
523
 
524
  /**
661
  *
662
  * @todo look into using recursiveDirectoryIterator and recursiveRegexIterator
663
  * @access public
664
+ * @return string[] - file paths of the backups
665
  */
666
  public function get_backups() {
667
 
classes/schedules.php CHANGED
@@ -40,6 +40,20 @@ class HMBKP_Schedules {
40
  return $this->schedules;
41
  }
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  /**
44
  * Instantiate the individual scheduled backup objects
45
  *
40
  return $this->schedules;
41
  }
42
 
43
+ /**
44
+ * Get a schedule by ID
45
+ *
46
+ * @return HMBKP_Scheduled_Backup
47
+ */
48
+ public function get_schedule( $id ) {
49
+
50
+ foreach ( $this->schedules as $schedule )
51
+ if ( $schedule->get_id() == $id )
52
+ return $schedule;
53
+
54
+ return null;
55
+ }
56
+
57
  /**
58
  * Instantiate the individual scheduled backup objects
59
  *
classes/services.php CHANGED
@@ -90,7 +90,7 @@ abstract class HMBKP_Service {
90
 
91
  $errors = $this->update( $new_data, $old_data );
92
 
93
- if ( $errors = array_flip( $errors ) ) {
94
 
95
  foreach( $errors as $error => &$field )
96
  $field = get_class( $this ) . '[' . $field . ']';
90
 
91
  $errors = $this->update( $new_data, $old_data );
92
 
93
+ if ( $errors && $errors = array_flip( $errors ) ) {
94
 
95
  foreach( $errors as $error => &$field )
96
  $field = get_class( $this ) . '[' . $field . ']';
functions/core.php CHANGED
@@ -198,6 +198,7 @@ function hmbkp_setup_default_schedules() {
198
  add_action( 'admin_notices', 'hmbkp_default_schedules_setup_warning' );
199
 
200
  }
 
201
 
202
  /**
203
  * Add weekly, fortnightly and monthly as a cron schedule choices
198
  add_action( 'admin_notices', 'hmbkp_default_schedules_setup_warning' );
199
 
200
  }
201
+ add_action( 'admin_init', 'hmbkp_setup_default_schedules' );
202
 
203
  /**
204
  * Add weekly, fortnightly and monthly as a cron schedule choices
hm-backup/hm-backup.php CHANGED
@@ -3,7 +3,7 @@
3
  /**
4
  * Generic file and database backup class
5
  *
6
- * @version 2.0 RC1
7
  */
8
  class HM_Backup {
9
 
3
  /**
4
  * Generic file and database backup class
5
  *
6
+ * @version 2.0
7
  */
8
  class HM_Backup {
9
 
plugin.php CHANGED
@@ -5,7 +5,7 @@ Plugin Name: BackUpWordPress
5
  Plugin URI: http://hmn.md/backupwordpress/
6
  Description: Simple automated backups of your WordPress powered website. Once activated you'll find me under <strong>Tools &rarr; Backups</strong>.
7
  Author: Human Made Limited
8
- Version: 2.0.1
9
  Author URI: http://hmn.md/
10
  */
11
 
@@ -26,17 +26,20 @@ Author URI: http://hmn.md/
26
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27
  */
28
 
29
- define( 'HMBKP_PLUGIN_SLUG', 'backupwordpress' );
30
- define( 'HMBKP_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
31
- define( 'HMBKP_PLUGIN_URL', plugins_url( HMBKP_PLUGIN_SLUG ) );
32
 
33
- if ( ! defined( 'HMBKP_REQUIRED_WP_VERSION' ) )
34
- define( 'HMBKP_REQUIRED_WP_VERSION', '3.3.2' );
 
 
 
35
 
36
- define( 'HMBKP_ADMIN_URL', add_query_arg( 'page', HMBKP_PLUGIN_SLUG, admin_url( 'tools.php' ) ) );
 
37
 
38
- if ( ! defined( 'HMBKP_SECURE_KEY' ) )
39
- define( 'HMBKP_SECURE_KEY', md5( ABSPATH . time() ) );
40
 
41
  // Max memory limit isn't defined in old versions of WordPress
42
  if ( ! defined( 'WP_MAX_MEMORY_LIMIT' ) )
@@ -64,6 +67,42 @@ if ( version_compare( get_bloginfo( 'version' ), HMBKP_REQUIRED_WP_VERSION, '<'
64
 
65
  }
66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  /**
68
  * Plugin setup
69
  *
@@ -103,45 +142,27 @@ function hmbkp_init() {
103
 
104
  }
105
 
106
- hmbkp_setup_default_schedules();
107
-
108
  // Handle any advanced option changes
109
- // TODO
110
  hmbkp_constant_changes();
111
 
112
  }
113
  add_action( 'admin_init', 'hmbkp_init' );
114
 
115
- // Load the admin menu
116
- require_once( HMBKP_PLUGIN_PATH . '/admin/menu.php' );
117
- require_once( HMBKP_PLUGIN_PATH . '/admin/actions.php' );
118
-
119
- // Load hm-backup
120
- if ( ! class_exists( 'HM_Backup' ) )
121
- require_once( HMBKP_PLUGIN_PATH . '/hm-backup/hm-backup.php' );
122
-
123
- // Load the schedules
124
- require_once( HMBKP_PLUGIN_PATH . '/classes/schedule.php' );
125
- require_once( HMBKP_PLUGIN_PATH . '/classes/schedules.php' );
126
-
127
- // Load the core functions
128
- require_once( HMBKP_PLUGIN_PATH . '/functions/core.php' );
129
- require_once( HMBKP_PLUGIN_PATH . '/functions/interface.php' );
130
 
131
- // Load Services
132
- require_once( HMBKP_PLUGIN_PATH . '/classes/services.php' );
133
 
134
- // Load the email service
135
- require_once( HMBKP_PLUGIN_PATH . '/classes/email.php' );
136
 
137
- // Load the wp cli command
138
- if ( defined( 'WP_CLI' ) && WP_CLI )
139
- include( HMBKP_PLUGIN_PATH . '/classes/wp-cli.php' );
140
 
141
- // Set the tmp directory to the backup path
142
- if ( ! defined( 'PCLZIP_TEMPORARY_DIR' ) )
143
- define( 'PCLZIP_TEMPORARY_DIR', trailingslashit( hmbkp_path() ) );
144
 
145
- // Hook in the activation and deactivation actions
146
- add_action( 'activate_' . HMBKP_PLUGIN_SLUG . '/plugin.php', 'hmbkp_activate' );
147
- add_action( 'deactivate_' . HMBKP_PLUGIN_SLUG . '/plugin.php', 'hmbkp_deactivate' );
5
  Plugin URI: http://hmn.md/backupwordpress/
6
  Description: Simple automated backups of your WordPress powered website. Once activated you'll find me under <strong>Tools &rarr; Backups</strong>.
7
  Author: Human Made Limited
8
+ Version: 2.0.3
9
  Author URI: http://hmn.md/
10
  */
11
 
26
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27
  */
28
 
29
+ if ( ! defined( 'HMBKP_PLUGIN_SLUG' ) )
30
+ define( 'HMBKP_PLUGIN_SLUG', 'backupwordpress' );
 
31
 
32
+ if ( ! defined( 'HMBKP_PLUGIN_PATH' ) )
33
+ define( 'HMBKP_PLUGIN_PATH', dirname( __FILE__ ) );
34
+
35
+ if ( ! defined( 'HMBKP_PLUGIN_URL' ) )
36
+ define( 'HMBKP_PLUGIN_URL', str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, HMBKP_PLUGIN_PATH ) );
37
 
38
+ if ( ! defined( 'HMBKP_ADMIN_URL' ) )
39
+ define( 'HMBKP_ADMIN_URL', add_query_arg( 'page', HMBKP_PLUGIN_SLUG, admin_url( 'tools.php' ) ) );
40
 
41
+ if ( ! defined( 'HMBKP_REQUIRED_WP_VERSION' ) )
42
+ define( 'HMBKP_REQUIRED_WP_VERSION', '3.3.3' );
43
 
44
  // Max memory limit isn't defined in old versions of WordPress
45
  if ( ! defined( 'WP_MAX_MEMORY_LIMIT' ) )
67
 
68
  }
69
 
70
+ // Load the admin menu
71
+ require_once( HMBKP_PLUGIN_PATH . '/admin/menu.php' );
72
+ require_once( HMBKP_PLUGIN_PATH . '/admin/actions.php' );
73
+
74
+ // Load hm-backup
75
+ if ( ! class_exists( 'HM_Backup' ) )
76
+ require_once( HMBKP_PLUGIN_PATH . '/hm-backup/hm-backup.php' );
77
+
78
+ // Load the schedules
79
+ require_once( HMBKP_PLUGIN_PATH . '/classes/schedule.php' );
80
+ require_once( HMBKP_PLUGIN_PATH . '/classes/schedules.php' );
81
+
82
+ // Load the core functions
83
+ require_once( HMBKP_PLUGIN_PATH . '/functions/core.php' );
84
+ require_once( HMBKP_PLUGIN_PATH . '/functions/interface.php' );
85
+
86
+ // Load Services
87
+ require_once( HMBKP_PLUGIN_PATH . '/classes/services.php' );
88
+
89
+ // Load the email service
90
+ require_once( HMBKP_PLUGIN_PATH . '/classes/email.php' );
91
+
92
+ // Load the wp cli command
93
+ if ( defined( 'WP_CLI' ) && WP_CLI )
94
+ include( HMBKP_PLUGIN_PATH . '/classes/wp-cli.php' );
95
+
96
+ // Set the tmp directory to the backup path
97
+ if ( ! defined( 'PCLZIP_TEMPORARY_DIR' ) )
98
+ define( 'PCLZIP_TEMPORARY_DIR', trailingslashit( hmbkp_path() ) );
99
+
100
+ // Hook in the activation and deactivation actions
101
+ add_action( 'activate_' . HMBKP_PLUGIN_SLUG . '/plugin.php', 'hmbkp_activate' );
102
+ add_action( 'deactivate_' . HMBKP_PLUGIN_SLUG . '/plugin.php', 'hmbkp_deactivate' );
103
+
104
+ if ( ! function_exists( 'hmbkp_init' ) ) :
105
+
106
  /**
107
  * Plugin setup
108
  *
142
 
143
  }
144
 
 
 
145
  // Handle any advanced option changes
 
146
  hmbkp_constant_changes();
147
 
148
  }
149
  add_action( 'admin_init', 'hmbkp_init' );
150
 
151
+ /**
152
+ * Function to run when the schedule cron fires
153
+ * @param array $args
154
+ */
155
+ function hmbkp_schedule_hook_run( $schedule_id ) {
 
 
 
 
 
 
 
 
 
 
156
 
157
+ $schedules = new HMBKP_Schedules();
158
+ $schedule = $schedules->get_schedule( $schedule_id );
159
 
160
+ if ( ! $schedule )
161
+ return;
162
 
163
+ $schedule->run();
 
 
164
 
165
+ }
166
+ add_action( 'hmbkp_schedule_hook', 'hmbkp_schedule_hook_run' );
 
167
 
168
+ endif;
 
 
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: humanmade, joehoyle, mattheu, tcrsavage, willmot, cuvelier
3
  Tags: back up, backup, backups, database, zip, db, files, archive, wp-cli, humanmade
4
  Requires at least: 3.3.3
5
- Tested up to: 3.4.2
6
- Stable tag: 2.0.1
7
 
8
  Simple automated back ups of your WordPress powered website.
9
 
@@ -103,6 +103,21 @@ You can also tweet <a href="http://twitter.com/humanmadeltd">@humanmadeltd</a> o
103
 
104
  == Changelog ==
105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  #### 2.0.1
107
 
108
  * Fix fatal error on PHP 5.2.
2
  Contributors: humanmade, joehoyle, mattheu, tcrsavage, willmot, cuvelier
3
  Tags: back up, backup, backups, database, zip, db, files, archive, wp-cli, humanmade
4
  Requires at least: 3.3.3
5
+ Tested up to: 3.5
6
+ Stable tag: 2.0.3
7
 
8
  Simple automated back ups of your WordPress powered website.
9
 
103
 
104
  == Changelog ==
105
 
106
+ #### 2.0.3
107
+
108
+ * Fix issues with scheduled backups not firing in some cases.
109
+ * Better compatibility when the WP Remote plugin is active alongside BackUpWordPress.
110
+ * Catch and display more WP Cron errors.
111
+ * BackUpWordPress now fails to activate on WordPress 3.3.2 and below.
112
+ * Other minor fixes and improvements.
113
+
114
+ #### 2.0.2
115
+
116
+ * Only send backup failed emails if the backup actually failed.
117
+ * Turn off the generic "memory limit probably hit" message as it was showing for too many people.
118
+ * Fix a possible notice when the backup running filename is blank.
119
+ * Include the `wp_error` response in the cron check.
120
+
121
  #### 2.0.1
122
 
123
  * Fix fatal error on PHP 5.2.