Companion Auto Update - Version 3.8.0

Version Description

(January 14, 2020) = * New: Better handling of plugins with an unknown WP version * New: More intervals for notifications * Fix: Call to undefined function errors

Download this release

Release Info

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

Code changes from version 3.7.1.1 to 3.8.0

admin/dashboard.php CHANGED
@@ -70,11 +70,12 @@ if( isset( $_POST['submit'] ) ) {
70
  // Intervals
71
 
72
  // Set variables
73
- $plugin_sc = sanitize_text_field( $_POST['plugin_schedule'] );
74
- $theme_sc = sanitize_text_field( $_POST['theme_schedule'] );
75
- $core_sc = sanitize_text_field( $_POST['core_schedule'] );
76
- $schedule_mail = sanitize_text_field( $_POST['schedule_mail'] );
77
- $html_or_text = sanitize_text_field( $_POST['html_or_text'] );
 
78
 
79
  // First clear schedules
80
  wp_clear_scheduled_hook('wp_update_plugins');
@@ -84,6 +85,7 @@ if( isset( $_POST['submit'] ) ) {
84
  wp_clear_scheduled_hook('cau_custom_hooks_plugins');
85
  wp_clear_scheduled_hook('cau_custom_hooks_themes');
86
  wp_clear_scheduled_hook('cau_log_updater');
 
87
 
88
  // Then set the new times
89
 
@@ -91,8 +93,8 @@ if( isset( $_POST['submit'] ) ) {
91
  if( $plugin_sc == 'daily' ) {
92
 
93
  $date = date( 'Y-m-d' );
94
- $hours = sanitize_text_field( $_POST['pluginScheduleTimeH'] );
95
- $minutes = sanitize_text_field( $_POST['pluginScheduleTimeM'] );
96
  $seconds = date( 's' );
97
  $fullDate = $date.' '.$hours.':'.$minutes.':'.$seconds;
98
  $pluginSetTime = strtotime( $fullDate );
@@ -113,8 +115,8 @@ if( isset( $_POST['submit'] ) ) {
113
  if( $theme_sc == 'daily' ) {
114
 
115
  $dateT = date( 'Y-m-d' );
116
- $hoursT = sanitize_text_field( $_POST['ThemeScheduleTimeH'] );
117
- $minutesT = sanitize_text_field( $_POST['ThemeScheduleTimeM'] );
118
  $secondsT = date( 's' );
119
  $fullDateT = $dateT.' '.$hoursT.':'.$minutesT.':'.$secondsT;
120
  $themeSetTime = strtotime( $fullDateT );
@@ -133,8 +135,8 @@ if( isset( $_POST['submit'] ) ) {
133
  if( $core_sc == 'daily' ) {
134
 
135
  $dateC = date( 'Y-m-d' );
136
- $hoursC = sanitize_text_field( $_POST['CoreScheduleTimeH'] );
137
- $minutesC = sanitize_text_field( $_POST['CoreScheduleTimeM'] );
138
  $secondsC = date( 's' );
139
  $fullDateC = $dateC.' '.$hoursC.':'.$minutesC.':'.$secondsC;
140
  $coreSetTime = strtotime( $fullDateC );
@@ -147,12 +149,12 @@ if( isset( $_POST['submit'] ) ) {
147
 
148
  }
149
 
150
- // Emails
151
  if( $schedule_mail == 'daily' ) {
152
 
153
  $dateT = date( 'Y-m-d' );
154
- $hoursT = sanitize_text_field( $_POST['timeScheduleEmailTimeH'] );
155
- $minutesT = sanitize_text_field( $_POST['timeScheduleEmailTimeM'] );
156
  $secondsT = date( 's' );
157
  $fullDateT = $dateT.' '.$hoursT.':'.$minutesT.':'.$secondsT;
158
  $emailSetTime = strtotime( $fullDateT );
@@ -165,6 +167,25 @@ if( isset( $_POST['submit'] ) ) {
165
 
166
  }
167
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  echo '<div id="message" class="updated"><p><b>'.__( 'Settings saved.' ).'</b></p></div>';
169
 
170
  }
@@ -191,6 +212,7 @@ $plugin_schedule = wp_get_schedule( 'wp_update_plugins' );
191
  $theme_schedule = wp_get_schedule( 'wp_update_themes' );
192
  $core_schedule = wp_get_schedule( 'wp_version_check' );
193
  $schedule_mail = wp_get_schedule( 'cau_set_schedule_mail' );
 
194
  $cs_hooks_p = wp_get_schedule( 'cau_custom_hooks_plugins' );
195
  $cs_hooks_t = wp_get_schedule( 'cau_custom_hooks_themes' );
196
  $availableIntervals = cau_wp_get_schedules();
@@ -252,21 +274,16 @@ $availableIntervals = cau_wp_get_schedules();
252
 
253
  <table class="form-table">
254
  <tr>
255
- <th scope="row"><?php _e( 'Update available', 'companion-auto-update' );?></th>
256
- <td>
257
- <p>
258
- <input id="cau_send" name="cau_send" type="checkbox" <?php if( cau_get_db_value( 'send' ) == 'on' ) { echo 'checked'; } ?> />
259
- <label for="cau_send"><?php _e('Send me emails when an update is available.', 'companion-auto-update');?></label>
260
- </p>
261
- </td>
262
- </tr>
263
- <tr>
264
- <th scope="row"><?php _e( 'Successful update', 'companion-auto-update' );?></th>
265
  <td>
266
  <p>
267
  <input id="cau_send_update" name="cau_send_update" type="checkbox" <?php if( cau_get_db_value( 'sendupdate' ) == 'on' ) { echo 'checked'; } ?> />
268
  <label for="cau_send_update"><?php _e( 'Send me emails when something has been updated.', 'companion-auto-update' );?></label>
269
  </p>
 
 
 
 
270
  </td>
271
  </tr>
272
  <tr>
@@ -274,12 +291,12 @@ $availableIntervals = cau_wp_get_schedules();
274
  <td>
275
  <p>
276
  <input id="cau_send_outdated" name="cau_send_outdated" type="checkbox" <?php if( cau_get_db_value( 'sendoutdated' ) == 'on' ) { echo 'checked'; } ?> />
277
- <label for="cau_send_outdated"><?php _e( 'Be notified of plugins that have not been tested with your current version of WordPress.', 'companion-auto-update' );?></label>
278
  </p>
279
  </td>
280
  </tr>
281
  <tr>
282
- <th scope="row"><?php _e( 'Email Address' );?></th>
283
  <td>
284
  <p>
285
  <label for="cau_email"><?php _e( 'To', 'companion-auto-update' ); ?>:</label>
@@ -330,142 +347,83 @@ $availableIntervals = cau_wp_get_schedules();
330
 
331
  <div class="welcome-to-cau interval-bg welcome-panel cau-dashboard-box" style="overflow: hidden;">
332
 
333
- <h2 class="title"><?php _e('Intervals', 'companion-auto-update');?></h2>
334
-
335
- <div class="welcome-column welcome-column-quarter">
336
 
337
- <h4><?php _e( 'Plugin update interval', 'companion-auto-update' );?></h4>
338
- <p>
339
- <select name='plugin_schedule' id='plugin_schedule' class='schedule_interval wide'>
340
- <?php foreach ( $availableIntervals as $key => $value ) {
341
- echo "<option "; if( $plugin_schedule == $key ) { echo "selected "; } echo "value='".$key."'>".$value."</option>";
342
- } ?>
343
- </select>
344
- </p>
345
- <div class='timeSchedulePlugins' <?php if( $plugin_schedule != 'daily' ) { echo "style='display: none;'"; } ?> >
346
 
347
- <?php
348
 
349
- $setTimePlugins = wp_next_scheduled( 'wp_update_plugins' );
350
- $setTimePluginsHour = date( 'H' , $setTimePlugins );
351
- $setTimePluginsMin = date( 'i' , $setTimePlugins );
 
 
352
 
353
- ?>
 
 
 
 
 
 
 
354
 
355
- <div class='cau_schedule_input'>
356
- <input type='number' min='0' max='23' name='pluginScheduleTimeH' value='<?php echo $setTimePluginsHour; ?>' maxlength='2' >
 
 
 
357
  </div><div class='cau_schedule_input_div'>
358
  :
359
  </div><div class='cau_schedule_input'>
360
- <input type='number' min='0' max='59' name='pluginScheduleTimeM' value='<?php echo $setTimePluginsMin; ?>' maxlength='2' >
361
  </div><div class='cau_shedule_notation'>
362
- <span class='cau_tooltip'><span class="dashicons dashicons-editor-help"></span>
363
- <span class='cau_tooltip_text'><?php _e('At what time should the updater run? Only works when set to <u>daily</u>.', 'companion-auto-update'); ?> - <?php _e( 'Time notation: 24H', 'companion-auto-update'); ?></span>
364
  </span>
365
- </div>
366
 
367
- </div>
368
 
369
- </div><div class="welcome-column welcome-column-quarter">
370
 
371
- <h4><?php _e( 'Theme update interval', 'companion-auto-update' );?></h4>
372
- <p>
373
- <select name='theme_schedule' id='theme_schedule' class='schedule_interval wide'>
374
- <?php foreach ( $availableIntervals as $key => $value ) {
375
- echo "<option "; if( $theme_schedule == $key ) { echo "selected "; } echo "value='".$key."'>".$value."</option>";
376
- } ?>
377
- </select>
378
- </p>
379
- <div class='timeScheduleThemes' <?php if( $theme_schedule != 'daily' ) { echo "style='display: none;'"; } ?> >
380
-
381
- <?php
382
-
383
- $setTimeThemes = wp_next_scheduled( 'wp_update_themes' );
384
- $setTimeThemesHour = date( 'H' , $setTimeThemes );
385
- $setTimeThemesMins = date( 'i' , $setTimeThemes );
386
 
387
- ?>
388
 
389
- <div class='cau_schedule_input'>
390
- <input type='number' min='0' max='23' name='ThemeScheduleTimeH' value='<?php echo $setTimeThemesHour; ?>' maxlength='2' >
391
- </div><div class='cau_schedule_input_div'>
392
- :
393
- </div><div class='cau_schedule_input'>
394
- <input type='number' min='0' max='59' name='ThemeScheduleTimeM' value='<?php echo $setTimeThemesMins; ?>' maxlength='2' >
395
- </div><div class='cau_shedule_notation'>
396
- <span class='cau_tooltip'><span class="dashicons dashicons-editor-help"></span>
397
- <span class='cau_tooltip_text'><?php _e('At what time should the updater run? Only works when set to <u>daily</u>.', 'companion-auto-update'); ?> - <?php _e( 'Time notation: 24H', 'companion-auto-update'); ?></span>
398
- </span>
399
- </div>
400
- </div>
401
 
402
- </div><div class="welcome-column welcome-column-quarter">
403
 
404
- <h4><?php _e( 'Core update interval', 'companion-auto-update' );?></h4>
405
- <p>
406
- <select name='core_schedule' id='core_schedule' class='schedule_interval wide'>
407
- <?php foreach ( $availableIntervals as $key => $value ) {
408
- echo "<option "; if( $core_schedule == $key ) { echo "selected "; } echo "value='".$key."'>".$value."</option>";
409
- } ?>
410
- </select>
411
- </p>
412
- <div class='timeScheduleCore' <?php if( $core_schedule != 'daily' ) { echo "style='display: none;'"; } ?> >
413
 
414
- <?php
 
415
 
416
- $setTimeCore = wp_next_scheduled( 'wp_version_check' );
417
- $setTimeCoreHour = date( 'H' , $setTimeCore );
418
- $setTimeCoreMins = date( 'i' , $setTimeCore );
419
 
420
- ?>
421
 
422
- <div class='cau_schedule_input'>
423
- <input type='number' min='0' max='23' name='CoreScheduleTimeH' value='<?php echo $setTimeCoreHour; ?>' maxlength='2' >
424
- </div><div class='cau_schedule_input_div'>
425
- :
426
- </div><div class='cau_schedule_input'>
427
- <input type='number' min='0' max='59' name='CoreScheduleTimeM' value='<?php echo $setTimeCoreMins; ?>' maxlength='2' >
428
- </div><div class='cau_shedule_notation'>
429
- <span class='cau_tooltip'><span class="dashicons dashicons-editor-help"></span>
430
- <span class='cau_tooltip_text'><?php _e('At what time should the updater run? Only works when set to <u>daily</u>.', 'companion-auto-update'); ?> - <?php _e( 'Time notation: 24H', 'companion-auto-update'); ?></span>
431
- </span>
432
- </div>
433
- </div>
434
 
435
- </div><div class="welcome-column welcome-column-quarter">
436
 
437
- <h4><?php _e( 'Email Notifications', 'companion-auto-update' );?></h4>
438
- <p>
439
- <select id='schedule_mail' name='schedule_mail' class='schedule_interval wide'>
440
- <?php foreach ( $availableIntervals as $key => $value ) {
441
- echo "<option "; if( $schedule_mail == $key ) { echo "selected "; } echo "value='".$key."'>".$value."</option>";
442
- } ?>
443
- </select>
444
- </p>
445
- <div class='timeScheduleEmail' <?php if( $schedule_mail != 'daily' ) { echo "style='display: none;'"; } ?> >
446
 
447
- <?php
 
448
 
449
- $setTimeEmails = wp_next_scheduled( 'cau_set_schedule_mail' );
450
- $setTimeEmailHour = date( 'H' , $setTimeEmails );
451
- $setTimeEmailMins = date( 'i' , $setTimeEmails );
452
 
453
- ?>
454
 
455
- <div class='cau_schedule_input'>
456
- <input type='number' min='0' max='23' name='timeScheduleEmailTimeH' value='<?php echo $setTimeEmailHour; ?>' maxlength='2' >
457
- </div><div class='cau_schedule_input_div'>
458
- :
459
- </div><div class='cau_schedule_input'>
460
- <input type='number' min='0' max='59' name='timeScheduleEmailTimeM' value='<?php echo $setTimeEmailMins; ?>' maxlength='2' >
461
- </div><div class='cau_shedule_notation'>
462
- <span class='cau_tooltip'><span class="dashicons dashicons-editor-help"></span>
463
- <span class='cau_tooltip_text'><?php _e( 'Time notation: 24H', 'companion-auto-update'); ?></span>
464
- </span>
465
- </div>
466
- </div>
467
 
468
  </div>
 
469
  </div>
470
 
471
  <div class="welcome-to-cau advanced-bg welcome-panel cau-dashboard-box">
@@ -477,15 +435,15 @@ $availableIntervals = cau_wp_get_schedules();
477
  <tr>
478
  <th scope="row"><label><?php _e( 'Allow access to:', 'companion-auto-update' ); ?></label></th>
479
  <td>
480
- <p><label for="allow_administrator"><input name="allow_administrator" type="checkbox" id="allow_administrator" disabled="" checked=""><?php _e( 'Administrator' ); ?></label></p>
481
- <p><label for="allow_editor"><input name="allow_editor" type="checkbox" id="allow_editor" <?php if( cau_get_db_value( 'allow_editor' ) == 'on' ) { echo "CHECKED"; } ?>><?php _e( 'Editor' ); ?></label></p>
482
- <p><label for="allow_author"><input name="allow_author" type="checkbox" id="allow_author" <?php if( cau_get_db_value( 'allow_author' ) == 'on' ) { echo "CHECKED"; } ?>><?php _e( 'Author' ); ?></label></p>
483
  </td>
484
  </tr>
485
  <tr>
486
  <th scope="row"><label><?php _e( 'Delay updates', 'companion-auto-update' ); ?></label></th>
487
  <td>
488
- <p><label for="update_delay"><input name="update_delay" type="checkbox" id="update_delay" <?php if( cau_get_db_value( 'update_delay' ) == 'on' ) { echo "CHECKED"; } ?>><?php _e( 'Delay updates' ); ?></label></p>
489
  </td>
490
  </tr>
491
  <tr id='update_delay_days_block' <?php if( cau_get_db_value( 'update_delay' ) != 'on' ) { echo "class='disabled_option'"; } ?>>
@@ -548,7 +506,14 @@ $availableIntervals = cau_wp_get_schedules();
548
  <a href="<?php echo cau_donateUrl(); ?>" target="_blank" class="button button-primary button-hero">
549
  <?php _e('Donate to help development', 'companion-auto-update'); ?>
550
  </a>
551
- <p style="font-size: 12px; color: #BDBDBD;">Donations via PayPal. Amount can be changed.</p>
 
 
 
 
 
 
 
552
  </div>
553
 
554
  </div>
@@ -565,50 +530,28 @@ $availableIntervals = cau_wp_get_schedules();
565
  jQuery( '#update_delay_days_block' ).toggleClass( 'disabled_option' );
566
  });
567
 
568
- jQuery( '#plugin_schedule' ).change( function() {
569
-
570
- var selected = jQuery(this).val();
571
-
572
- if( selected == 'daily' ) {
573
- jQuery('.timeSchedulePlugins').show();
574
- } else {
575
- jQuery('.timeSchedulePlugins').hide();
576
- }
577
-
578
- });
579
-
580
- jQuery( '#theme_schedule' ).change( function() {
581
-
582
- var selected = jQuery(this).val();
583
-
584
- if( selected == 'daily' ) {
585
- jQuery('.timeScheduleThemes').show();
586
- } else {
587
- jQuery('.timeScheduleThemes').hide();
588
- }
589
-
590
- });
591
-
592
- jQuery( '#core_schedule' ).change( function() {
593
 
594
- var selected = jQuery(this).val();
 
595
 
596
  if( selected == 'daily' ) {
597
- jQuery('.timeScheduleCore').show();
598
  } else {
599
- jQuery('.timeScheduleCore').hide();
600
  }
601
 
602
  });
603
 
604
- jQuery( '#schedule_mail' ).change( function() {
605
 
606
- var selected = jQuery(this).val();
 
607
 
608
  if( selected == 'daily' ) {
609
- jQuery('.timeScheduleEmail').show();
610
  } else {
611
- jQuery('.timeScheduleEmail').hide();
612
  }
613
 
614
  });
70
  // Intervals
71
 
72
  // Set variables
73
+ $plugin_sc = sanitize_text_field( $_POST['plugin_schedule'] );
74
+ $theme_sc = sanitize_text_field( $_POST['theme_schedule'] );
75
+ $core_sc = sanitize_text_field( $_POST['core_schedule'] );
76
+ $schedule_mail = sanitize_text_field( $_POST['update_notifications'] );
77
+ $outdated_notifier = sanitize_text_field( $_POST['outdated_notifier'] );
78
+ $html_or_text = sanitize_text_field( $_POST['html_or_text'] );
79
 
80
  // First clear schedules
81
  wp_clear_scheduled_hook('wp_update_plugins');
85
  wp_clear_scheduled_hook('cau_custom_hooks_plugins');
86
  wp_clear_scheduled_hook('cau_custom_hooks_themes');
87
  wp_clear_scheduled_hook('cau_log_updater');
88
+ wp_clear_scheduled_hook('cau_outdated_notifier');
89
 
90
  // Then set the new times
91
 
93
  if( $plugin_sc == 'daily' ) {
94
 
95
  $date = date( 'Y-m-d' );
96
+ $hours = sanitize_text_field( $_POST['plugin_schedule-sethour'] );
97
+ $minutes = sanitize_text_field( $_POST['plugin_schedule-setminutes'] );
98
  $seconds = date( 's' );
99
  $fullDate = $date.' '.$hours.':'.$minutes.':'.$seconds;
100
  $pluginSetTime = strtotime( $fullDate );
115
  if( $theme_sc == 'daily' ) {
116
 
117
  $dateT = date( 'Y-m-d' );
118
+ $hoursT = sanitize_text_field( $_POST['theme_schedule-sethour'] );
119
+ $minutesT = sanitize_text_field( $_POST['theme_schedule-setminutes'] );
120
  $secondsT = date( 's' );
121
  $fullDateT = $dateT.' '.$hoursT.':'.$minutesT.':'.$secondsT;
122
  $themeSetTime = strtotime( $fullDateT );
135
  if( $core_sc == 'daily' ) {
136
 
137
  $dateC = date( 'Y-m-d' );
138
+ $hoursC = sanitize_text_field( $_POST['core_schedule-sethour'] );
139
+ $minutesC = sanitize_text_field( $_POST['core_schedule-setminutes'] );
140
  $secondsC = date( 's' );
141
  $fullDateC = $dateC.' '.$hoursC.':'.$minutesC.':'.$secondsC;
142
  $coreSetTime = strtotime( $fullDateC );
149
 
150
  }
151
 
152
+ // Update notifications
153
  if( $schedule_mail == 'daily' ) {
154
 
155
  $dateT = date( 'Y-m-d' );
156
+ $hoursT = sanitize_text_field( $_POST['update_notifications-sethour'] );
157
+ $minutesT = sanitize_text_field( $_POST['update_notifications-setminutes'] );
158
  $secondsT = date( 's' );
159
  $fullDateT = $dateT.' '.$hoursT.':'.$minutesT.':'.$secondsT;
160
  $emailSetTime = strtotime( $fullDateT );
167
 
168
  }
169
 
170
+ // Outdated notifications
171
+ if( $outdated_notifier == 'daily' ) {
172
+
173
+ $dateT = date( 'Y-m-d' );
174
+ $hoursT = sanitize_text_field( $_POST['outdated_notifier-sethour'] );
175
+ $minutesT = sanitize_text_field( $_POST['outdated_notifier-setminutes'] );
176
+ $secondsT = date( 's' );
177
+ $fullDateT = $dateT.' '.$hoursT.':'.$minutesT.':'.$secondsT;
178
+ $emailSetTime = strtotime( $fullDateT );
179
+
180
+ wp_schedule_event( $emailSetTime, $outdated_notifier, 'cau_outdated_notifier' );
181
+
182
+ } else {
183
+
184
+ wp_schedule_event( time(), $outdated_notifier, 'cau_outdated_notifier' );
185
+
186
+ }
187
+
188
+
189
  echo '<div id="message" class="updated"><p><b>'.__( 'Settings saved.' ).'</b></p></div>';
190
 
191
  }
212
  $theme_schedule = wp_get_schedule( 'wp_update_themes' );
213
  $core_schedule = wp_get_schedule( 'wp_version_check' );
214
  $schedule_mail = wp_get_schedule( 'cau_set_schedule_mail' );
215
+ $outdated_notifier = wp_get_schedule( 'cau_outdated_notifier' );
216
  $cs_hooks_p = wp_get_schedule( 'cau_custom_hooks_plugins' );
217
  $cs_hooks_t = wp_get_schedule( 'cau_custom_hooks_themes' );
218
  $availableIntervals = cau_wp_get_schedules();
274
 
275
  <table class="form-table">
276
  <tr>
277
+ <th scope="row"><?php _e( 'Update notifications', 'companion-auto-update' );?></th>
 
 
 
 
 
 
 
 
 
278
  <td>
279
  <p>
280
  <input id="cau_send_update" name="cau_send_update" type="checkbox" <?php if( cau_get_db_value( 'sendupdate' ) == 'on' ) { echo 'checked'; } ?> />
281
  <label for="cau_send_update"><?php _e( 'Send me emails when something has been updated.', 'companion-auto-update' );?></label>
282
  </p>
283
+ <p>
284
+ <input id="cau_send" name="cau_send" type="checkbox" <?php if( cau_get_db_value( 'send' ) == 'on' ) { echo 'checked'; } ?> />
285
+ <label for="cau_send"><?php _e('Send me emails when an update is available.', 'companion-auto-update');?></label>
286
+ </p>
287
  </td>
288
  </tr>
289
  <tr>
291
  <td>
292
  <p>
293
  <input id="cau_send_outdated" name="cau_send_outdated" type="checkbox" <?php if( cau_get_db_value( 'sendoutdated' ) == 'on' ) { echo 'checked'; } ?> />
294
+ <label for="cau_send_outdated"><?php _e( 'Be notified of plugins that have not been tested with the 3 latest major versions of WordPress.', 'companion-auto-update' );?></label>
295
  </p>
296
  </td>
297
  </tr>
298
  <tr>
299
+ <th scope="row"><?php _e( 'Email Address', 'companion-auto-update' );?></th>
300
  <td>
301
  <p>
302
  <label for="cau_email"><?php _e( 'To', 'companion-auto-update' ); ?>:</label>
347
 
348
  <div class="welcome-to-cau interval-bg welcome-panel cau-dashboard-box" style="overflow: hidden;">
349
 
350
+ <h2 class="title"><?php _e( 'Intervals', 'companion-auto-update' );?></h2>
 
 
351
 
352
+ <?php
 
 
 
 
 
 
 
 
353
 
354
+ function cau_show_interval_selection( $identiefier, $schedule ) {
355
 
356
+ // Get the info
357
+ $setValue = wp_get_schedule( $schedule );
358
+ $setTime = wp_next_scheduled( $schedule );
359
+ $setHour = date( 'H' , $setTime );
360
+ $setMinutes = date( 'i' , $setTime );
361
 
362
+ // Show interval selection
363
+ echo "<p>";
364
+ echo "<select name='$identiefier' id='$identiefier' class='schedule_interval wide interval_scheduler' data-timeblock='$identiefier'>";
365
+ foreach ( cau_wp_get_schedules() as $key => $value ) {
366
+ echo "<option "; if( $setValue == $key ) { echo "selected "; } echo "value='".$key."'>".$value."</option>";
367
+ }
368
+ echo "</select>";
369
+ echo "</p>";
370
 
371
+ // Set the time when daily is selected
372
+ echo "<div class='timeblock-$identiefier' style='display: none;'>";
373
+
374
+ echo "<div class='cau_schedule_input'>
375
+ <input type='number' min='0' max='23' name='".$identiefier."-sethour' value='$setHour' maxlength='2' >
376
  </div><div class='cau_schedule_input_div'>
377
  :
378
  </div><div class='cau_schedule_input'>
379
+ <input type='number' min='0' max='59' name='".$identiefier."-setminutes' value='$setMinutes' maxlength='2' >
380
  </div><div class='cau_shedule_notation'>
381
+ <span class='cau_tooltip'><span class='dashicons dashicons-editor-help'></span>
382
+ <span class='cau_tooltip_text'>".__( 'At what time should the updater run? Only works when set to <u>daily</u>.', 'companion-auto-update' )." - ".__( 'Time notation: 24H', 'companion-auto-update' )."</span>
383
  </span>
384
+ </div>";
385
 
386
+ echo "</div>";
387
 
388
+ }
389
 
390
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
391
 
392
+ <div class="welcome-column">
393
 
394
+ <h4><?php _e( 'Plugin update interval', 'companion-auto-update' );?></h4>
395
+ <?php cau_show_interval_selection( 'plugin_schedule', 'wp_update_plugins' ); ?>
 
 
 
 
 
 
 
 
 
 
396
 
397
+ </div>
398
 
399
+ <div class="welcome-column">
 
 
 
 
 
 
 
 
400
 
401
+ <h4><?php _e( 'Theme update interval', 'companion-auto-update' );?></h4>
402
+ <?php cau_show_interval_selection( 'theme_schedule', 'wp_update_themes' ); ?>
403
 
404
+ </div>
 
 
405
 
406
+ <div class="welcome-column">
407
 
408
+ <h4><?php _e( 'Core update interval', 'companion-auto-update' );?></h4>
409
+ <?php cau_show_interval_selection( 'core_schedule', 'wp_version_check' ); ?>
 
 
 
 
 
 
 
 
 
 
410
 
411
+ </div>
412
 
413
+ <div class="welcome-column">
 
 
 
 
 
 
 
 
414
 
415
+ <h4><?php _e( 'Update notifications', 'companion-auto-update' );?></h4>
416
+ <?php cau_show_interval_selection( 'update_notifications', 'cau_set_schedule_mail' ); ?>
417
 
418
+ </div>
 
 
419
 
420
+ <div class="welcome-column">
421
 
422
+ <h4><?php _e( 'Outdated software', 'companion-auto-update' );?></h4>
423
+ <?php cau_show_interval_selection( 'outdated_notifier', 'cau_outdated_notifier' ); ?>
 
 
 
 
 
 
 
 
 
 
424
 
425
  </div>
426
+
427
  </div>
428
 
429
  <div class="welcome-to-cau advanced-bg welcome-panel cau-dashboard-box">
435
  <tr>
436
  <th scope="row"><label><?php _e( 'Allow access to:', 'companion-auto-update' ); ?></label></th>
437
  <td>
438
+ <p><label for="allow_administrator"><input name="allow_administrator" type="checkbox" id="allow_administrator" disabled="" checked=""><?php _e( 'Administrator', 'companion-auto-update' ); ?></label></p>
439
+ <p><label for="allow_editor"><input name="allow_editor" type="checkbox" id="allow_editor" <?php if( cau_get_db_value( 'allow_editor' ) == 'on' ) { echo "CHECKED"; } ?>><?php _e( 'Editor', 'companion-auto-update' ); ?></label></p>
440
+ <p><label for="allow_author"><input name="allow_author" type="checkbox" id="allow_author" <?php if( cau_get_db_value( 'allow_author' ) == 'on' ) { echo "CHECKED"; } ?>><?php _e( 'Author', 'companion-auto-update' ); ?></label></p>
441
  </td>
442
  </tr>
443
  <tr>
444
  <th scope="row"><label><?php _e( 'Delay updates', 'companion-auto-update' ); ?></label></th>
445
  <td>
446
+ <p><label for="update_delay"><input name="update_delay" type="checkbox" id="update_delay" <?php if( cau_get_db_value( 'update_delay' ) == 'on' ) { echo "CHECKED"; } ?>><?php _e( 'Delay updates', 'companion-auto-update' ); ?></label></p>
447
  </td>
448
  </tr>
449
  <tr id='update_delay_days_block' <?php if( cau_get_db_value( 'update_delay' ) != 'on' ) { echo "class='disabled_option'"; } ?>>
506
  <a href="<?php echo cau_donateUrl(); ?>" target="_blank" class="button button-primary button-hero">
507
  <?php _e('Donate to help development', 'companion-auto-update'); ?>
508
  </a>
509
+ <p style="font-size: 12px; color: #BDBDBD;"><?php _e( 'Donations via PayPal. Amount can be changed.', 'companion-auto-update'); ?></p>
510
+ </div>
511
+
512
+ <div class="welcome-to-cau welcome-panel cau-dashboard-box">
513
+ <h3><span style='background: #EBE3F7; color: #BCADD3; padding: 1px 5px; border-radius: 3px; font-size: .8em'>Plugin Promotion</span></h3>
514
+ <h3>Keep your site fast with our Revision Manager</h3>
515
+ <p>Post Revisions are great, but will also slow down your site. Take back control over revisions with Companion Revision Manager!</p>
516
+ <a href="https://codeermeneer.nl/portfolio/plugin/companion-revision-manager/" target="_blank" class="button button-alt">Read more</a>
517
  </div>
518
 
519
  </div>
530
  jQuery( '#update_delay_days_block' ).toggleClass( 'disabled_option' );
531
  });
532
 
533
+ jQuery( '.interval_scheduler' ).change( function() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
534
 
535
+ var selected = jQuery(this).val(); // Selected value
536
+ var timeblock = jQuery(this).data( 'timeblock' ); // Corresponding time block
537
 
538
  if( selected == 'daily' ) {
539
+ jQuery( '.timeblock-'+timeblock ).show();
540
  } else {
541
+ jQuery( '.timeblock-'+timeblock ).hide();
542
  }
543
 
544
  });
545
 
546
+ jQuery( '.interval_scheduler' ).each( function() {
547
 
548
+ var selected = jQuery(this).val(); // Selected value
549
+ var timeblock = jQuery(this).data( 'timeblock' ); // Corresponding time block
550
 
551
  if( selected == 'daily' ) {
552
+ jQuery( '.timeblock-'+timeblock ).show();
553
  } else {
554
+ jQuery( '.timeblock-'+timeblock ).hide();
555
  }
556
 
557
  });
admin/status.php CHANGED
@@ -36,6 +36,7 @@
36
  global $wpdb;
37
  $table_name = $wpdb->prefix . "auto_updates";
38
  $schedules = wp_get_schedules();
 
39
 
40
  ?>
41
 
@@ -75,7 +76,7 @@
75
  $__status = 'enabled';
76
  $__icon = 'yes-alt';
77
  $__text = __( 'Enabled', 'companion-auto-update' );
78
- $__interval = wp_get_schedule( $eventNames[$key] );
79
  $__next = date_i18n( $dateFormat, wp_next_scheduled( $eventNames[$key] ) );
80
  } else {
81
  $__status = 'disabled';
@@ -132,7 +133,7 @@
132
  $__status = 'enabled';
133
  $__icon = 'yes-alt';
134
  $__text = __( 'Enabled', 'companion-auto-update' );
135
- $__interval = wp_get_schedule( $other_eventNames[$key] );
136
  $__next = date_i18n( $dateFormat, wp_next_scheduled( $other_eventNames[$key] ) );
137
  } else {
138
  $__status = 'warning';
@@ -322,7 +323,7 @@
322
  <tbody id="the-list">
323
  <tr>
324
  <td>
325
- <div class='button button-primary toggle_advanced_button'>Toggle</div>
326
 
327
  <div class='toggle_advanced_content' style='display: none;'>
328
  <?php
36
  global $wpdb;
37
  $table_name = $wpdb->prefix . "auto_updates";
38
  $schedules = wp_get_schedules();
39
+ $interval_names = cau_wp_get_schedules();
40
 
41
  ?>
42
 
76
  $__status = 'enabled';
77
  $__icon = 'yes-alt';
78
  $__text = __( 'Enabled', 'companion-auto-update' );
79
+ $__interval = $interval_names[wp_get_schedule( $eventNames[$key] )];
80
  $__next = date_i18n( $dateFormat, wp_next_scheduled( $eventNames[$key] ) );
81
  } else {
82
  $__status = 'disabled';
133
  $__status = 'enabled';
134
  $__icon = 'yes-alt';
135
  $__text = __( 'Enabled', 'companion-auto-update' );
136
+ $__interval = $interval_names[wp_get_schedule( $other_eventNames[$key] )];
137
  $__next = date_i18n( $dateFormat, wp_next_scheduled( $other_eventNames[$key] ) );
138
  } else {
139
  $__status = 'warning';
323
  <tbody id="the-list">
324
  <tr>
325
  <td>
326
+ <div class='button button-primary toggle_advanced_button'><?php _e( 'Toggle', 'companion-auto-update' ); ?></div>
327
 
328
  <div class='toggle_advanced_content' style='display: none;'>
329
  <?php
backend/style.css CHANGED
@@ -110,7 +110,8 @@
110
  padding: 5px;
111
  }
112
  select.schedule_interval {
113
- width: 90%;
 
114
  }
115
 
116
  /* Overwrite core UI */
110
  padding: 5px;
111
  }
112
  select.schedule_interval {
113
+ max-width: 90%;
114
+ width: 225px;
115
  }
116
 
117
  /* Overwrite core UI */
cau_emails.php CHANGED
@@ -3,14 +3,24 @@
3
  // Check if emails should be send or not
4
  function cau_check_updates_mail() {
5
 
 
6
  if( cau_get_db_value( 'send' ) == 'on' ) {
7
  cau_list_theme_updates(); // Check for theme updates
8
  cau_list_plugin_updates(); // Check for plugin updates
9
  }
10
 
11
- if( cau_get_db_value( 'sendupdate' ) == 'on' && cau_get_db_value( 'plugins' ) == 'on' ) cau_plugin_updated(); // Check for updated plugins
 
 
 
12
 
13
- if( cau_get_db_value( 'sendoutdated' ) == 'on' ) cau_list_outdated_software(); // Check for oudated plugins
 
 
 
 
 
 
14
  }
15
 
16
  // Ge the emailadresses it should be send to
@@ -31,6 +41,7 @@ function cau_set_email() {
31
  return $emailArray;
32
 
33
  }
 
34
  // Mail format
35
  function cau_is_html() {
36
 
@@ -65,6 +76,7 @@ function cau_outdated_message( $single, $plural, $list ) {
65
  $text .= "\n";
66
 
67
  foreach ( $list as $plugin => $version ) {
 
68
  $text .= "- ".sprintf( esc_html__( "%s tested up to: %s", "companion-auto-update" ), $plugin, $version )."\n";
69
  }
70
 
@@ -306,7 +318,7 @@ function cau_plugin_updated() {
306
 
307
  $dateFormat = get_option( 'date_format' );
308
  $timestamp = date_i18n( $dateFormat, filemtime( $fullPath ) );
309
- $timestamp .= ' &dash; '.date( 'H:i', filemtime( $fullPath ) );
310
 
311
  if( $fileDate >= $lastday ) {
312
 
@@ -348,7 +360,7 @@ function cau_plugin_updated() {
348
 
349
  $dateFormat = get_option( 'date_format' );
350
  $timestamp = date_i18n( $dateFormat, filemtime( $fullPath ) );
351
- $timestamp .= ' &dash; '.date( 'H:i', filemtime( $fullPath ) );
352
 
353
  if( $fileDate >= $lastday ) {
354
  array_push( $themeNames, $path_parts['filename'] );
3
  // Check if emails should be send or not
4
  function cau_check_updates_mail() {
5
 
6
+ // Notify of pending updates
7
  if( cau_get_db_value( 'send' ) == 'on' ) {
8
  cau_list_theme_updates(); // Check for theme updates
9
  cau_list_plugin_updates(); // Check for plugin updates
10
  }
11
 
12
+ // Notify of completed updates
13
+ if( cau_get_db_value( 'sendupdate' ) == 'on' && cau_get_db_value( 'plugins' ) == 'on' ) {
14
+ cau_plugin_updated(); // Check for updated plugins
15
+ }
16
 
17
+ }
18
+
19
+ // Notify of out of date software
20
+ function cau_outdated_notifier_mail() {
21
+ if( cau_get_db_value( 'sendoutdated' ) == 'on' ) {
22
+ cau_list_outdated_software(); // Check for oudated plugins
23
+ }
24
  }
25
 
26
  // Ge the emailadresses it should be send to
41
  return $emailArray;
42
 
43
  }
44
+
45
  // Mail format
46
  function cau_is_html() {
47
 
76
  $text .= "\n";
77
 
78
  foreach ( $list as $plugin => $version ) {
79
+ if( $version == '' ) $version = __( "Unknown", "companion-auto-update" );
80
  $text .= "- ".sprintf( esc_html__( "%s tested up to: %s", "companion-auto-update" ), $plugin, $version )."\n";
81
  }
82
 
318
 
319
  $dateFormat = get_option( 'date_format' );
320
  $timestamp = date_i18n( $dateFormat, filemtime( $fullPath ) );
321
+ $timestamp .= ' - '.date( 'H:i', filemtime( $fullPath ) );
322
 
323
  if( $fileDate >= $lastday ) {
324
 
360
 
361
  $dateFormat = get_option( 'date_format' );
362
  $timestamp = date_i18n( $dateFormat, filemtime( $fullPath ) );
363
+ $timestamp .= ' - '.date( 'H:i', filemtime( $fullPath ) );
364
 
365
  if( $fileDate >= $lastday ) {
366
  array_push( $themeNames, $path_parts['filename'] );
cau_functions.php CHANGED
@@ -173,6 +173,11 @@ function cau_incorrectDatabaseVersion() {
173
  // Run custom hooks on plugin update
174
  function cau_run_custom_hooks_p() {
175
 
 
 
 
 
 
176
  // Create array
177
  $allDates = array();
178
 
@@ -551,7 +556,12 @@ function cau_fetch_log( $limit, $format = 'simple' ) {
551
  $dateFormat = get_option( 'date_format' );
552
 
553
  // PLUGINS
554
- if( $plugins ) {
 
 
 
 
 
555
 
556
  // Where to look for plugins
557
  $plugdir = plugin_dir_path( __DIR__ );
@@ -1010,7 +1020,12 @@ function cau_plugin_info( $slug, $what ) {
1010
  // Get list of outdated plugins
1011
  function cau_list_outdated() {
1012
 
1013
- $outdatedList = array();
 
 
 
 
 
1014
 
1015
  foreach ( get_plugins() as $key => $value) {
1016
 
@@ -1052,6 +1067,11 @@ function cau_version_compare( $ver1, $ver2, $operator = null ) {
1052
  // Get plugin information of currently installed plugins
1053
  function cau_active_plugin_info( $slug, $what ) {
1054
 
 
 
 
 
 
1055
  $allPlugins = get_plugins();
1056
 
1057
  foreach ($allPlugins as $key => $value) {
@@ -1081,19 +1101,19 @@ function cau_addMoreIntervals( $schedules ) {
1081
  // Add a weekly interval.
1082
  $schedules['weekly'] = array(
1083
  'interval' => 604800,
1084
- 'display' => __( 'Once Weekly', 'companion-auto-update' ),
1085
  );
1086
 
1087
  // Add a twice montly interval.
1088
  $schedules['twice_monthly'] = array(
1089
- 'interval' => 1317600,
1090
- 'display' => __( 'Twice a month', 'companion-auto-update' ),
1091
  );
1092
 
1093
  // Add a montly interval.
1094
  $schedules['once_monthly'] = array(
1095
- 'interval' => 2635200,
1096
- 'display' => __( 'Once a month', 'companion-auto-update' ),
1097
  );
1098
 
1099
  return $schedules;
@@ -1118,19 +1138,48 @@ function cau_wp_get_schedules() {
1118
  // Do a bunch of checks to format them the right way
1119
  foreach ( $value as $display => $interval ) {
1120
 
1121
- if( $display == 'display' ) {
1122
- $intervalNames[$counter] = $interval; // Add the display name (i.e. "Once a month" or "Once Daily")
1123
- $counter++; // Make sure the next interval gets a new "key" value
1124
- } else {
1125
- if( $interval == '86400' ) $key = 'daily'; // Force the daily interval to be called daily, requires by a bunch of handles of this plugin
1126
  $intervalTimes[$counter] = $key; // Add the backend name (i.e. "once_monthly" or "daily")
1127
  $intervalUniques[$counter] = $interval; // Add the unix timestamp of this interval, used to identify unique items
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1128
  }
1129
 
1130
  }
1131
 
1132
  }
1133
 
 
 
 
1134
  // Prevent duplicates
1135
  foreach ( array_unique( $intervalUniques ) as $key => $value ) {
1136
  // $value is the timestamp
@@ -1162,6 +1211,12 @@ function cau_updateLogDBisEmpty() {
1162
  // Plugin information to DB
1163
  function cau_savePluginInformation( $method = 'New' ) {
1164
 
 
 
 
 
 
 
1165
  global $wpdb;
1166
  $updateDB = "update_log";
1167
  $updateLog = $wpdb->prefix.$updateDB;
173
  // Run custom hooks on plugin update
174
  function cau_run_custom_hooks_p() {
175
 
176
+ // Check if function exists
177
+ if ( ! function_exists( 'get_plugins' ) ) {
178
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
179
+ }
180
+
181
  // Create array
182
  $allDates = array();
183
 
556
  $dateFormat = get_option( 'date_format' );
557
 
558
  // PLUGINS
559
+ if( $plugins ) {
560
+
561
+ // Check if function exists
562
+ if ( ! function_exists( 'get_plugins' ) ) {
563
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
564
+ }
565
 
566
  // Where to look for plugins
567
  $plugdir = plugin_dir_path( __DIR__ );
1020
  // Get list of outdated plugins
1021
  function cau_list_outdated() {
1022
 
1023
+ $outdatedList = array();
1024
+
1025
+ // Check if function exists
1026
+ if ( ! function_exists( 'get_plugins' ) ) {
1027
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
1028
+ }
1029
 
1030
  foreach ( get_plugins() as $key => $value) {
1031
 
1067
  // Get plugin information of currently installed plugins
1068
  function cau_active_plugin_info( $slug, $what ) {
1069
 
1070
+ // Check if function exists
1071
+ if ( ! function_exists( 'get_plugins' ) ) {
1072
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
1073
+ }
1074
+
1075
  $allPlugins = get_plugins();
1076
 
1077
  foreach ($allPlugins as $key => $value) {
1101
  // Add a weekly interval.
1102
  $schedules['weekly'] = array(
1103
  'interval' => 604800,
1104
+ 'display' => __( 'Every week', 'companion-auto-update' ),
1105
  );
1106
 
1107
  // Add a twice montly interval.
1108
  $schedules['twice_monthly'] = array(
1109
+ 'interval' => 1209600,
1110
+ 'display' => __( 'Every 2 weeks', 'companion-auto-update' ),
1111
  );
1112
 
1113
  // Add a montly interval.
1114
  $schedules['once_monthly'] = array(
1115
+ 'interval' => 2419200,
1116
+ 'display' => __( 'Every 4 weeks', 'companion-auto-update' ),
1117
  );
1118
 
1119
  return $schedules;
1138
  // Do a bunch of checks to format them the right way
1139
  foreach ( $value as $display => $interval ) {
1140
 
1141
+ if( $display == 'interval' ) {
1142
+
1143
+ if( $interval == '86400' ) $key = 'daily'; // Force the daily interval to be called daily, required by a bunch of handles of this plugin
1144
+
 
1145
  $intervalTimes[$counter] = $key; // Add the backend name (i.e. "once_monthly" or "daily")
1146
  $intervalUniques[$counter] = $interval; // Add the unix timestamp of this interval, used to identify unique items
1147
+
1148
+ // Format display name in a proper way
1149
+ $numOfMinutes = ($interval/60);
1150
+ $identifier = __( 'minutes', 'companion-auto-update' );
1151
+
1152
+ // I just know there's an easier way for this, but I can't come up with it and this works so...
1153
+ if( $interval >= (60*60) ) {
1154
+ $numOfMinutes = ($numOfMinutes/60);
1155
+ $identifier = __( 'hours', 'companion-auto-update' );
1156
+ }
1157
+ if( $interval >= (60*60*24) ) {
1158
+ $numOfMinutes = ($numOfMinutes/24);
1159
+ $identifier = __( 'days', 'companion-auto-update' );
1160
+ }
1161
+ if( $interval >= (60*60*24*7) ) {
1162
+ $numOfMinutes = ($numOfMinutes/7);
1163
+ $identifier = __( 'weeks', 'companion-auto-update' );
1164
+ }
1165
+ if( $interval >= (60*60*24*7*(52/12)) ) {
1166
+ $numOfMinutes = ($numOfMinutes/(52/12));
1167
+ $identifier = __( 'months', 'companion-auto-update' );
1168
+ }
1169
+
1170
+ $display = sprintf( esc_html__( 'Every %s %s', 'companion-auto-update' ), round( $numOfMinutes, 2 ), $identifier ); // Translateble
1171
+ $intervalNames[$counter] = $display; // Add the display name (i.e. "Once a month" or "Once Daily")
1172
+
1173
+ $counter++; // Make sure the next interval gets a new "key" value
1174
  }
1175
 
1176
  }
1177
 
1178
  }
1179
 
1180
+ // Sort the interval from smallest to largest
1181
+ asort( $intervalUniques );
1182
+
1183
  // Prevent duplicates
1184
  foreach ( array_unique( $intervalUniques ) as $key => $value ) {
1185
  // $value is the timestamp
1211
  // Plugin information to DB
1212
  function cau_savePluginInformation( $method = 'New' ) {
1213
 
1214
+ // Check if function exists
1215
+ if ( ! function_exists( 'get_plugins' ) ) {
1216
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
1217
+ }
1218
+
1219
+ // Set variables
1220
  global $wpdb;
1221
  $updateDB = "update_log";
1222
  $updateLog = $wpdb->prefix.$updateDB;
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.7.1.1
7
  * Author: Papin Schipper
8
  * Author URI: http://codeermeneer.nl/
9
  * Contributors: papin
@@ -37,12 +37,14 @@ function cau_install( $network_wide ) {
37
  } else {
38
  cau_database_creation();
39
  }
40
- if (! wp_next_scheduled ( 'cau_set_schedule_mail' )) wp_schedule_event( time(), 'daily', 'cau_set_schedule_mail'); // Set schedule for mail etc.
41
  if (! wp_next_scheduled ( 'cau_custom_hooks_plugins' )) wp_schedule_event( time(), 'daily', 'cau_custom_hooks_plugins'); // Run custom hooks on plugin updates
42
  if (! wp_next_scheduled ( 'cau_custom_hooks_themes' )) wp_schedule_event( time(), 'daily', 'cau_custom_hooks_themes'); // Run custom hooks on theme updates
43
  if (! wp_next_scheduled ( 'cau_log_updater' )) wp_schedule_event( ( time() - 1800 ), 'daily', 'cau_log_updater'); // Keep the log up to date
 
44
  }
45
  add_action( 'cau_set_schedule_mail', 'cau_check_updates_mail' );
 
46
  add_action( 'wp_update_plugins', 'cau_run_custom_hooks_p' );
47
  add_action( 'wp_update_themes', 'cau_run_custom_hooks_t' );
48
  add_action( 'wp_version_check', 'cau_run_custom_hooks_c' );
@@ -77,25 +79,28 @@ function cau_donateUrl() {
77
 
78
  // Database version
79
  function cau_db_version() {
80
- return '3.7.0';
81
  }
82
  function cau_database_creation() {
83
 
84
  global $wpdb;
85
 
 
86
  $cau_db_version = cau_db_version();
87
  $autoupdates = $wpdb->prefix."auto_updates";
88
  $updateLog = $wpdb->prefix."update_log";
89
 
90
- // Create db table
 
 
 
91
  $sql = "CREATE TABLE $autoupdates (
92
  id INT(9) NOT NULL AUTO_INCREMENT,
93
  name VARCHAR(255) NOT NULL,
94
  onoroff TEXT NOT NULL,
95
  UNIQUE KEY id (id)
96
- )";
97
 
98
- // Create second db table
99
  $sql2 = "CREATE TABLE $updateLog (
100
  id INT(9) NOT NULL AUTO_INCREMENT,
101
  slug VARCHAR(255) NOT NULL,
@@ -104,8 +109,9 @@ function cau_database_creation() {
104
  method VARCHAR(10) NOT NULL,
105
  put_on_hold VARCHAR(100) DEFAULT '0',
106
  UNIQUE KEY id (id)
107
- )";
108
 
 
109
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
110
  dbDelta( $sql );
111
  dbDelta( $sql2 );
@@ -202,11 +208,28 @@ register_deactivation_hook( __FILE__, 'cau_remove' );
202
 
203
  // Update
204
  function cau_update_db_check() {
 
205
  $cau_db_version = cau_db_version();
 
206
  if ( get_site_option( 'cau_db_version' ) != $cau_db_version ) {
 
207
  cau_database_creation();
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  update_option( "cau_db_version", $cau_db_version );
209
  }
 
210
  }
211
  add_action( 'upgrader_process_complete', 'cau_update_db_check' );
212
 
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.8.0
7
  * Author: Papin Schipper
8
  * Author URI: http://codeermeneer.nl/
9
  * Contributors: papin
37
  } else {
38
  cau_database_creation();
39
  }
40
+ if (! wp_next_scheduled ( 'cau_set_schedule_mail' )) wp_schedule_event( time(), 'daily', 'cau_set_schedule_mail'); // Set schedule for basic notifcations
41
  if (! wp_next_scheduled ( 'cau_custom_hooks_plugins' )) wp_schedule_event( time(), 'daily', 'cau_custom_hooks_plugins'); // Run custom hooks on plugin updates
42
  if (! wp_next_scheduled ( 'cau_custom_hooks_themes' )) wp_schedule_event( time(), 'daily', 'cau_custom_hooks_themes'); // Run custom hooks on theme updates
43
  if (! wp_next_scheduled ( 'cau_log_updater' )) wp_schedule_event( ( time() - 1800 ), 'daily', 'cau_log_updater'); // Keep the log up to date
44
+ if (! wp_next_scheduled ( 'cau_outdated_notifier' )) wp_schedule_event( time(), 'daily', 'cau_outdated_notifier'); // Set schedule for basic notifcations
45
  }
46
  add_action( 'cau_set_schedule_mail', 'cau_check_updates_mail' );
47
+ add_action( 'cau_outdated_notifier', 'cau_outdated_notifier_mail' );
48
  add_action( 'wp_update_plugins', 'cau_run_custom_hooks_p' );
49
  add_action( 'wp_update_themes', 'cau_run_custom_hooks_t' );
50
  add_action( 'wp_version_check', 'cau_run_custom_hooks_c' );
79
 
80
  // Database version
81
  function cau_db_version() {
82
+ return '3.7.2';
83
  }
84
  function cau_database_creation() {
85
 
86
  global $wpdb;
87
 
88
+ // Plugin db info
89
  $cau_db_version = cau_db_version();
90
  $autoupdates = $wpdb->prefix."auto_updates";
91
  $updateLog = $wpdb->prefix."update_log";
92
 
93
+ // WordPress db info
94
+ $charset_collate = $wpdb->get_charset_collate();
95
+
96
+ // DB table creation queries
97
  $sql = "CREATE TABLE $autoupdates (
98
  id INT(9) NOT NULL AUTO_INCREMENT,
99
  name VARCHAR(255) NOT NULL,
100
  onoroff TEXT NOT NULL,
101
  UNIQUE KEY id (id)
102
+ ) $charset_collate;";
103
 
 
104
  $sql2 = "CREATE TABLE $updateLog (
105
  id INT(9) NOT NULL AUTO_INCREMENT,
106
  slug VARCHAR(255) NOT NULL,
109
  method VARCHAR(10) NOT NULL,
110
  put_on_hold VARCHAR(100) DEFAULT '0',
111
  UNIQUE KEY id (id)
112
+ ) $charset_collate;";
113
 
114
+ // Create DB tables
115
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
116
  dbDelta( $sql );
117
  dbDelta( $sql2 );
208
 
209
  // Update
210
  function cau_update_db_check() {
211
+
212
  $cau_db_version = cau_db_version();
213
+
214
  if ( get_site_option( 'cau_db_version' ) != $cau_db_version ) {
215
+
216
  cau_database_creation();
217
+
218
+ // In 3.7.2 we've added $wpdb->get_charset_collate
219
+ if( get_site_option( 'cau_db_version' ) < '3.7.2' ) {
220
+
221
+ global $wpdb;
222
+ $autoupdates = $wpdb->prefix."auto_updates";
223
+ $updateLog = $wpdb->prefix."update_log";
224
+ $db_charset = constant( 'DB_CHARSET' );
225
+ $wpdb->query( "ALTER TABLE $autoupdates CONVERT TO CHARACTER SET $db_charset" );
226
+ $wpdb->query( "ALTER TABLE $updateLog CONVERT TO CHARACTER SET $db_charset" );
227
+
228
+ }
229
+
230
  update_option( "cau_db_version", $cau_db_version );
231
  }
232
+
233
  }
234
  add_action( 'upgrader_process_complete', 'cau_update_db_check' );
235
 
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: auto, automatic, background, update, updates, updating, automatic updates,
5
  Requires at least: 3.6.0
6
  Tested up to: 5.6
7
  Requires PHP: 5.1
8
- Stable tag: 3.7.1.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -81,6 +81,11 @@ So obviously, some of you wondered what the difference would be between the defa
81
 
82
  == Changelog ==
83
 
 
 
 
 
 
84
  = 3.7.1.1 (November 2, 2020) =
85
  * Fix: Type in wp_next_scheduled
86
 
5
  Requires at least: 3.6.0
6
  Tested up to: 5.6
7
  Requires PHP: 5.1
8
+ Stable tag: 3.8.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
81
 
82
  == Changelog ==
83
 
84
+ = 3.8.0 (January 14, 2020) =
85
+ * New: Better handling of plugins with an unknown WP version
86
+ * New: More intervals for notifications
87
+ * Fix: Call to undefined function errors
88
+
89
  = 3.7.1.1 (November 2, 2020) =
90
  * Fix: Type in wp_next_scheduled
91