Advanced Automatic Updates - Version 0.9

Version Description

  • ADDED: Warning when Better WP Security is hiding update info
  • ADDED: Warning when the user can't update directly, but hasn't defined S/FTP login details
  • ADDED: AUTOMATIC_UPDATER_DISABLED wp-config option, for forcing updates to never happen
  • ADDED: Sanity check to make sure the plugin isn't accessed directly
  • CHANGED: For nightly build upgrade notification emails, include the build numbers
  • UPDATED: Tested up to WordPress 3.6
  • FIXED: Don't send a notification email if the core upgrade didn't change versions (ie, a nightly build with no changes)
  • FIXED: Settings page CSS wasn't loading if the plugin was installed in a symlink directory
  • FIXED: Themes and plugins in non-writeable directories weren't being highlighted correctly on the settings page
  • FIXED: Core upgrade retry emails were not showing the correct retry limit
  • FIXED: Nightly core upgrades can sometimes repeat more than once every 24 hours
Download this release

Release Info

Developer pento
Plugin Icon wp plugin Advanced Automatic Updates
Version 0.9
Comparing to
See all releases

Code changes from version 0.8.5 to 0.9

Files changed (5) hide show
  1. admin.php +83 -21
  2. automatic-updater.php +57 -24
  3. js/admin.js +28 -0
  4. readme.txt +15 -4
  5. updater-skin.php +2 -3
admin.php CHANGED
@@ -2,6 +2,7 @@
2
 
3
  class Automatic_Updater_Admin {
4
  private $automatic_updater;
 
5
 
6
  function init( $automatic_updater ) {
7
  static $instance = false;
@@ -15,23 +16,26 @@ class Automatic_Updater_Admin {
15
  function __construct( $automatic_updater ) {
16
  $this->automatic_updater = $automatic_updater;
17
 
18
- if ( is_multisite() )
 
19
  add_action( 'network_admin_menu', array( &$this, 'plugin_menu' ) );
20
- else
 
21
  add_action( 'admin_menu', array( &$this, 'plugin_menu' ) );
 
 
 
22
 
23
  add_filter( 'plugin_action_links_' . Automatic_Updater::$basename, array( &$this, 'plugin_row_links' ) );
24
  add_filter( 'network_admin_plugin_action_links_' . Automatic_Updater::$basename, array( &$this, 'plugin_row_links' ) );
25
  }
26
 
27
  function plugin_menu() {
28
- $slug = 'options-general.php';
29
- if ( is_multisite() )
30
- $slug = 'settings.php';
31
-
32
- $hook = add_submenu_page( $slug, esc_html__( 'Automatic Updater', 'automatic-updater' ), esc_html__( 'Automatic Updater', 'automatic-updater' ), 'update_core', 'automatic-updater', array( &$this, 'settings' ) );
33
 
34
  add_action( "load-$hook", array( &$this, 'settings_loader' ) );
 
 
35
  }
36
 
37
  function settings_loader() {
@@ -49,7 +53,8 @@ class Automatic_Updater_Admin {
49
  '<p><a href="http://wordpress.org/support/plugin/automatic-updater">' . esc_html__( 'Support Forums', 'automatic-updater' ) . '</a></p>'
50
  );
51
 
52
- wp_enqueue_style( 'automatic-updater-admin', plugins_url( 'css/admin.css', __FILE__ ) );
 
53
  }
54
 
55
  function settings() {
@@ -64,12 +69,13 @@ class Automatic_Updater_Admin {
64
  $message = esc_html__( 'Settings updated', 'automatic-updater' );
65
  }
66
 
67
- $messages = array(
68
- 'core' => wp_kses( __( 'Update WordPress Core automatically? <strong>(Strongly Recommended)</strong>', 'automatic-updater' ), array( 'strong' => array() ) ),
69
- 'plugins' => esc_html__( 'Update your plugins automatically?', 'automatic-updater' ),
70
- 'themes' => esc_html__( 'Update your themes automatically?', 'automatic-updater' )
71
- );
72
  ?>
 
73
  <div class="wrap">
74
  <?php screen_icon( 'tools' ); ?>
75
  <h2><?php esc_html_e( 'Automatic Updater', 'automatic-updater' ); ?></h2>
@@ -80,10 +86,46 @@ class Automatic_Updater_Admin {
80
  </div>
81
  <?php } ?>
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  <form method="post">
84
  <?php wp_nonce_field( 'automatic-updater-settings' ); ?>
85
 
86
  <?php
 
 
 
 
 
 
87
  foreach ( $this->automatic_updater->get_option( 'update' ) as $type => $enabled ) {
88
  $checked = '';
89
  if ( $enabled )
@@ -143,13 +185,16 @@ class Automatic_Updater_Admin {
143
  <p><?php esc_html_e( "Running plugins from SVN is great for helping plugin devs fine tune them before release, so on behalf of all of us, thanks! If you see Akismet here and don't have it coming from a custom repository, it will probably automatically update when the WordPress Core SVN update occurs.", 'automatic-updater' ); ?></p>
144
  <?php
145
  foreach ( $source_control['plugins'] as $id => $plugin ) {
146
- if ( ! is_writable( WP_PLUGIN_DIR . '/' . plugin_dir_path( $id ) . '/.svn' ) )
 
147
  $writable_error = true;
 
 
148
 
149
  $checked = '';
150
  if ( array_key_exists( $id, $svn_options['plugins'] ) )
151
  $checked = ' checked="checked"';
152
- echo "<input type='checkbox' name='svn-plugins[]' id='$id' value='$id'$checked /> <label for='$id'>{$plugin['plugin']['Name']} ($id)</label><br/>";
153
  }
154
  }
155
 
@@ -159,13 +204,16 @@ class Automatic_Updater_Admin {
159
  <p><?php esc_html_e( "Running themes from SVN makes you an excellent person who makes the WordPress community better - thank you! If you see any of the default Twenty Ten, Eleven or Twelve themes, these will probably automatically update when the WordPress Core SVN update occurs.", 'automatic-updater' ); ?></p>
160
  <?php
161
  foreach ( $source_control['themes'] as $id => $theme ) {
162
- if ( ! is_writable( $theme['theme']->get_stylesheet_directory() . '/.svn' ) )
 
163
  $writable_error = true;
 
 
164
 
165
  $checked = '';
166
  if ( array_key_exists( $id, $svn_options['themes'] ) )
167
  $checked = ' checked="checked"';
168
- echo "<input type='checkbox' name='svn-themes[]' id='$id' value='$id'$checked /> <label for='$id'>{$theme['theme']->name} ($id)</label><br/>";
169
  }
170
  }
171
 
@@ -226,8 +274,9 @@ class Automatic_Updater_Admin {
226
  }
227
 
228
  $top_options = array( 'override-email', 'retries-limit' );
229
- foreach ( $top_options as $option )
230
  $this->automatic_updater->update_option( $option, $_REQUEST[ $option ] );
 
231
 
232
  $svn_options = array(
233
  'core' => false,
@@ -257,10 +306,23 @@ class Automatic_Updater_Admin {
257
  $this->automatic_updater->update_option( 'svn', $svn_options );
258
  }
259
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
  function plugin_row_links( $links ) {
261
- $url = admin_url( 'options-general.php?page=automatic-updater' );
262
- if ( is_multisite() )
263
- $url = network_admin_url( 'settings.php?page=automatic-updater' );
264
 
265
  array_unshift( $links, "<a href='$url'>" . esc_html__( 'Settings', 'automatic-updater' ) . '</a>' );
266
 
2
 
3
  class Automatic_Updater_Admin {
4
  private $automatic_updater;
5
+ private $adminPage;
6
 
7
  function init( $automatic_updater ) {
8
  static $instance = false;
16
  function __construct( $automatic_updater ) {
17
  $this->automatic_updater = $automatic_updater;
18
 
19
+ if ( is_multisite() ) {
20
+ $this->adminPage = 'settings.php';
21
  add_action( 'network_admin_menu', array( &$this, 'plugin_menu' ) );
22
+ } else {
23
+ $this->adminPage = 'options-general.php';
24
  add_action( 'admin_menu', array( &$this, 'plugin_menu' ) );
25
+ }
26
+
27
+ add_action( 'wp_ajax_automatic-updater-hide-connection-warning', array( &$this, 'ajax_hide_connection_warning' ) );
28
 
29
  add_filter( 'plugin_action_links_' . Automatic_Updater::$basename, array( &$this, 'plugin_row_links' ) );
30
  add_filter( 'network_admin_plugin_action_links_' . Automatic_Updater::$basename, array( &$this, 'plugin_row_links' ) );
31
  }
32
 
33
  function plugin_menu() {
34
+ $hook = add_submenu_page( $this->adminPage, esc_html__( 'Automatic Updater', 'automatic-updater' ), esc_html__( 'Automatic Updater', 'automatic-updater' ), 'update_core', 'automatic-updater', array( &$this, 'settings' ) );
 
 
 
 
35
 
36
  add_action( "load-$hook", array( &$this, 'settings_loader' ) );
37
+
38
+ add_action( "admin_footer-$hook", array( &$this, 'footer' ) );
39
  }
40
 
41
  function settings_loader() {
53
  '<p><a href="http://wordpress.org/support/plugin/automatic-updater">' . esc_html__( 'Support Forums', 'automatic-updater' ) . '</a></p>'
54
  );
55
 
56
+ wp_enqueue_style( 'automatic-updater-admin', plugins_url( 'css/admin.css', Automatic_Updater::$basename ) );
57
+ wp_enqueue_script( 'automatic-updater-admin', plugins_url( 'js/admin.js', Automatic_Updater::$basename ) );
58
  }
59
 
60
  function settings() {
69
  $message = esc_html__( 'Settings updated', 'automatic-updater' );
70
  }
71
 
72
+ if ( ! empty( $_REQUEST['action'] ) && 'hide-connection-warning' === $_REQUEST['action'] ) {
73
+ check_admin_referer( 'automatic-updater-hide-connection-warning' );
74
+
75
+ $this->automatic_updater->update_option( 'show-connection-warning', false );
76
+ }
77
  ?>
78
+
79
  <div class="wrap">
80
  <?php screen_icon( 'tools' ); ?>
81
  <h2><?php esc_html_e( 'Automatic Updater', 'automatic-updater' ); ?></h2>
86
  </div>
87
  <?php } ?>
88
 
89
+ <?php
90
+ if ( $this->automatic_updater->get_option( 'show-connection-warning' ) ) {
91
+ // If it isn't a direct connection
92
+ $method = get_filesystem_method();
93
+ if ( 'direct' !== $method && ! defined( 'FTP_USER' ) ) {
94
+ // Using a remote login method, and the upgrade info probably isn't defined
95
+ $admin_url = wp_nonce_url( admin_url( "{$this->adminPage}?page=automatic-updater&action=hide-connection-warning" ), 'automatic-updater-hide-connection-warning' );
96
+ ?>
97
+ <div class="updated">
98
+ <p><?php echo wp_kses( sprintf( __( 'It looks like Automatic Updater may not be able to run automatically, due to not having permission to write to the WordPress directory, or connect to the server over FTP. If you usually upgrade by entering your FTP login details, please read <a href="%s">this documentation</a> on storing your connection details.', 'automatic-updater' ), 'http://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants' ), array( 'a' => array( 'href' => array() ) ) ); ?></p>
99
+ <p><?php echo wp_kses( sprintf( __( 'Alternatively, if WordPress normally upgrades immediately when you click the Update button, or if you don\'t want to see this message again, feel free to <a href="%1$s" id="%2$s">hide it</a>.', 'automatic-updater' ), $admin_url, 'automatic-updater-hide-connection-warning' ), array( 'a' => array( 'href' => array(), 'id' => array() ) ) ); ?></p>
100
+ </div>
101
+ <?php
102
+ }
103
+ }
104
+ ?>
105
+
106
+ <?php
107
+ if ( is_plugin_active( 'better-wp-security/better-wp-security.php' ) ) {
108
+ global $bwpsoptions;
109
+ if ( ! empty( $bwpsoptions[ 'st_corenot' ] ) || ! empty( $bwpsoptions[ 'st_pluginnot' ] ) || ! empty( $bwpsoptions[ 'st_themenot' ] ) ) {
110
+ ?>
111
+ <div class="updated">
112
+ <p><?php echo wp_kses( sprintf( __( 'The Better WP Security plugin is hiding updates, which will prevent Automatic Updater from operating correctly. Please <a href="%s">disable these options</a>.', 'automatic-updater' ), admin_url( 'admin.php?page=better-wp-security-systemtweaks#st_themenot' ) ), array( 'a' => array( 'href' => array() ) ) ); ?></p>
113
+ </div>
114
+ <?php
115
+ }
116
+ }
117
+ ?>
118
+
119
  <form method="post">
120
  <?php wp_nonce_field( 'automatic-updater-settings' ); ?>
121
 
122
  <?php
123
+ $messages = array(
124
+ 'core' => wp_kses( __( 'Update WordPress Core automatically? <strong>(Strongly Recommended)</strong>', 'automatic-updater' ), array( 'strong' => array() ) ),
125
+ 'plugins' => esc_html__( 'Update your plugins automatically?', 'automatic-updater' ),
126
+ 'themes' => esc_html__( 'Update your themes automatically?', 'automatic-updater' )
127
+ );
128
+
129
  foreach ( $this->automatic_updater->get_option( 'update' ) as $type => $enabled ) {
130
  $checked = '';
131
  if ( $enabled )
185
  <p><?php esc_html_e( "Running plugins from SVN is great for helping plugin devs fine tune them before release, so on behalf of all of us, thanks! If you see Akismet here and don't have it coming from a custom repository, it will probably automatically update when the WordPress Core SVN update occurs.", 'automatic-updater' ); ?></p>
186
  <?php
187
  foreach ( $source_control['plugins'] as $id => $plugin ) {
188
+ $class = '';
189
+ if ( ! is_writable( WP_PLUGIN_DIR . '/' . plugin_dir_path( $id ) . '/.svn' ) ) {
190
  $writable_error = true;
191
+ $class = ' class="form-invalid"';
192
+ }
193
 
194
  $checked = '';
195
  if ( array_key_exists( $id, $svn_options['plugins'] ) )
196
  $checked = ' checked="checked"';
197
+ echo "<input type='checkbox' name='svn-plugins[]' id='$id' value='$id'$checked /> <label for='$id'$class>{$plugin['plugin']['Name']} ($id)</label><br/>";
198
  }
199
  }
200
 
204
  <p><?php esc_html_e( "Running themes from SVN makes you an excellent person who makes the WordPress community better - thank you! If you see any of the default Twenty Ten, Eleven or Twelve themes, these will probably automatically update when the WordPress Core SVN update occurs.", 'automatic-updater' ); ?></p>
205
  <?php
206
  foreach ( $source_control['themes'] as $id => $theme ) {
207
+ $class = '';
208
+ if ( ! is_writable( $theme['theme']->get_stylesheet_directory() . '/.svn' ) ) {
209
  $writable_error = true;
210
+ $class = ' class="form-invalid"';
211
+ }
212
 
213
  $checked = '';
214
  if ( array_key_exists( $id, $svn_options['themes'] ) )
215
  $checked = ' checked="checked"';
216
+ echo "<input type='checkbox' name='svn-themes[]' id='$id' value='$id'$checked /> <label for='$id'$class>{$theme['theme']->name} ($id)</label><br/>";
217
  }
218
  }
219
 
274
  }
275
 
276
  $top_options = array( 'override-email', 'retries-limit' );
277
+ foreach ( $top_options as $option ) {
278
  $this->automatic_updater->update_option( $option, $_REQUEST[ $option ] );
279
+ }
280
 
281
  $svn_options = array(
282
  'core' => false,
306
  $this->automatic_updater->update_option( 'svn', $svn_options );
307
  }
308
 
309
+ function ajax_hide_connection_warning() {
310
+ $this->automatic_updater->update_option( 'show-connection-warning', false );
311
+ die();
312
+ }
313
+
314
+ function footer() {
315
+ ?>
316
+ <script type='text/javascript'>
317
+ /* <![CDATA[ */
318
+ var automaticUpdaterSettings = { 'nonce': '<?php echo wp_create_nonce( 'automatic-updater' ); ?>' };
319
+ /* ]]> */
320
+ </script>
321
+ <?php
322
+ }
323
+
324
  function plugin_row_links( $links ) {
325
+ $url = admin_url( "{$this->adminPage}?page=automatic-updater" );
 
 
326
 
327
  array_unshift( $links, "<a href='$url'>" . esc_html__( 'Settings', 'automatic-updater' ) . '</a>' );
328
 
automatic-updater.php CHANGED
@@ -4,13 +4,19 @@
4
  * Plugin URI: http://pento.net/projects/automatic-updater-for-wordpress/
5
  * Description: Automatically update your WordPress site, as soon as updates are released! Never worry about falling behing on updating again!
6
  * Author: pento
7
- * Version: 0.8.5
8
  * Author URI: http://pento.net/
9
  * License: GPL2+
10
  * Text Domain: automatic-updater
11
  * Domain Path: /languages/
12
  */
13
 
 
 
 
 
 
 
14
  $automatic_updater_file = __FILE__;
15
 
16
  if ( isset( $plugin ) )
@@ -49,10 +55,12 @@ class Automatic_Updater {
49
 
50
  add_action( 'shutdown', array( &$this, 'shutdown' ) );
51
 
52
- add_action( 'auto_updater_core_event', array( &$this, 'update_core' ) );
53
- add_action( 'auto_updater_plugins_event', array( &$this, 'update_plugins' ) );
54
- add_action( 'auto_updater_themes_event', array( &$this, 'update_themes' ) );
55
- add_action( 'auto_updater_svn_event', array( &$this, 'update_svn' ) );
 
 
56
 
57
  // Nothing else matters if we're on WPMS and not on the main site
58
  if ( is_multisite() && ! is_main_site() )
@@ -63,6 +71,9 @@ class Automatic_Updater {
63
  Automatic_Updater_Admin::init( $this );
64
  }
65
 
 
 
 
66
  add_action( 'admin_init', array( &$this, 'check_wordpress_version' ) );
67
 
68
  // Configure SVN updates cron, if it's enabled
@@ -70,7 +81,8 @@ class Automatic_Updater {
70
  if ( ! wp_next_scheduled( 'auto_updater_svn_event' ) )
71
  wp_schedule_event( time(), 'hourly', 'auto_updater_svn_event' );
72
  } else {
73
- if ( $timestamp = wp_next_scheduled( 'auto_updater_svn_event' ) )
 
74
  wp_unschedule_event( $timestamp, 'auto_updater_svn_event' );
75
  }
76
 
@@ -213,12 +225,18 @@ class Automatic_Updater {
213
  $this->options['svn-success-email'] = true;
214
 
215
  // SVN support for themes and plugins added in 0.8
216
- if ( ! is_array( $this->options['svn'] ) )
217
  $this->options['svn'] = array(
218
  'core' => $this->options['svn'],
219
  'plugins' => array(),
220
  'themes' => array(),
221
  );
 
 
 
 
 
 
222
  }
223
 
224
  function update_core() {
@@ -238,7 +256,7 @@ class Automatic_Updater {
238
  if ( empty( $updates ) )
239
  return;
240
 
241
- if ( 'development' == $updates[0]->response )
242
  $update = $updates[0];
243
  else
244
  $update = find_core_update( $updates[0]->current, $updates[0]->locale );
@@ -254,15 +272,19 @@ class Automatic_Updater {
254
  $old_version = $GLOBALS['wp_version'];
255
 
256
  // Sanity check that the new upgrade is actually an upgrade
257
- if ( 'development' != $update->response && version_compare( $old_version, $update->current, '>=' ) )
258
  return;
259
 
260
  // Only do development version updates once every 24 hours
261
- if ( 'development' == $update->response ) {
262
  if ( time() < $this->options['next-development-update'] )
263
  return;
264
 
265
  $this->options['next-development-update'] = strtotime( '+24 hours' );
 
 
 
 
266
  }
267
 
268
  $this->running = true;
@@ -277,8 +299,14 @@ class Automatic_Updater {
277
 
278
  do_action( 'auto_updater_after_update', 'core' );
279
 
 
 
 
 
 
 
280
  if ( is_wp_error( $result ) ) {
281
- if ( $this->options['tries']['core']['version'] != $update->current )
282
  $this->options['tries']['core']['version'] = $update->current;
283
 
284
  $this->options['tries']['core']['tries']++;
@@ -289,9 +317,9 @@ class Automatic_Updater {
289
  $message .= '<br><br>' . $result->get_error_message() . '<br><br>';
290
  $message .= sprintf( esc_html__( 'We\'re sorry it didn\'t work out. Please try upgrading manually, instead. This is attempt %1$d of %2$d.', 'automatic-updater' ),
291
  $this->options['tries']['core']['tries'],
292
- $this->option['retries-limit'] );
293
- } else if( 'development' == $update->response ) {
294
- $message = esc_html__( "We've successfully upgraded WordPress to the latest nightly build!", 'automatic-updater' );
295
  $message .= '<br><br>' . esc_html__( 'Have fun!', 'automatic-updater' );
296
 
297
  $this->options['tries']['core']['version'] = 0;
@@ -337,7 +365,7 @@ class Automatic_Updater {
337
  // Remove any plugins that have failed to upgrade
338
  if ( ! empty( $this->options['retries']['plugins'][ $id ] ) ) {
339
  // If there's a new version of a failed plugin, we should give it another go.
340
- if ( $this->options['retries']['plugins'][ $id ]['version'] != $plugin->update->new_version )
341
  unset( $this->options['retries']['plugins'][ $id ] );
342
  // If the plugin has already had it's chance, move on.
343
  else if ($this->options['retries']['plugins'][ $id ]['tries'] > $this->options['retries-limit'] )
@@ -365,13 +393,14 @@ class Automatic_Updater {
365
 
366
  foreach ( $plugins as $id => $plugin ) {
367
  if ( is_wp_error( $result[ $id ] ) ) {
368
- if ( empty( $this->options['retries']['plugins'][ $id ] ) )
369
  $this->options['retries']['plugins'][ $id ] = array(
370
  'tries' => 1,
371
  'version' => $plugin->update->new_version,
372
  );
373
- else
374
  $this->options['retries']['plugins'][ $id ]['tries']++;
 
375
 
376
  $upgrade_failed = true;
377
 
@@ -430,7 +459,7 @@ class Automatic_Updater {
430
  // Remove any themes that have failed to upgrade
431
  if ( ! empty( $this->options['retries']['themes'][ $id ] ) ) {
432
  // If there's a new version of a failed theme, we should give it another go.
433
- if ( $this->options['retries']['themes'][ $id ]['version'] != $theme->update['new_version'] )
434
  unset( $this->options['retries']['themes'][ $id ] );
435
  // If the themes has already had it's chance, move on.
436
  else if ($this->options['retries']['themes'][ $id ]['tries'] > $this->options['retries-limit'] )
@@ -458,13 +487,14 @@ class Automatic_Updater {
458
 
459
  foreach ( $themes as $id => $theme ) {
460
  if ( is_wp_error( $result[ $id ] ) ) {
461
- if ( empty( $this->options['retries']['themes'][ $id ] ) )
462
  $this->options['retries']['themes'][ $id ] = array(
463
  'tries' => 1,
464
  'version' => $themes->update['new_version'],
465
  );
466
- else
467
  $this->options['retries']['themes'][ $id ]['tries']++;
 
468
 
469
  $upgrade_failed = true;
470
 
@@ -706,7 +736,7 @@ class Automatic_Updater {
706
 
707
  if ( function_exists( 'get_core_updates' ) ) {
708
  $update_wordpress = get_core_updates( array( 'dismissed' => false ) );
709
- if ( ! empty( $update_wordpress ) && 'latest' != $update_wordpress[0]->response )
710
  $counts['wordpress'] = 1;
711
  }
712
 
@@ -740,18 +770,21 @@ class Automatic_Updater {
740
  $return['core'] = $type;
741
 
742
  foreach ( $plugins as $id => $plugin )
743
- if ( plugin_dir_path( $id ) != './' && is_dir( WP_PLUGIN_DIR . '/' . plugin_dir_path( $id ) . ".$type" ) )
744
  $return['plugins'][ $id ] = array(
745
  'type' => $type,
746
  'plugin' => $plugin
747
  );
 
748
 
749
- foreach ( $themes as $id => $theme )
750
- if ( is_dir( $theme->get_stylesheet_directory() . "/.$type" ) )
751
  $return['themes'][ $id ] = array(
752
  'type' => $type,
753
  'theme' => $theme
754
  );
 
 
755
  }
756
 
757
  return $return;
4
  * Plugin URI: http://pento.net/projects/automatic-updater-for-wordpress/
5
  * Description: Automatically update your WordPress site, as soon as updates are released! Never worry about falling behing on updating again!
6
  * Author: pento
7
+ * Version: 0.9
8
  * Author URI: http://pento.net/
9
  * License: GPL2+
10
  * Text Domain: automatic-updater
11
  * Domain Path: /languages/
12
  */
13
 
14
+ // Don't allow the plugin to be loaded directly
15
+ if ( ! function_exists( 'add_action' ) ) {
16
+ echo "Please enable this plugin from your wp-admin.";
17
+ exit;
18
+ }
19
+
20
  $automatic_updater_file = __FILE__;
21
 
22
  if ( isset( $plugin ) )
55
 
56
  add_action( 'shutdown', array( &$this, 'shutdown' ) );
57
 
58
+ if ( ! defined( 'AUTOMATIC_UPDATER_DISABLED' ) || ! AUTOMATIC_UPDATER_DISABLED ) {
59
+ add_action( 'auto_updater_core_event', array( &$this, 'update_core' ) );
60
+ add_action( 'auto_updater_plugins_event', array( &$this, 'update_plugins' ) );
61
+ add_action( 'auto_updater_themes_event', array( &$this, 'update_themes' ) );
62
+ add_action( 'auto_updater_svn_event', array( &$this, 'update_svn' ) );
63
+ }
64
 
65
  // Nothing else matters if we're on WPMS and not on the main site
66
  if ( is_multisite() && ! is_main_site() )
71
  Automatic_Updater_Admin::init( $this );
72
  }
73
 
74
+ if ( defined( 'AUTOMATIC_UPDATER_DISABLED' ) && AUTOMATIC_UPDATER_DISABLED )
75
+ return;
76
+
77
  add_action( 'admin_init', array( &$this, 'check_wordpress_version' ) );
78
 
79
  // Configure SVN updates cron, if it's enabled
81
  if ( ! wp_next_scheduled( 'auto_updater_svn_event' ) )
82
  wp_schedule_event( time(), 'hourly', 'auto_updater_svn_event' );
83
  } else {
84
+ $timestamp = wp_next_scheduled( 'auto_updater_svn_event' );
85
+ if ( $timestamp )
86
  wp_unschedule_event( $timestamp, 'auto_updater_svn_event' );
87
  }
88
 
225
  $this->options['svn-success-email'] = true;
226
 
227
  // SVN support for themes and plugins added in 0.8
228
+ if ( ! is_array( $this->options['svn'] ) ) {
229
  $this->options['svn'] = array(
230
  'core' => $this->options['svn'],
231
  'plugins' => array(),
232
  'themes' => array(),
233
  );
234
+ }
235
+
236
+ // Warning for incorrect permissions added in 0.9
237
+ if ( ! array_key_exists( 'show-connection-warning', $this->options ) ) {
238
+ $this->options['show-connection-warning'] = true;
239
+ }
240
  }
241
 
242
  function update_core() {
256
  if ( empty( $updates ) )
257
  return;
258
 
259
+ if ( 'development' === $updates[0]->response )
260
  $update = $updates[0];
261
  else
262
  $update = find_core_update( $updates[0]->current, $updates[0]->locale );
272
  $old_version = $GLOBALS['wp_version'];
273
 
274
  // Sanity check that the new upgrade is actually an upgrade
275
+ if ( 'development' !== $update->response && version_compare( $old_version, $update->current, '>=' ) )
276
  return;
277
 
278
  // Only do development version updates once every 24 hours
279
+ if ( 'development' === $update->response ) {
280
  if ( time() < $this->options['next-development-update'] )
281
  return;
282
 
283
  $this->options['next-development-update'] = strtotime( '+24 hours' );
284
+
285
+ // It seems the core upgrade process sometimes prevents the shutdown function from running.
286
+ // Let's force the option to be saved, just to be certain we don't get repeat updates.
287
+ update_option( 'automatic-updater', $this->options );
288
  }
289
 
290
  $this->running = true;
299
 
300
  do_action( 'auto_updater_after_update', 'core' );
301
 
302
+ include( ABSPATH . WPINC . '/version.php' );
303
+ if ( $old_version === $wp_version ) {
304
+ // Huh, I guess it didn't really need to do that upgrade
305
+ return;
306
+ }
307
+
308
  if ( is_wp_error( $result ) ) {
309
+ if ( $this->options['tries']['core']['version'] !== $update->current )
310
  $this->options['tries']['core']['version'] = $update->current;
311
 
312
  $this->options['tries']['core']['tries']++;
317
  $message .= '<br><br>' . $result->get_error_message() . '<br><br>';
318
  $message .= sprintf( esc_html__( 'We\'re sorry it didn\'t work out. Please try upgrading manually, instead. This is attempt %1$d of %2$d.', 'automatic-updater' ),
319
  $this->options['tries']['core']['tries'],
320
+ $this->options['retries-limit'] );
321
+ } else if ( 'development' === $update->response ) {
322
+ $message = sprintf( esc_html__( 'We\'ve successfully upgraded WordPress from version %1$s to version %2$s, the latest nightly build!', 'automatic-updater' ), $old_version, $wp_version );
323
  $message .= '<br><br>' . esc_html__( 'Have fun!', 'automatic-updater' );
324
 
325
  $this->options['tries']['core']['version'] = 0;
365
  // Remove any plugins that have failed to upgrade
366
  if ( ! empty( $this->options['retries']['plugins'][ $id ] ) ) {
367
  // If there's a new version of a failed plugin, we should give it another go.
368
+ if ( $this->options['retries']['plugins'][ $id ]['version'] !== $plugin->update->new_version )
369
  unset( $this->options['retries']['plugins'][ $id ] );
370
  // If the plugin has already had it's chance, move on.
371
  else if ($this->options['retries']['plugins'][ $id ]['tries'] > $this->options['retries-limit'] )
393
 
394
  foreach ( $plugins as $id => $plugin ) {
395
  if ( is_wp_error( $result[ $id ] ) ) {
396
+ if ( empty( $this->options['retries']['plugins'][ $id ] ) ) {
397
  $this->options['retries']['plugins'][ $id ] = array(
398
  'tries' => 1,
399
  'version' => $plugin->update->new_version,
400
  );
401
+ } else {
402
  $this->options['retries']['plugins'][ $id ]['tries']++;
403
+ }
404
 
405
  $upgrade_failed = true;
406
 
459
  // Remove any themes that have failed to upgrade
460
  if ( ! empty( $this->options['retries']['themes'][ $id ] ) ) {
461
  // If there's a new version of a failed theme, we should give it another go.
462
+ if ( $this->options['retries']['themes'][ $id ]['version'] !== $theme->update['new_version'] )
463
  unset( $this->options['retries']['themes'][ $id ] );
464
  // If the themes has already had it's chance, move on.
465
  else if ($this->options['retries']['themes'][ $id ]['tries'] > $this->options['retries-limit'] )
487
 
488
  foreach ( $themes as $id => $theme ) {
489
  if ( is_wp_error( $result[ $id ] ) ) {
490
+ if ( empty( $this->options['retries']['themes'][ $id ] ) ) {
491
  $this->options['retries']['themes'][ $id ] = array(
492
  'tries' => 1,
493
  'version' => $themes->update['new_version'],
494
  );
495
+ } else {
496
  $this->options['retries']['themes'][ $id ]['tries']++;
497
+ }
498
 
499
  $upgrade_failed = true;
500
 
736
 
737
  if ( function_exists( 'get_core_updates' ) ) {
738
  $update_wordpress = get_core_updates( array( 'dismissed' => false ) );
739
+ if ( ! empty( $update_wordpress ) && 'latest' !== $update_wordpress[0]->response )
740
  $counts['wordpress'] = 1;
741
  }
742
 
770
  $return['core'] = $type;
771
 
772
  foreach ( $plugins as $id => $plugin )
773
+ if ( plugin_dir_path( $id ) !== './' && is_dir( WP_PLUGIN_DIR . '/' . plugin_dir_path( $id ) . ".$type" ) ) {
774
  $return['plugins'][ $id ] = array(
775
  'type' => $type,
776
  'plugin' => $plugin
777
  );
778
+ }
779
 
780
+ foreach ( $themes as $id => $theme ) {
781
+ if ( is_dir( $theme->get_stylesheet_directory() . "/.$type" ) ) {
782
  $return['themes'][ $id ] = array(
783
  'type' => $type,
784
  'theme' => $theme
785
  );
786
+ }
787
+ }
788
  }
789
 
790
  return $return;
js/admin.js ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var automaticUpdaterAdmin;
2
+
3
+ ( function( $ ) {
4
+
5
+ automaticUpdaterAdmin = {
6
+
7
+ load: function() {
8
+ $( document ).on( 'click', '#automatic-updater-hide-connection-warning', this.hideConnectionWarning );
9
+ },
10
+
11
+ hideConnectionWarning: function( e ) {
12
+ e.preventDefault();
13
+ e.stopPropagation();
14
+
15
+ $.ajax( ajaxurl, {
16
+ data: {
17
+ action: 'automatic-updater-hide-connection-warning',
18
+ _ajax_nonce: automaticUpdaterSettings.nonce
19
+ }
20
+ } );
21
+
22
+ $( e.target ).closest( '.updated' ).slideUp( 'fast' );
23
+ }
24
+ };
25
+
26
+ } )( jQuery );
27
+
28
+ automaticUpdaterAdmin.load();
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: pento
3
  Donate link: http://pento.net/donate/
4
  Tags: updates, core, plugins, themes, stable, nightly, svn, wordpress automatic upgrader
5
  Requires at least: 3.4
6
- Tested up to: 3.5
7
- Stable tag: 0.8.4
8
  License: GPL2+
9
 
10
  Automatically update WordPress, your themes and plugins! Never have to click the update button again!
@@ -17,8 +17,6 @@ If you're working on a WordPress Multisite install, it will properly restrict th
17
 
18
  While this will be useful for the vast majority of sites, please exercise caution, particularly if you have any custom themes or plugins running on your site.
19
 
20
- You should also be aware that this will only work on WordPress installs that have the appropriate file permissions to update through the web interface - it will not work if you usually FTP updates to your server.
21
-
22
  There are some Actions and Filters provided, check the [Documentation](http://pento.net/projects/automatic-updater-for-wordpress/) for more details.
23
 
24
  == Installation ==
@@ -43,6 +41,19 @@ There are some Actions and Filters provided, check the [Documentation](http://pe
43
 
44
  == Changelog ==
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  = 0.8.5 =
47
  * FIXED: Disable email notifications option was being set, but not showing up as set
48
  * FIXED: Only write to the options table when options have actually change
3
  Donate link: http://pento.net/donate/
4
  Tags: updates, core, plugins, themes, stable, nightly, svn, wordpress automatic upgrader
5
  Requires at least: 3.4
6
+ Tested up to: 3.6
7
+ Stable tag: 0.8.5
8
  License: GPL2+
9
 
10
  Automatically update WordPress, your themes and plugins! Never have to click the update button again!
17
 
18
  While this will be useful for the vast majority of sites, please exercise caution, particularly if you have any custom themes or plugins running on your site.
19
 
 
 
20
  There are some Actions and Filters provided, check the [Documentation](http://pento.net/projects/automatic-updater-for-wordpress/) for more details.
21
 
22
  == Installation ==
41
 
42
  == Changelog ==
43
 
44
+ = 0.9 =
45
+ * ADDED: Warning when Better WP Security is hiding update info
46
+ * ADDED: Warning when the user can't update directly, but hasn't defined S/FTP login details
47
+ * ADDED: AUTOMATIC_UPDATER_DISABLED wp-config option, for forcing updates to never happen
48
+ * ADDED: Sanity check to make sure the plugin isn't accessed directly
49
+ * CHANGED: For nightly build upgrade notification emails, include the build numbers
50
+ * UPDATED: Tested up to WordPress 3.6
51
+ * FIXED: Don't send a notification email if the core upgrade didn't change versions (ie, a nightly build with no changes)
52
+ * FIXED: Settings page CSS wasn't loading if the plugin was installed in a symlink directory
53
+ * FIXED: Themes and plugins in non-writeable directories weren't being highlighted correctly on the settings page
54
+ * FIXED: Core upgrade retry emails were not showing the correct retry limit
55
+ * FIXED: Nightly core upgrades can sometimes repeat more than once every 24 hours
56
+
57
  = 0.8.5 =
58
  * FIXED: Disable email notifications option was being set, but not showing up as set
59
  * FIXED: Only write to the options table when options have actually change
updater-skin.php CHANGED
@@ -12,16 +12,15 @@ class Auto_Updater_Skin extends WP_Upgrader_Skin {
12
  function feedback( $data ) {
13
  if ( is_wp_error( $data ) )
14
  $string = $data->get_error_message();
15
- else if ( is_array( $data ) ) {
16
  return;
17
- }
18
  else
19
  $string = $data;
20
 
21
  if ( ! empty( $this->upgrader->strings[ $string ] ) )
22
  $string = $this->upgrader->strings[ $string ];
23
 
24
- if ( strpos($string, '%') !== false ) {
25
  $args = func_get_args();
26
  $args = array_splice( $args, 1 );
27
  if ( ! empty( $args ) )
12
  function feedback( $data ) {
13
  if ( is_wp_error( $data ) )
14
  $string = $data->get_error_message();
15
+ else if ( is_array( $data ) )
16
  return;
 
17
  else
18
  $string = $data;
19
 
20
  if ( ! empty( $this->upgrader->strings[ $string ] ) )
21
  $string = $this->upgrader->strings[ $string ];
22
 
23
+ if ( strpos( $string, '%' ) !== false ) {
24
  $args = func_get_args();
25
  $args = array_splice( $args, 1 );
26
  if ( ! empty( $args ) )