Companion Auto Update - Version 3.3.9

Version Description

(March 11, 2019) = * Fix: Sometimes emails would be sent twice * Fix: Cronjobs disabled shouldn't be a critical error * Fix: Sometimes update reminder emails would not send at all * Improvement: Removed "Howdy" from emails * Improvement: Fixed a few typos

Download this release

Release Info

Developer Papin
Plugin Icon 128x128 Companion Auto Update
Version 3.3.9
Comparing to
See all releases

Code changes from version 3.3.8 to 3.3.9

admin/dashboard.php CHANGED
@@ -51,8 +51,8 @@
51
  </div><div class="welcome-column welcome-column-quarter">
52
  <h3>'.__( 'Get Started' ).'</h3>
53
  <ul>
54
- <li><a href="'.admin_url( cau_menloc().'?page=cau-settings&tab=pluginlist&cau_page=advanced' ).'">'.__( 'Select plugins', 'companion-auto-update' ).'</a></li>
55
- <li><a href="'.admin_url( cau_menloc().'?page=cau-settings&tab=schedule&cau_page=advanced' ).'">'.__( 'Advanced settings', 'companion-auto-update' ).'</a></li>
56
  </ul>
57
  </div><div class="welcome-column welcome-column-quarter">
58
  <h3>'.__( 'More Actions' ).'</h3>
@@ -67,6 +67,8 @@
67
 
68
  ?>
69
 
 
 
70
  <form method="POST">
71
 
72
  <table class="form-table">
@@ -164,7 +166,7 @@
164
  <td>
165
  <p>
166
  <input id="wpemails" name="wpemails" type="checkbox" <?php if( $cau_configs[9]->onoroff == 'on' ) { echo 'checked'; } ?> />
167
- <label for="wpemails"><?php _e('By default wordpress sends an email when a core update happend. Uncheck this box to disable these emails.', 'companion-auto-update');?></label>
168
  </p>
169
  </td>
170
  </tr>
@@ -175,3 +177,21 @@
175
  <?php submit_button(); ?>
176
 
177
  </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  </div><div class="welcome-column welcome-column-quarter">
52
  <h3>'.__( 'Get Started' ).'</h3>
53
  <ul>
54
+ <li><a href="'.cau_url( 'pluginlist' ).'">'.__( 'Select plugins', 'companion-auto-update' ).'</a></li>
55
+ <li><a href="'.cau_url( 'schedule' ).'">'.__( 'Advanced settings', 'companion-auto-update' ).'</a></li>
56
  </ul>
57
  </div><div class="welcome-column welcome-column-quarter">
58
  <h3>'.__( 'More Actions' ).'</h3>
67
 
68
  ?>
69
 
70
+ <div class="cau-column-wide">
71
+
72
  <form method="POST">
73
 
74
  <table class="form-table">
166
  <td>
167
  <p>
168
  <input id="wpemails" name="wpemails" type="checkbox" <?php if( $cau_configs[9]->onoroff == 'on' ) { echo 'checked'; } ?> />
169
+ <label for="wpemails"><?php _e( 'By default WordPress sends an email when a core update has occurred. Uncheck this box to disable these emails.', 'companion-auto-update' );?></label>
170
  </p>
171
  </td>
172
  </tr>
177
  <?php submit_button(); ?>
178
 
179
  </form>
180
+
181
+ </div><div class="cau-column-small">
182
+
183
+ <div class="welcome-to-cau love-bg cau-show-love cau-dashboard-box">
184
+ <h3><?php _e( 'Like our plugin?', 'companion-auto-update' ); ?></h3>
185
+ <p><?php _e('Companion Auto Update is free to use. It has required a great deal of time and effort to develop and you can help support this development by making a small donation.<br />You get useful software and we get to carry on making it better.', 'companion-auto-update'); ?></p>
186
+ <a href="https://wordpress.org/support/plugin/companion-auto-update/reviews/#new-post" target="_blank" class="cau-button rate-button">
187
+ <span class="dashicons dashicons-star-filled"></span>
188
+ <?php _e('Rate us (5 stars?)', 'companion-auto-update'); ?>
189
+ </a>
190
+ <a href="<?php echo cau_donateUrl(); ?>" target="_blank" class="cau-button donate-button">
191
+ <span class="dashicons dashicons-heart"></span>
192
+ <?php _e('Donate to help development', 'companion-auto-update'); ?>
193
+ </a>
194
+ <p style="font-size: 12px; color: #BDBDBD;">Donations via PayPal. Amount can be changed.</p>
195
+ </div>
196
+
197
+ </div>
admin/log.php CHANGED
@@ -9,11 +9,19 @@ if( isset( $_GET['filter'] ) ) {
9
  ?>
10
 
11
  <ul class="subsubsub">
12
- <li><a <?php if( $filter == 'all' ) { echo "class='current'"; } ?> href='<?php echo admin_url( 'tools.php?page=cau-settings&tab=log&cau_page=log&filter=all' ); ?>'><?php _e( 'View full changelog', 'companion-auto-update' ); ?></a></li> |
13
- <li><a <?php if( $filter == 'plugins' ) { echo "class='current'"; } ?> href='<?php echo admin_url( 'tools.php?page=cau-settings&tab=log&cau_page=log&filter=plugins' ); ?>'><?php _e( 'Plugins', 'companion-auto-update' ); ?></a></li> |
14
- <li><a <?php if( $filter == 'themes' ) { echo "class='current'"; } ?> href='<?php echo admin_url( 'tools.php?page=cau-settings&tab=log&cau_page=log&filter=themes' ); ?>'><?php _e( 'Themes', 'companion-auto-update' ); ?></a></li>
15
  </ul>
16
 
17
  <div class='cau_spacing'></div>
18
 
19
- <?php cau_fetch_log( 'all', 'table' ); ?>
 
 
 
 
 
 
 
 
9
  ?>
10
 
11
  <ul class="subsubsub">
12
+ <li><a <?php if( $filter == 'all' ) { echo "class='current'"; } ?> href='<?php echo cau_url( 'log&filter=all' ); ?>'><?php _e( 'View full changelog', 'companion-auto-update' ); ?></a></li> |
13
+ <li><a <?php if( $filter == 'plugins' ) { echo "class='current'"; } ?> href='<?php echo cau_url( 'log&filter=plugins' ); ?>'><?php _e( 'Plugins', 'companion-auto-update' ); ?></a></li> |
14
+ <li><a <?php if( $filter == 'themes' ) { echo "class='current'"; } ?> href='<?php echo cau_url( 'log&filter=themes' ); ?>'><?php _e( 'Themes', 'companion-auto-update' ); ?></a></li>
15
  </ul>
16
 
17
  <div class='cau_spacing'></div>
18
 
19
+ <?php
20
+
21
+ // Make sure it shows the correct time
22
+ date_default_timezone_set( get_option('timezone_string') );
23
+
24
+ // Show log
25
+ cau_fetch_log( 'all', 'table' );
26
+
27
+ ?>
admin/schedule.php CHANGED
@@ -17,7 +17,6 @@ if( isset( $_POST['submit'] ) ) {
17
  $core_sc = sanitize_text_field( $_POST['core_schedule'] );
18
  $schedule_mail = sanitize_text_field( $_POST['schedule_mail'] );
19
 
20
-
21
  // First clear schedules
22
  wp_clear_scheduled_hook('wp_update_plugins');
23
  wp_clear_scheduled_hook('wp_update_themes');
@@ -88,7 +87,7 @@ if( isset( $_POST['submit'] ) ) {
88
 
89
  wp_schedule_event( time(), $schedule_mail, 'cau_set_schedule_mail' );
90
 
91
- header( "Location: ".cau_menloc()."?page=cau-settings&tab=schedule&showmessage=true" );
92
 
93
  }
94
 
@@ -254,14 +253,15 @@ if( isset( $_GET['showmessage'] ) ) {
254
  <div class="welcome-to-cau love-bg cau-show-love cau-dashboard-box">
255
  <h3><?php _e( 'Like our plugin?', 'companion-auto-update' ); ?></h3>
256
  <p><?php _e('Companion Auto Update is free to use. It has required a great deal of time and effort to develop and you can help support this development by making a small donation.<br />You get useful software and we get to carry on making it better.', 'companion-auto-update'); ?></p>
257
- <a href="<?php echo cau_donateUrl(); ?>" target="_blank" class="cau-button donate-button">
258
- <span class="dashicons dashicons-heart"></span>
259
- <?php _e('Donate to help development', 'companion-auto-update'); ?>
260
- </a>
261
  <a href="https://wordpress.org/support/plugin/companion-auto-update/reviews/#new-post" target="_blank" class="cau-button rate-button">
262
  <span class="dashicons dashicons-star-filled"></span>
263
  <?php _e('Rate us (5 stars?)', 'companion-auto-update'); ?>
264
  </a>
 
 
 
 
 
265
  </div>
266
 
267
  </div>
17
  $core_sc = sanitize_text_field( $_POST['core_schedule'] );
18
  $schedule_mail = sanitize_text_field( $_POST['schedule_mail'] );
19
 
 
20
  // First clear schedules
21
  wp_clear_scheduled_hook('wp_update_plugins');
22
  wp_clear_scheduled_hook('wp_update_themes');
87
 
88
  wp_schedule_event( time(), $schedule_mail, 'cau_set_schedule_mail' );
89
 
90
+ header( "Location: ".cau_url( 'schedule&showmessage=true' ) );
91
 
92
  }
93
 
253
  <div class="welcome-to-cau love-bg cau-show-love cau-dashboard-box">
254
  <h3><?php _e( 'Like our plugin?', 'companion-auto-update' ); ?></h3>
255
  <p><?php _e('Companion Auto Update is free to use. It has required a great deal of time and effort to develop and you can help support this development by making a small donation.<br />You get useful software and we get to carry on making it better.', 'companion-auto-update'); ?></p>
 
 
 
 
256
  <a href="https://wordpress.org/support/plugin/companion-auto-update/reviews/#new-post" target="_blank" class="cau-button rate-button">
257
  <span class="dashicons dashicons-star-filled"></span>
258
  <?php _e('Rate us (5 stars?)', 'companion-auto-update'); ?>
259
  </a>
260
+ <a href="<?php echo cau_donateUrl(); ?>" target="_blank" class="cau-button donate-button">
261
+ <span class="dashicons dashicons-heart"></span>
262
+ <?php _e('Donate to help development', 'companion-auto-update'); ?>
263
+ </a>
264
+ <p style="font-size: 12px; color: #BDBDBD;">Donations via PayPal. Amount can be changed.</p>
265
  </div>
266
 
267
  </div>
admin/status.php CHANGED
@@ -1,13 +1,17 @@
1
  <?php
2
-
 
3
  $dateFormat = get_option( 'date_format' );
4
  $dateFormat .= ' '.get_option( 'time_format' );
5
 
 
 
 
6
  global $wpdb;
7
  $table_name = $wpdb->prefix . "auto_updates";
8
 
9
  // Minor updates
10
- $configs = $wpdb->get_results( "SELECT * FROM $table_name WHERE name = 'minor'");
11
  foreach ( $configs as $config ) {
12
 
13
  if( $config->onoroff == 'on' && wp_get_schedule( 'wp_version_check' ) ) {
@@ -27,7 +31,7 @@
27
  }
28
 
29
  // Major updates
30
- $configs = $wpdb->get_results( "SELECT * FROM $table_name WHERE name = 'major'");
31
  foreach ( $configs as $config ) {
32
 
33
  if( $config->onoroff == 'on' && wp_get_schedule( 'wp_version_check' ) ) {
@@ -47,7 +51,7 @@
47
  }
48
 
49
  // Plugin updates
50
- $configs = $wpdb->get_results( "SELECT * FROM $table_name WHERE name = 'plugins'");
51
  foreach ( $configs as $config ) {
52
 
53
  if( $config->onoroff == 'on' && wp_get_schedule( 'wp_update_plugins' ) ) {
@@ -67,7 +71,7 @@
67
  }
68
 
69
  // Themes updates
70
- $configs = $wpdb->get_results( "SELECT * FROM $table_name WHERE name = 'themes'");
71
  foreach ( $configs as $config ) {
72
 
73
  if( $config->onoroff == 'on' && wp_get_schedule( 'wp_update_plugins' ) ) {
@@ -86,6 +90,7 @@
86
 
87
  }
88
 
 
89
  if ( wp_next_scheduled ( 'cau_set_schedule_mail' ) ) {
90
  $setScheduleStatus = 'enabled';
91
  $setScheduleIcon = 'yes';
@@ -217,7 +222,7 @@ if( checkAutomaticUpdaterDisabled() ) { ?>
217
  <td class="cau_plugin_issue_fixit">
218
  <form method="POST">
219
  <button type="submit" name="fixit" class="button button-primary"><?php _e( 'Fix it', 'companion-auto-update' ); ?></button>
220
- <a href="<?php echo admin_url( cau_menloc().'?page=cau-settings&tab=support' ); ?>" class="button"><?php _e( 'Contact for support', 'companion-auto-update' ); ?></a>
221
  </form>
222
  </td>
223
  </tr>
@@ -246,7 +251,7 @@ if( checkCronjobsDisabled() ) { ?>
246
  <?php _e( 'Cronjobs are disabled.', 'companion-auto-update' ); ?>
247
  </td>
248
  <td class="cau_plugin_issue_fixit">
249
- <a href="<?php echo admin_url( cau_menloc().'?page=cau-settings&tab=support' ); ?>" class="button"><?php _e( 'Contact for support', 'companion-auto-update' ); ?></a>
250
  </td>
251
  </tr>
252
  </tbody>
1
  <?php
2
+
3
+ // Date format
4
  $dateFormat = get_option( 'date_format' );
5
  $dateFormat .= ' '.get_option( 'time_format' );
6
 
7
+ // Make sure the correct timezone is set
8
+ date_default_timezone_set( get_option('timezone_string') );
9
+
10
  global $wpdb;
11
  $table_name = $wpdb->prefix . "auto_updates";
12
 
13
  // Minor updates
14
+ $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'minor'");
15
  foreach ( $configs as $config ) {
16
 
17
  if( $config->onoroff == 'on' && wp_get_schedule( 'wp_version_check' ) ) {
31
  }
32
 
33
  // Major updates
34
+ $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'major'");
35
  foreach ( $configs as $config ) {
36
 
37
  if( $config->onoroff == 'on' && wp_get_schedule( 'wp_version_check' ) ) {
51
  }
52
 
53
  // Plugin updates
54
+ $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'plugins'");
55
  foreach ( $configs as $config ) {
56
 
57
  if( $config->onoroff == 'on' && wp_get_schedule( 'wp_update_plugins' ) ) {
71
  }
72
 
73
  // Themes updates
74
+ $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'themes'");
75
  foreach ( $configs as $config ) {
76
 
77
  if( $config->onoroff == 'on' && wp_get_schedule( 'wp_update_plugins' ) ) {
90
 
91
  }
92
 
93
+ // E-mail notifications
94
  if ( wp_next_scheduled ( 'cau_set_schedule_mail' ) ) {
95
  $setScheduleStatus = 'enabled';
96
  $setScheduleIcon = 'yes';
222
  <td class="cau_plugin_issue_fixit">
223
  <form method="POST">
224
  <button type="submit" name="fixit" class="button button-primary"><?php _e( 'Fix it', 'companion-auto-update' ); ?></button>
225
+ <a href="<?php echo cau_url( 'support' ); ?>" class="button"><?php _e( 'Contact for support', 'companion-auto-update' ); ?></a>
226
  </form>
227
  </td>
228
  </tr>
251
  <?php _e( 'Cronjobs are disabled.', 'companion-auto-update' ); ?>
252
  </td>
253
  <td class="cau_plugin_issue_fixit">
254
+ <a href="<?php echo cau_url( 'support' ); ?>" class="button"><?php _e( 'Contact for support', 'companion-auto-update' ); ?></a>
255
  </td>
256
  </tr>
257
  </tbody>
admin/support.php CHANGED
@@ -5,7 +5,7 @@
5
  <ul>
6
  <li><a href="https://codeermeneer.nl/stuffs/faq-auto-updater/" target="_blank"><?php _e( 'Frequently Asked Questions', 'companion-auto-update' ); ?></a></li>
7
  <li><a href="https://wordpress.org/support/plugin/companion-auto-update" target="_blank"><?php _e( 'Support Forums' ); ?></a></li>
8
- <li><a href="<?php echo admin_url( cau_menloc().'?page=cau-settings&tab=status&cau_page=status' ); ?>"><?php _e( 'Status', 'companion-auto-update' ); ?></a></li>
9
  </ul>
10
  </div><div class="welcome-column welcome-column welcome-column-third">
11
  <h3><?php _e( 'Want to contribute?', 'companion-auto-update' ); ?></h3>
@@ -38,13 +38,14 @@
38
  <h3><?php _e( 'Like our plugin?', 'companion-auto-update' ); ?></h3>
39
  <p><?php _e('Companion Auto Update is free to use. It has required a great deal of time and effort to develop and you can help support this development by making a small donation.<br />You get useful software and we get to carry on making it better.', 'companion-auto-update'); ?></p>
40
  </div><div class="welcome-column welcome-column welcome-column-half">
41
- <a href="<?php echo cau_donateUrl(); ?>" target="_blank" class="cau-button donate-button">
42
- <span class="dashicons dashicons-heart"></span>
43
- <?php _e('Donate to help development', 'companion-auto-update'); ?>
44
- </a>
45
  <a href="https://wordpress.org/support/plugin/companion-auto-update/reviews/#new-post" target="_blank" class="cau-button rate-button">
46
  <span class="dashicons dashicons-star-filled"></span>
47
  <?php _e('Rate us (5 stars?)', 'companion-auto-update'); ?>
48
  </a>
 
 
 
 
 
49
  </div>
50
  </div>
5
  <ul>
6
  <li><a href="https://codeermeneer.nl/stuffs/faq-auto-updater/" target="_blank"><?php _e( 'Frequently Asked Questions', 'companion-auto-update' ); ?></a></li>
7
  <li><a href="https://wordpress.org/support/plugin/companion-auto-update" target="_blank"><?php _e( 'Support Forums' ); ?></a></li>
8
+ <li><a href="<?php echo cau_url( 'status' ); ?>"><?php _e( 'Status', 'companion-auto-update' ); ?></a></li>
9
  </ul>
10
  </div><div class="welcome-column welcome-column welcome-column-third">
11
  <h3><?php _e( 'Want to contribute?', 'companion-auto-update' ); ?></h3>
38
  <h3><?php _e( 'Like our plugin?', 'companion-auto-update' ); ?></h3>
39
  <p><?php _e('Companion Auto Update is free to use. It has required a great deal of time and effort to develop and you can help support this development by making a small donation.<br />You get useful software and we get to carry on making it better.', 'companion-auto-update'); ?></p>
40
  </div><div class="welcome-column welcome-column welcome-column-half">
 
 
 
 
41
  <a href="https://wordpress.org/support/plugin/companion-auto-update/reviews/#new-post" target="_blank" class="cau-button rate-button">
42
  <span class="dashicons dashicons-star-filled"></span>
43
  <?php _e('Rate us (5 stars?)', 'companion-auto-update'); ?>
44
  </a>
45
+ <a href="<?php echo cau_donateUrl(); ?>" target="_blank" class="cau-button donate-button">
46
+ <span class="dashicons dashicons-heart"></span>
47
+ <?php _e('Donate to help development', 'companion-auto-update'); ?>
48
+ </a>
49
+ <p style="font-size: 12px; color: #BDBDBD;">Donations via PayPal. Amount can be changed.</p>
50
  </div>
51
  </div>
cau_emails.php CHANGED
@@ -40,10 +40,11 @@ function cau_set_email() {
40
  // Set the content for the emails about pending updates
41
  function cau_pending_message( $single, $plural ) {
42
 
43
- return sprintf(
44
- esc_html__( 'Howdy! There are one or more %1$s updates waiting on your WordPress site at %2$s but we noticed that you disabled auto-updating for %3$s.
45
 
46
- Outdated %3$s are a security risk so please consider manually updating them via your dashboard.', 'companion-auto-update' ), $single, get_site_url(), $plural );
 
 
47
 
48
  }
49
 
@@ -51,7 +52,7 @@ Outdated %3$s are a security risk so please consider manually updating them via
51
  function cau_updated_message( $type, $updatedList ) {
52
 
53
  $text = sprintf( esc_html__(
54
- 'Howdy! One or more %1$s on your WordPress site at %2$s have been updated by Companion Auto Update. No further action is needed on your part.
55
  For more info on what is new visit your dashboard and check the changelog.
56
 
57
  The following %1$s have been updated:', 'companion-auto-update'
@@ -143,15 +144,18 @@ function cau_plugin_updated() {
143
  $themeDates = array();
144
 
145
  // Where to look for plugins
146
- $plugdir = plugin_dir_path( __DIR__ );
147
- $allPlugins = get_plugins();
148
 
149
  // Where to look for themes
150
- $themedir = get_theme_root();
151
- $allThemes = wp_get_themes();
 
 
 
152
 
153
  // Loop trough all plugins
154
- foreach ( $allPlugins as $key => $value) {
155
 
156
  // Get plugin data
157
  $fullPath = $plugdir.'/'.$key;
@@ -160,7 +164,6 @@ function cau_plugin_updated() {
160
 
161
  // Get last update date
162
  $fileDate = date ( 'YmdHi', filemtime( $fullPath ) );
163
- $mailSched = wp_get_schedule( 'cau_set_schedule_mail' );
164
 
165
  if( $mailSched == 'hourly' ) {
166
  $lastday = date( 'YmdHi', strtotime( '-1 hour' ) );
@@ -188,7 +191,7 @@ function cau_plugin_updated() {
188
  }
189
 
190
  // Loop trough all themes
191
- foreach ( $allThemes as $key => $value) {
192
 
193
  // Get theme data
194
  $fullPath = $themedir.'/'.$key;
@@ -197,7 +200,6 @@ function cau_plugin_updated() {
197
  // Get last update date
198
  $dateFormat = get_option( 'date_format' );
199
  $fileDate = date ( 'YmdHi', filemtime( $fullPath ) );
200
- $mailSched = wp_get_schedule( 'cau_set_schedule_mail' );
201
 
202
  if( $mailSched == 'hourly' ) {
203
  $lastday = date( 'YmdHi', strtotime( '-1 hour' ) );
@@ -224,26 +226,23 @@ function cau_plugin_updated() {
224
  $updatedListT = '';
225
 
226
  foreach ( $pluginDates as $key => $value ) {
227
-
228
  $updatedListP .= "- ".$pluginNames[$key]." to version ".$pluginVersion[$key]."\n";
229
  $totalNumP++;
230
-
231
  }
232
  foreach ( $themeNames as $key => $value ) {
233
-
234
  $updatedListT .= "- ".$themeNames[$key]."\n";
235
  $totalNumT++;
236
-
237
  }
238
 
239
-
240
  // If plugins have been updated, send email
241
  if( $totalNumP > 0 ) {
242
 
 
243
  $subject = '[' . get_bloginfo( 'name' ) . '] ' . __('One or more plugins have been updated.', 'companion-auto-update');
244
  $type = __('plugins', 'companion-auto-update');
245
  $message = cau_updated_message( $type, "\n".$updatedListP );
246
 
 
247
  foreach ( cau_set_email() as $key => $value) {
248
  foreach ($value as $k => $v) {
249
  wp_mail( $v, $subject, $message, $headers );
@@ -256,10 +255,12 @@ function cau_plugin_updated() {
256
  // If themes have been updated, send email
257
  if( $totalNumT > 0 ) {
258
 
 
259
  $subject = '[' . get_bloginfo( 'name' ) . '] ' . __('One or more themes have been updated.', 'companion-auto-update');
260
  $type = __('themes', 'companion-auto-update');
261
  $message = cau_updated_message( $type, "\n".$updatedListT );
262
 
 
263
  foreach ( cau_set_email() as $key => $value) {
264
  foreach ($value as $k => $v) {
265
  wp_mail( $v, $subject, $message, $headers );
@@ -268,6 +269,14 @@ function cau_plugin_updated() {
268
  }
269
 
270
  }
 
 
 
 
 
 
 
 
271
 
272
  }
273
 
40
  // Set the content for the emails about pending updates
41
  function cau_pending_message( $single, $plural ) {
42
 
43
+ $text = sprintf( esc_html__( 'There are one or more %s updates waiting on your WordPress site at %s but we noticed that you disabled auto-updating for %s.
 
44
 
45
+ Leaving your site outdated is a security risk so please consider manually updating them via your dashboard.', 'companion-auto-update' ), $single, get_site_url(), $plural );
46
+
47
+ return $text;
48
 
49
  }
50
 
52
  function cau_updated_message( $type, $updatedList ) {
53
 
54
  $text = sprintf( esc_html__(
55
+ 'One or more %1$s on your WordPress site at %2$s have been updated by Companion Auto Update. No further action is needed on your part.
56
  For more info on what is new visit your dashboard and check the changelog.
57
 
58
  The following %1$s have been updated:', 'companion-auto-update'
144
  $themeDates = array();
145
 
146
  // Where to look for plugins
147
+ $plugdir = plugin_dir_path( __DIR__ );
148
+ $allPlugins = get_plugins();
149
 
150
  // Where to look for themes
151
+ $themedir = get_theme_root();
152
+ $allThemes = wp_get_themes();
153
+
154
+ // Mail schedule
155
+ $mailSched = wp_get_schedule( 'cau_set_schedule_mail' );
156
 
157
  // Loop trough all plugins
158
+ foreach ( $allPlugins as $key => $value ) {
159
 
160
  // Get plugin data
161
  $fullPath = $plugdir.'/'.$key;
164
 
165
  // Get last update date
166
  $fileDate = date ( 'YmdHi', filemtime( $fullPath ) );
 
167
 
168
  if( $mailSched == 'hourly' ) {
169
  $lastday = date( 'YmdHi', strtotime( '-1 hour' ) );
191
  }
192
 
193
  // Loop trough all themes
194
+ foreach ( $allThemes as $key => $value ) {
195
 
196
  // Get theme data
197
  $fullPath = $themedir.'/'.$key;
200
  // Get last update date
201
  $dateFormat = get_option( 'date_format' );
202
  $fileDate = date ( 'YmdHi', filemtime( $fullPath ) );
 
203
 
204
  if( $mailSched == 'hourly' ) {
205
  $lastday = date( 'YmdHi', strtotime( '-1 hour' ) );
226
  $updatedListT = '';
227
 
228
  foreach ( $pluginDates as $key => $value ) {
 
229
  $updatedListP .= "- ".$pluginNames[$key]." to version ".$pluginVersion[$key]."\n";
230
  $totalNumP++;
 
231
  }
232
  foreach ( $themeNames as $key => $value ) {
 
233
  $updatedListT .= "- ".$themeNames[$key]."\n";
234
  $totalNumT++;
 
235
  }
236
 
 
237
  // If plugins have been updated, send email
238
  if( $totalNumP > 0 ) {
239
 
240
+ // E-mail content
241
  $subject = '[' . get_bloginfo( 'name' ) . '] ' . __('One or more plugins have been updated.', 'companion-auto-update');
242
  $type = __('plugins', 'companion-auto-update');
243
  $message = cau_updated_message( $type, "\n".$updatedListP );
244
 
245
+ // Send to all addresses
246
  foreach ( cau_set_email() as $key => $value) {
247
  foreach ($value as $k => $v) {
248
  wp_mail( $v, $subject, $message, $headers );
255
  // If themes have been updated, send email
256
  if( $totalNumT > 0 ) {
257
 
258
+ // E-mail content
259
  $subject = '[' . get_bloginfo( 'name' ) . '] ' . __('One or more themes have been updated.', 'companion-auto-update');
260
  $type = __('themes', 'companion-auto-update');
261
  $message = cau_updated_message( $type, "\n".$updatedListT );
262
 
263
+ // Send to all addresses
264
  foreach ( cau_set_email() as $key => $value) {
265
  foreach ($value as $k => $v) {
266
  wp_mail( $v, $subject, $message, $headers );
269
  }
270
 
271
  }
272
+
273
+ // Prevent duplicate emails by setting the event again
274
+ if( $totalNumT > 0 OR $totalNumP > 0 ) {
275
+ if( $mailSched == 'hourly' ) {
276
+ wp_clear_scheduled_hook('cau_set_schedule_mail');
277
+ wp_schedule_event( strtotime( '+1 hour', time() ) , 'hourly', 'cau_set_schedule_mail' );
278
+ }
279
+ }
280
 
281
  }
282
 
cau_functions.php CHANGED
@@ -47,11 +47,11 @@ function cau_pluginHasIssues() {
47
  }
48
  function cau_pluginIssueLevels() {
49
 
50
- if( cau_incompatiblePlugins() OR get_option( 'blog_public' ) == 0 ) {
51
  $level = 'low';
52
  }
53
 
54
- if( checkAutomaticUpdaterDisabled() OR checkCronjobsDisabled() ) {
55
  $level = 'high';
56
  }
57
 
@@ -232,12 +232,18 @@ function checkCronjobsDisabled() {
232
  }
233
 
234
  // Menu location
235
- function cau_menloc() {
236
- return 'tools.php';
 
 
 
237
  }
238
 
239
  // Get the active tab
240
  function active_tab( $page, $identifier = 'tab' ) {
 
 
 
241
 
242
  if( !isset( $_GET[ $identifier ] ) ) {
243
  $cur_page = '';
@@ -246,7 +252,7 @@ function active_tab( $page, $identifier = 'tab' ) {
246
  }
247
 
248
  if( $page == $cur_page ) {
249
- echo 'nav-tab-active';
250
  }
251
 
252
  }
@@ -325,9 +331,6 @@ function cau_fetch_log( $limit, $format = 'simple' ) {
325
  // Date format
326
  $dateFormat = get_option( 'date_format' );
327
 
328
- // Make sure it shows the correct time
329
- date_default_timezone_set( get_option('timezone_string') );
330
-
331
  // PLUGINS
332
  if( $plugins ) {
333
 
@@ -421,8 +424,14 @@ function cau_fetch_log( $limit, $format = 'simple' ) {
421
  $coreFile = get_home_path().'wp-admin/about.php';
422
  if( file_exists( $coreFile ) ) {
423
  $coreDate = date( 'YmdHi', filemtime( $coreFile ) );
424
- $coreDateF = date_i18n( $dateFormat, filemtime( $coreFile ) );
425
- $coreDateF .= ' &dash; '.date( 'H:i', filemtime( $coreFile ) );
 
 
 
 
 
 
426
  } else {
427
  $coreDate = date('YmdHi');
428
  $coreDateF = 'Could not read core date.';
47
  }
48
  function cau_pluginIssueLevels() {
49
 
50
+ if( cau_incompatiblePlugins() OR get_option( 'blog_public' ) == 0 OR checkCronjobsDisabled() ) {
51
  $level = 'low';
52
  }
53
 
54
+ if( checkAutomaticUpdaterDisabled() ) {
55
  $level = 'high';
56
  }
57
 
232
  }
233
 
234
  // Menu location
235
+ function cau_menloc( $after = '' ) {
236
+ return 'tools.php'.$after;
237
+ }
238
+ function cau_url( $tab = '' ) {
239
+ return admin_url( cau_menloc( '?page=cau-settings&tab='.$tab ) );
240
  }
241
 
242
  // Get the active tab
243
  function active_tab( $page, $identifier = 'tab' ) {
244
+ echo _active_tab( $page, $identifier );
245
+ }
246
+ function _active_tab( $page, $identifier = 'tab' ) {
247
 
248
  if( !isset( $_GET[ $identifier ] ) ) {
249
  $cur_page = '';
252
  }
253
 
254
  if( $page == $cur_page ) {
255
+ return 'nav-tab-active';
256
  }
257
 
258
  }
331
  // Date format
332
  $dateFormat = get_option( 'date_format' );
333
 
 
 
 
334
  // PLUGINS
335
  if( $plugins ) {
336
 
424
  $coreFile = get_home_path().'wp-admin/about.php';
425
  if( file_exists( $coreFile ) ) {
426
  $coreDate = date( 'YmdHi', filemtime( $coreFile ) );
427
+
428
+ if( $format == 'table' ) {
429
+ $coreDateF = date_i18n( $dateFormat, filemtime( $coreFile ) );
430
+ $coreDateF .= ' &dash; '.date ( 'H:i', filemtime( $coreFile ) );
431
+ } else {
432
+ $coreDateF = date_i18n( $dateFormat, filemtime( $coreFile ) );
433
+ }
434
+
435
  } else {
436
  $coreDate = date('YmdHi');
437
  $coreDateF = 'Could not read core date.';
companion-auto-update.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Companion Auto Update
4
  * Plugin URI: http://codeermeneer.nl/portfolio/companion-auto-update/
5
  * Description: This plugin auto updates all plugins, all themes and the wordpress core.
6
- * Version: 3.3.8
7
  * Author: Papin Schipper
8
  * Author URI: http://codeermeneer.nl/
9
  * Contributors: papin
@@ -51,7 +51,7 @@ add_action('admin_init', 'cau_pluginRedirectWelcomeScreen');
51
 
52
  // Donate url
53
  function cau_donateUrl() {
54
- return 'https://www.paypal.me/dakel/5/';
55
  }
56
 
57
  // Create database
@@ -93,7 +93,7 @@ function cau_check_if_exists( $whattocheck ) {
93
  global $wpdb;
94
  $table_name = $wpdb->prefix . "auto_updates";
95
 
96
- $rows = $wpdb->get_col( "SELECT COUNT(*) as num_rows FROM {$table_name} WHERE name = '$whattocheck'" );
97
  $check = $rows[0];
98
 
99
  if( $check > 0) {
@@ -153,7 +153,7 @@ require_once( plugin_dir_path( __FILE__ ) . 'cau_functions.php' );
153
 
154
  // Add plugin to menu
155
  function register_cau_menu_page() {
156
- add_submenu_page( cau_menloc() , __('Auto Updater', 'companion-auto-update'), __('Auto Updater', 'companion-auto-update'), 'manage_options', 'cau-settings', 'cau_frontend' );
157
  }
158
  add_action( 'admin_menu', 'register_cau_menu_page' );
159
 
@@ -164,39 +164,38 @@ function cau_frontend() { ?>
164
 
165
  <h1 class="wp-heading-inline"><?php _e('Companion Auto Update', 'companion-auto-update'); ?></h1>
166
 
167
- <div class='cau_support_buttons'>
168
- <a href="<?php echo cau_donateUrl(); ?>" target="_blank" class="donate-button page-title-action cau_hide_on_mobile"><?php _e('Donate to help development', 'companion-auto-update'); ?></a>
169
- </div>
170
-
171
  <hr class="wp-header-end">
172
 
173
- <h2 class="nav-tab-wrapper wp-clearfix">
174
- <a href="<?php echo cau_menloc(); ?>?page=cau-settings" class="nav-tab <?php active_tab(''); ?>"><?php _e('Dashboard' ); ?></a>
175
- <a href="<?php echo cau_menloc(); ?>?page=cau-settings&amp;tab=schedule&cau_page=advanced" class="nav-tab <?php active_tab('schedule', 'tab'); ?>"><?php _e('Advanced settings', 'companion-auto-update'); ?></a>
176
- <a href="<?php echo cau_menloc(); ?>?page=cau-settings&amp;tab=pluginlist&cau_page=advanced" class="nav-tab <?php active_tab('pluginlist', 'tab'); ?>"><?php _e('Select plugins', 'companion-auto-update'); ?></a>
177
- <a href="<?php echo cau_menloc(); ?>?page=cau-settings&amp;tab=log&amp;cau_page=log" class="systeminfoTab nav-tab <?php active_tab('log', 'cau_page'); ?>"><?php _e('Update log', 'companion-auto-update'); ?></a>
178
- <a href="<?php echo cau_menloc(); ?>?page=cau-settings&amp;tab=status&amp;cau_page=status" class="systeminfoTab nav-tab <?php active_tab('status', 'cau_page'); ?>"><?php _e('Status', 'companion-auto-update'); ?></a>
179
- <a href="<?php echo cau_menloc(); ?>?page=cau-settings&amp;tab=support" class="nav-tab <?php active_tab('support'); ?>"><?php _e('Support', 'companion-auto-update'); ?></a>
180
- </h2>
181
-
182
  <?php
183
 
184
- if( !isset( $_GET['tab'] ) ) {
185
-
186
- require_once( plugin_dir_path( __FILE__ ) . 'admin/dashboard.php' );
187
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  } else {
 
 
189
 
190
- $requestedPage = $_GET['tab'];
191
- $allowedPages = array( 'dashboard', 'log', 'pluginlist', 'rollback', 'schedule', 'status', 'support' );
192
-
193
- if( in_array( $requestedPage, $allowedPages) ) {
194
- require_once( plugin_dir_path( __FILE__ ) . 'admin/'.$requestedPage.'.php' );
195
- } else {
196
- wp_die( 'You\'re not allowed to view <strong>'.$requestedPage.'</strong>.' );
197
- }
198
-
199
- } ?>
200
 
201
  </div>
202
 
@@ -214,9 +213,9 @@ function cau_widget() {
214
  echo '<p>'.__('Below are the last 7 updates ran on this site. Includes plugins and themes, both automatically updated and manually updated.', 'companion-auto-update').'</p>';
215
  cau_fetch_log( '7' );
216
  echo '<p>
217
- <a href="'.admin_url( cau_menloc().'?page=cau-settings&tab=log&cau_page=log').'">'.__('View full changelog', 'companion-auto-update').'</a>
218
  <span class="cau_divide">|</span>
219
- <a href="'.admin_url( cau_menloc().'?page=cau-settings').'">'.__( 'Settings' ).'</a>
220
  </p>';
221
 
222
  }
@@ -244,7 +243,7 @@ require_once( plugin_dir_path( __FILE__ ) . 'cau_emails.php' );
244
  // Add settings link on plugin page
245
  function cau_settings_link( $links ) {
246
 
247
- $settings_link = '<a href="'.get_admin_url().''.cau_menloc().'?page=cau-settings">'.__( 'Settings' ).'</a>';
248
  $settings_link2 = '<a href="https://translate.wordpress.org/projects/wp-plugins/companion-auto-update">'.__( 'Help us translate', 'companion-auto-update' ).'</a>';
249
  $settings_link3 = '<a href="'.cau_donateUrl().'">'.__( 'Donate to help development', 'companion-auto-update' ).'</a>';
250
 
@@ -341,7 +340,7 @@ function cau_checkForIssues( $admin_bar ) {
341
  $admin_bar->add_menu( array(
342
  'id' => 'cau-has-issues',
343
  'title' => '<span class="ab-icon"></span><span class="cau-level-'.cau_pluginIssueLevels().'">'.cau_pluginIssueCount().'</span>',
344
- 'href' => admin_url( cau_menloc().'?page=cau-settings&tab=status&cau_page=status' ),
345
  'meta' => array(
346
  'target' => '_self',
347
  'title' => $cauWaningBarTitle,
3
  * Plugin Name: Companion Auto Update
4
  * Plugin URI: http://codeermeneer.nl/portfolio/companion-auto-update/
5
  * Description: This plugin auto updates all plugins, all themes and the wordpress core.
6
+ * Version: 3.3.9
7
  * Author: Papin Schipper
8
  * Author URI: http://codeermeneer.nl/
9
  * Contributors: papin
51
 
52
  // Donate url
53
  function cau_donateUrl() {
54
+ return 'https://www.paypal.me/dakel/10/';
55
  }
56
 
57
  // Create database
93
  global $wpdb;
94
  $table_name = $wpdb->prefix . "auto_updates";
95
 
96
+ $rows = $wpdb->get_col( "SELECT COUNT(*) as num_rows FROM {$table_name} WHERE name = '{$whattocheck}'" );
97
  $check = $rows[0];
98
 
99
  if( $check > 0) {
153
 
154
  // Add plugin to menu
155
  function register_cau_menu_page() {
156
+ add_submenu_page( cau_menloc() , __( 'Auto Updater', 'companion-auto-update' ), __( 'Auto Updater', 'companion-auto-update' ), 'manage_options', 'cau-settings', 'cau_frontend' );
157
  }
158
  add_action( 'admin_menu', 'register_cau_menu_page' );
159
 
164
 
165
  <h1 class="wp-heading-inline"><?php _e('Companion Auto Update', 'companion-auto-update'); ?></h1>
166
 
 
 
 
 
167
  <hr class="wp-header-end">
168
 
 
 
 
 
 
 
 
 
 
169
  <?php
170
 
171
+ // Force tab parameter
172
+ if( !isset( $_GET['tab'] ) ) header( "Location: ".cau_url( 'dashboard' ) );
173
+
174
+ // Allow only access to these pages
175
+ $allowedPages = array(
176
+ 'dashboard' => __( 'Dashboard' ),
177
+ 'schedule' => __( 'Advanced settings', 'companion-auto-update' ),
178
+ 'pluginlist' => __( 'Select plugins', 'companion-auto-update' ),
179
+ 'log' => __( 'Update log', 'companion-auto-update' ),
180
+ 'status' => __( 'Status', 'companion-auto-update' ),
181
+ 'support' => __( 'Support', 'companion-auto-update' )
182
+ );
183
+
184
+ // Show subtabs
185
+ echo "<h2 class='nav-tab-wrapper wp-clearfix'>";
186
+ foreach ( $allowedPages as $page => $title ) echo "<a href='".cau_url( $page )."' class='nav-tab "._active_tab( $page )."'>".$title."</a>";
187
+ echo "</h2>";
188
+
189
+ // Show page content
190
+ $requestedPage = $_GET['tab'];
191
+
192
+ if( array_key_exists( $requestedPage, $allowedPages ) ) {
193
+ require_once( plugin_dir_path( __FILE__ ) . 'admin/'.$requestedPage.'.php' );
194
  } else {
195
+ wp_die( 'You\'re not allowed to view <strong>'.$requestedPage.'</strong>.' );
196
+ }
197
 
198
+ ?>
 
 
 
 
 
 
 
 
 
199
 
200
  </div>
201
 
213
  echo '<p>'.__('Below are the last 7 updates ran on this site. Includes plugins and themes, both automatically updated and manually updated.', 'companion-auto-update').'</p>';
214
  cau_fetch_log( '7' );
215
  echo '<p>
216
+ <a href="'.cau_url( 'log' ).'">'.__('View full changelog', 'companion-auto-update').'</a>
217
  <span class="cau_divide">|</span>
218
+ <a href="'.cau_url( 'dashboard' ).'">'.__( 'Settings' ).'</a>
219
  </p>';
220
 
221
  }
243
  // Add settings link on plugin page
244
  function cau_settings_link( $links ) {
245
 
246
+ $settings_link = '<a href="'.cau_url( 'dashboard' ).'">'.__( 'Settings' ).'</a>';
247
  $settings_link2 = '<a href="https://translate.wordpress.org/projects/wp-plugins/companion-auto-update">'.__( 'Help us translate', 'companion-auto-update' ).'</a>';
248
  $settings_link3 = '<a href="'.cau_donateUrl().'">'.__( 'Donate to help development', 'companion-auto-update' ).'</a>';
249
 
340
  $admin_bar->add_menu( array(
341
  'id' => 'cau-has-issues',
342
  'title' => '<span class="ab-icon"></span><span class="cau-level-'.cau_pluginIssueLevels().'">'.cau_pluginIssueCount().'</span>',
343
+ 'href' => cau_url( 'status' ),
344
  'meta' => array(
345
  'target' => '_self',
346
  'title' => $cauWaningBarTitle,
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: auto, automatic, background, update, updates, updating, automatic updates,
5
  Requires at least: 3.5.0
6
  Tested up to: 5.1
7
  Requires PHP: 5.1
8
- Stable tag: 3.3.8
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -72,6 +72,13 @@ For some reason this plugin seems to have trouble with updating themes by Elegan
72
 
73
  == Changelog ==
74
 
 
 
 
 
 
 
 
75
  = 3.3.8 (March 1, 2019) =
76
  * Fix: Show correct timestamp in log
77
  * Fix: Fixed a few typos
5
  Requires at least: 3.5.0
6
  Tested up to: 5.1
7
  Requires PHP: 5.1
8
+ Stable tag: 3.3.9
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
72
 
73
  == Changelog ==
74
 
75
+ = 3.3.9 (March 11, 2019) =
76
+ * Fix: Sometimes emails would be sent twice
77
+ * Fix: Cronjobs disabled shouldn't be a critical error
78
+ * Fix: Sometimes update reminder emails would not send at all
79
+ * Improvement: Removed "Howdy" from emails
80
+ * Improvement: Fixed a few typos
81
+
82
  = 3.3.8 (March 1, 2019) =
83
  * Fix: Show correct timestamp in log
84
  * Fix: Fixed a few typos