Companion Auto Update - Version 3.6.0

Version Description

Download this release

Release Info

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

Code changes from version 3.5.5 to 3.6.0

admin/dashboard.php CHANGED
@@ -51,6 +51,12 @@ if( isset( $_POST['submit'] ) ) {
51
  $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'wpemails'", $wpemails ) );
52
  $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'html_or_text'", $html_or_text ) );
53
 
 
 
 
 
 
 
54
  // Intervals
55
 
56
  // Set variables
@@ -430,6 +436,25 @@ $availableIntervals = cau_wp_get_schedules();
430
  </div>
431
  </div>
432
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
433
  <?php wp_nonce_field( 'cau_save_settings' ); ?>
434
  <?php submit_button(); ?>
435
 
51
  $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'wpemails'", $wpemails ) );
52
  $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'html_or_text'", $html_or_text ) );
53
 
54
+ // Advanced
55
+ $allow_editor = $_POST['allow_editor'];
56
+ $allow_author = $_POST['allow_author'];
57
+ $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'allow_editor'", $allow_editor ) );
58
+ $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'allow_author'", $allow_author ) );
59
+
60
  // Intervals
61
 
62
  // Set variables
436
  </div>
437
  </div>
438
 
439
+ <div class="welcome-to-cau advanced-bg welcome-panel cau-dashboard-box">
440
+
441
+ <h2 class="title"><?php _e( 'Advanced settings', 'companion-auto-update' ); ?></h2>
442
+
443
+ <table class="form-table">
444
+ <tbody>
445
+ <tr>
446
+ <th scope="row"><label for="blogname"><?php _e( 'Allow access to:', 'companion-auto-update' ); ?></label></th>
447
+ <td>
448
+ <p><label for="allow_administrator"><input name="allow_administrator" type="checkbox" id="allow_administrator" disabled="" checked=""><?php _e( 'Administrator', '' ); ?></label></p>
449
+ <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>
450
+ <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>
451
+ </td>
452
+ </tr>
453
+ </tbody>
454
+ </table>
455
+
456
+ </div>
457
+
458
  <?php wp_nonce_field( 'cau_save_settings' ); ?>
459
  <?php submit_button(); ?>
460
 
backend/style.css CHANGED
@@ -61,6 +61,9 @@
61
  .welcome-to-cau.interval-bg {
62
  background-image: url('images/interval.svg');
63
  }
 
 
 
64
  .welcome-to-cau h2 {
65
  margin: 0;
66
  margin-bottom: 25px;
@@ -177,10 +180,10 @@ select.schedule_interval {
177
  .support-sidebar-list {
178
  margin-bottom: 25px;
179
  }
180
- .nav-tab {
181
  position: relative;
182
  }
183
- .nav-tab .cau_melding {
184
  display: inline-block;
185
  width: 11px;
186
  height: 11px;
@@ -189,18 +192,18 @@ select.schedule_interval {
189
  position: relative;
190
  bottom: -1px;
191
  }
192
- .nav-tab .cau_melding.level-okay {
193
  background: #7AD03A;
194
  }
195
- .nav-tab .cau_melding.level-low {
196
  background: #FFBA00;
197
  }
198
- .nav-tab .cau_melding.level-high {
199
  background: #FF0000;
200
  }
201
 
202
  /* Table Styling */
203
- .widefat td {
204
  vertical-align: middle!important;
205
  }
206
  table.autoupdate th.head-plugin {
@@ -284,7 +287,7 @@ table.rollbacklist td a.versionselectbutton {
284
  margin: 0!important;
285
  padding: 0!important;
286
  }
287
- #the-list input[type="checkbox"]:not(:checked), #the-list input[type="checkbox"]:checked {
288
  width: 45px;
289
  height: 45px;
290
  position: absolute;
@@ -294,17 +297,17 @@ table.rollbacklist td a.versionselectbutton {
294
  display: block;
295
  opacity: 0;
296
  }
297
- #the-list input[type="checkbox"]:not(:checked) + label, #the-list input[type="checkbox"]:checked + label {
298
  position: absolute;
299
  top: 15px;
300
  left: 12px;
301
  cursor: pointer;
302
  }
303
- #the-list input[type="checkbox"]:not(:checked) + label:before, #the-list input[type="checkbox"]:checked + label:before, #the-list input[type="checkbox"]:not(:checked) + label:after, #the-list input[type="checkbox"]:checked + label:after {
304
  content: '';
305
  position: absolute;
306
  }
307
- #the-list input[type="checkbox"]:not(:checked) + label:before, #the-list input[type="checkbox"]:checked + label:before {
308
  left: 0;
309
  top: -3px;
310
  width: 30px;
@@ -314,7 +317,7 @@ table.rollbacklist td a.versionselectbutton {
314
  border-radius: 15px;
315
  transition: background-color .2s;
316
  }
317
- #the-list input[type="checkbox"]:not(:checked) + label:after, #the-list input[type="checkbox"]:checked + label:after {
318
  width: 8px;
319
  height: 8px;
320
  transition: all .2s;
@@ -324,11 +327,11 @@ table.rollbacklist td a.versionselectbutton {
324
  top: 1px;
325
  left: 5px;
326
  }
327
- #the-list input[type="checkbox"]:not(:checked) + label:before {
328
  background: #9178B7;
329
  border: 2px solid #9178B7;
330
  }
331
- #the-list input[type="checkbox"]:not(:checked) + label:after {
332
  background: #9178B7;
333
  border-color: #FFF;
334
  left: 18px;
@@ -448,14 +451,14 @@ table.rollbacklist td a.versionselectbutton {
448
  box-sizing: border-box;
449
  padding-left: 5px;
450
  }
451
- .nav-tab-wrapper {
452
  position: relative;
453
  top: -20px;
454
  border-bottom: 1px solid #CCC!important;
455
  padding-bottom: 15px!important;
456
  margin-bottom: 0px!important;
457
  }
458
- .nav-tab {
459
  font-size: 12px;
460
  margin: 5px 5px 0 0!important;
461
  box-sizing: border-box;
61
  .welcome-to-cau.interval-bg {
62
  background-image: url('images/interval.svg');
63
  }
64
+ .welcome-to-cau.advanced-bg {
65
+ background-image: url('images/settings.svg');
66
+ }
67
  .welcome-to-cau h2 {
68
  margin: 0;
69
  margin-bottom: 25px;
180
  .support-sidebar-list {
181
  margin-bottom: 25px;
182
  }
183
+ .cau_content .nav-tab {
184
  position: relative;
185
  }
186
+ .cau_content .nav-tab .cau_melding {
187
  display: inline-block;
188
  width: 11px;
189
  height: 11px;
192
  position: relative;
193
  bottom: -1px;
194
  }
195
+ .cau_content .nav-tab .cau_melding.level-okay {
196
  background: #7AD03A;
197
  }
198
+ .cau_content .nav-tab .cau_melding.level-low {
199
  background: #FFBA00;
200
  }
201
+ .cau_content .nav-tab .cau_melding.level-high {
202
  background: #FF0000;
203
  }
204
 
205
  /* Table Styling */
206
+ .cau_content .widefat td {
207
  vertical-align: middle!important;
208
  }
209
  table.autoupdate th.head-plugin {
287
  margin: 0!important;
288
  padding: 0!important;
289
  }
290
+ .cau_content #the-list input[type="checkbox"]:not(:checked), .cau_content #the-list input[type="checkbox"]:checked {
291
  width: 45px;
292
  height: 45px;
293
  position: absolute;
297
  display: block;
298
  opacity: 0;
299
  }
300
+ .cau_content #the-list input[type="checkbox"]:not(:checked) + label, .cau_content #the-list input[type="checkbox"]:checked + label {
301
  position: absolute;
302
  top: 15px;
303
  left: 12px;
304
  cursor: pointer;
305
  }
306
+ .cau_content #the-list input[type="checkbox"]:not(:checked) + label:before, .cau_content #the-list input[type="checkbox"]:checked + label:before, .cau_content #the-list input[type="checkbox"]:not(:checked) + label:after, .cau_content #the-list input[type="checkbox"]:checked + label:after {
307
  content: '';
308
  position: absolute;
309
  }
310
+ .cau_content #the-list input[type="checkbox"]:not(:checked) + label:before, .cau_content #the-list input[type="checkbox"]:checked + label:before {
311
  left: 0;
312
  top: -3px;
313
  width: 30px;
317
  border-radius: 15px;
318
  transition: background-color .2s;
319
  }
320
+ .cau_content #the-list input[type="checkbox"]:not(:checked) + label:after, .cau_content #the-list input[type="checkbox"]:checked + label:after {
321
  width: 8px;
322
  height: 8px;
323
  transition: all .2s;
327
  top: 1px;
328
  left: 5px;
329
  }
330
+ .cau_content #the-list input[type="checkbox"]:not(:checked) + label:before {
331
  background: #9178B7;
332
  border: 2px solid #9178B7;
333
  }
334
+ .cau_content #the-list input[type="checkbox"]:not(:checked) + label:after {
335
  background: #9178B7;
336
  border-color: #FFF;
337
  left: 18px;
451
  box-sizing: border-box;
452
  padding-left: 5px;
453
  }
454
+ .cau_content .nav-tab-wrapper {
455
  position: relative;
456
  top: -20px;
457
  border-bottom: 1px solid #CCC!important;
458
  padding-bottom: 15px!important;
459
  margin-bottom: 0px!important;
460
  }
461
+ .cau_content .nav-tab {
462
  font-size: 12px;
463
  margin: 5px 5px 0 0!important;
464
  box-sizing: border-box;
cau_functions.php CHANGED
@@ -1,5 +1,24 @@
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  // Get database value
4
  function cau_get_db_value( $name, $table = 'auto_updates' ) {
5
 
@@ -239,9 +258,23 @@ function cau_run_custom_hooks_t() {
239
  $lastday = date( 'YmdHi', strtotime( '-1 day' ) );
240
  }
241
 
242
- // Push to array
 
 
 
243
  if( $fileDate >= $lastday ) {
 
 
244
  array_push( $allDates, $fileDate );
 
 
 
 
 
 
 
 
 
245
  }
246
 
247
  }
@@ -258,6 +291,52 @@ function cau_run_custom_hooks_t() {
258
 
259
  }
260
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261
  // Check if automatic updating is disabled globally
262
  function checkAutomaticUpdaterDisabled() {
263
 
@@ -547,8 +626,34 @@ function cau_fetch_log( $limit, $format = 'simple' ) {
547
  array_push( $pluginNames , $themeName );
548
  array_push( $pluginVersion , $themeVersion );
549
 
550
- // Get info from database
551
- array_push( $method , '-' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
552
 
553
  // Get last update date
554
  $fileDate = date( 'YmdHi', filemtime( $fullPath ) );
@@ -655,9 +760,11 @@ function cau_fetch_log( $limit, $format = 'simple' ) {
655
  // CORE
656
  if( $core ) {
657
 
658
- // There is no way (at this time) to check if someone changed this link, so therefore it won't work when it's changed, sorry
659
- $coreFile = get_home_path().'wp-admin/about.php';
 
660
  if( file_exists( $coreFile ) ) {
 
661
  $coreDate = date( 'YmdHi', filemtime( $coreFile ) );
662
 
663
  if( $format == 'table' ) {
@@ -667,6 +774,33 @@ function cau_fetch_log( $limit, $format = 'simple' ) {
667
  $coreDateF = date_i18n( $dateFormat, filemtime( $coreFile ) );
668
  }
669
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
670
  } else {
671
  $coreDate = date('YmdHi');
672
  $coreDateF = 'Could not read core date.';
@@ -680,7 +814,7 @@ function cau_fetch_log( $limit, $format = 'simple' ) {
680
  array_push( $plugslug , '' );
681
 
682
  // Get info from database
683
- array_push( $method , '-' );
684
 
685
  }
686
 
@@ -980,11 +1114,21 @@ function cau_savePluginInformation( $method = 'New' ) {
980
  $updateDB = "update_log";
981
  $updateLog = $wpdb->prefix.$updateDB;
982
  $allPlugins = get_plugins();
 
 
 
 
 
 
983
 
 
984
  foreach ( $allPlugins as $key => $value ) {
985
  if( !cau_check_if_exists( $key, 'slug', $updateDB ) ) $wpdb->insert( $updateLog, array( 'slug' => $key, 'oldVersion' => '-', 'method' => $method ) );
986
  }
987
 
 
 
 
988
  }
989
 
990
  function cau_updatePluginInformation( $slug, $method = '-', $newVersion = '-' ) {
1
  <?php
2
 
3
+ // What user rights can edit plugin settings?
4
+ function cau_allowed_user_rights() {
5
+
6
+ // Current user
7
+ $user = wp_get_current_user();
8
+
9
+ // Allow roles
10
+ $allowed_roles = array( 'administrator' );
11
+ if( cau_get_db_value( 'allow_editor' ) == 'on' ) array_push( $allowed_roles, 'editor' );
12
+ if( cau_get_db_value( 'allow_author' ) == 'on' ) array_push( $allowed_roles, 'author' );
13
+
14
+ // Check
15
+ if ( array_intersect( $allowed_roles, $user->roles ) ) {
16
+ return true;
17
+ } else {
18
+ return false;
19
+ }
20
+ }
21
+
22
  // Get database value
23
  function cau_get_db_value( $name, $table = 'auto_updates' ) {
24
 
258
  $lastday = date( 'YmdHi', strtotime( '-1 day' ) );
259
  }
260
 
261
+ $update_time = wp_next_scheduled( 'wp_update_themes' );
262
+ $range_start = date( 'Hi', strtotime( '-30 minutes', $update_time ) );
263
+ $range_end = date( 'Hi', strtotime( '+30 minutes', $update_time ) );
264
+
265
  if( $fileDate >= $lastday ) {
266
+
267
+ // Push to array
268
  array_push( $allDates, $fileDate );
269
+
270
+ // Update info
271
+ if( $fileTime > $range_start && $fileTime < $range_end ) {
272
+ $status = __( 'Automatic', 'companion-auto-update' );
273
+ } else {
274
+ $status = __( 'Manual', 'companion-auto-update' );
275
+ }
276
+ cau_updatePluginInformation( $key, $status );
277
+
278
  }
279
 
280
  }
291
 
292
  }
293
 
294
+ // Run custom hooks on core update
295
+ function cau_run_custom_hooks_c() {
296
+
297
+ // Create array
298
+ $totalNum = 0;
299
+
300
+ // Get data
301
+ $fullPath = ABSPATH.'wp-includes/version.php';
302
+ $fileDate = date ( 'YmdHi', filemtime( $fullPath ) );
303
+ $updateSched = wp_get_schedule( 'wp_version_check' );
304
+
305
+ // Check when the last update was
306
+ if( $updateSched == 'hourly' ) {
307
+ $lastday = date( 'YmdHi', strtotime( '-1 hour' ) );
308
+ } elseif( $updateSched == 'twicedaily' ) {
309
+ $lastday = date( 'YmdHi', strtotime( '-12 hours' ) );
310
+ } elseif( $updateSched == 'daily' ) {
311
+ $lastday = date( 'YmdHi', strtotime( '-1 day' ) );
312
+ }
313
+
314
+ // Check manual or automatic
315
+ $update_time = wp_next_scheduled( 'wp_version_check' );
316
+ $range_start = date( 'Hi', strtotime( '-30 minutes', $update_time ) );
317
+ $range_end = date( 'Hi', strtotime( '+30 minutes', $update_time ) );
318
+
319
+ if( $fileDate >= $lastday ) {
320
+
321
+ // Update info
322
+ if( $fileTime > $range_start && $fileTime < $range_end ) {
323
+ $status = __( 'Automatic', 'companion-auto-update' );
324
+ } else {
325
+ $status = __( 'Manual', 'companion-auto-update' );
326
+ }
327
+ cau_updatePluginInformation( 'core', $status );
328
+
329
+ $totalNum++;
330
+
331
+ }
332
+
333
+ // If there have been plugin updates run hook
334
+ if( $totalNum > 0 ) {
335
+ do_action( 'cau_after_core_update' );
336
+ }
337
+
338
+ }
339
+
340
  // Check if automatic updating is disabled globally
341
  function checkAutomaticUpdaterDisabled() {
342
 
626
  array_push( $pluginNames , $themeName );
627
  array_push( $pluginVersion , $themeVersion );
628
 
629
+ // Automatic or Manual (non-db-version)
630
+ $date_tod = date ( 'ydm' );
631
+ $fileDay = date ( 'ydm', filemtime( $fullPath ) );
632
+ $fileTime = date ( 'Hi', filemtime( $fullPath ) );
633
+ $updateSched = wp_next_scheduled( 'wp_update_themes' );
634
+ $range_start = date( 'Hi', strtotime( '-30 minutes', $updateSched ) );
635
+ $range_end = date( 'Hi', strtotime( '+30 minutes', $updateSched ) );
636
+
637
+ if( $date_tod == $fileDay ) {
638
+
639
+ if( $fileTime > $range_start && $fileTime < $range_end ) {
640
+ $status = __( 'Automatic', 'companion-auto-update' );
641
+ } else {
642
+ $status = __( 'Manual', 'companion-auto-update' );
643
+ }
644
+
645
+ array_push( $method , $status );
646
+
647
+ } else {
648
+
649
+ // Get info from database
650
+ if( cau_check_if_exists( $key, 'slug', $updateLog ) ) {
651
+ array_push( $method , cau_get_plugininfo( $key, 'method' ) );
652
+ } else {
653
+ array_push( $method , '-' );
654
+ }
655
+
656
+ }
657
 
658
  // Get last update date
659
  $fileDate = date( 'YmdHi', filemtime( $fullPath ) );
760
  // CORE
761
  if( $core ) {
762
 
763
+ $coreFile = ABSPATH.'wp-includes/version.php';
764
+ $updateSched = wp_get_schedule( 'wp_version_check' );
765
+
766
  if( file_exists( $coreFile ) ) {
767
+
768
  $coreDate = date( 'YmdHi', filemtime( $coreFile ) );
769
 
770
  if( $format == 'table' ) {
774
  $coreDateF = date_i18n( $dateFormat, filemtime( $coreFile ) );
775
  }
776
 
777
+ // Automatic or Manual (non-db-version)
778
+ $date_tod = date ( 'ydm' );
779
+ $fileDay = date ( 'ydm', filemtime( $coreFile ) );
780
+ $fileTime = date ( 'Hi', filemtime( $coreFile ) );
781
+ $range_start = date( 'Hi', strtotime( '-30 minutes', $updateSched ) );
782
+ $range_end = date( 'Hi', strtotime( '+30 minutes', $updateSched ) );
783
+
784
+ if( $date_tod == $fileDay ) {
785
+
786
+ if( $fileTime > $range_start && $fileTime < $range_end ) {
787
+ $methodVal = __( 'Automatic', 'companion-auto-update' );
788
+ } else {
789
+ $methodVal = __( 'Manual', 'companion-auto-update' );
790
+ }
791
+
792
+ } else {
793
+
794
+ // Get info from database
795
+ if( cau_check_if_exists( $key, 'slug', $updateLog ) ) {
796
+ $methodVal = cau_get_plugininfo( 'core', 'method' );
797
+ } else {
798
+ $methodVal = '';
799
+ }
800
+
801
+ }
802
+
803
+
804
  } else {
805
  $coreDate = date('YmdHi');
806
  $coreDateF = 'Could not read core date.';
814
  array_push( $plugslug , '' );
815
 
816
  // Get info from database
817
+ array_push( $method , $methodVal );
818
 
819
  }
820
 
1114
  $updateDB = "update_log";
1115
  $updateLog = $wpdb->prefix.$updateDB;
1116
  $allPlugins = get_plugins();
1117
+ $allThemes = wp_get_themes();
1118
+
1119
+ // Loop trough all themes
1120
+ foreach ( $allThemes as $key => $value ) {
1121
+ if( !cau_check_if_exists( $key, 'slug', $updateDB ) ) $wpdb->insert( $updateLog, array( 'slug' => $key, 'oldVersion' => '-', 'method' => $method ) );
1122
+ }
1123
 
1124
+ // Loop trough all plugins
1125
  foreach ( $allPlugins as $key => $value ) {
1126
  if( !cau_check_if_exists( $key, 'slug', $updateDB ) ) $wpdb->insert( $updateLog, array( 'slug' => $key, 'oldVersion' => '-', 'method' => $method ) );
1127
  }
1128
 
1129
+ // Core
1130
+ if( !cau_check_if_exists( 'core', 'slug', $updateDB ) ) $wpdb->insert( $updateLog, array( 'slug' => 'core', 'oldVersion' => '-', 'method' => $method ) );
1131
+
1132
  }
1133
 
1134
  function cau_updatePluginInformation( $slug, $method = '-', $newVersion = '-' ) {
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.5.5
7
  * Author: Papin Schipper
8
  * Author URI: http://codeermeneer.nl/
9
  * Contributors: papin
@@ -17,10 +17,12 @@
17
  defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
18
 
19
  // Load translations
20
- function cau_load_translations() {
21
  load_plugin_textdomain( 'companion-auto-update', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
 
 
22
  }
23
- add_action( 'init', 'cau_load_translations' );
24
 
25
  // Set up the database and required schedules
26
  function cau_install( $network_wide ) {
@@ -41,7 +43,8 @@ function cau_install( $network_wide ) {
41
  }
42
  add_action( 'cau_set_schedule_mail', 'cau_check_updates_mail' );
43
  add_action( 'wp_update_plugins', 'cau_run_custom_hooks_p' );
44
- add_action( 'cau_custom_hooks_themes', 'cau_run_custom_hooks_t' );
 
45
 
46
  // Redirect to welcome screen on activation of plugin
47
  function cau_pluginActivateWelcome() {
@@ -66,7 +69,7 @@ function cau_donateUrl() {
66
 
67
  // Database version
68
  function cau_db_version() {
69
- return '3.5.3';
70
  }
71
  function cau_database_creation() {
72
 
@@ -150,6 +153,11 @@ function cau_install_data() {
150
  // Stuff
151
  if( !cau_check_if_exists( 'html_or_text' ) ) $wpdb->insert( $table_name, array( 'name' => 'html_or_text', 'onoroff' => 'html' ) ); // 11
152
 
 
 
 
 
 
153
 
154
  }
155
  register_activation_hook( __FILE__, 'cau_install' );
@@ -185,7 +193,7 @@ require_once( plugin_dir_path( __FILE__ ) . 'cau_functions.php' );
185
 
186
  // Add plugin to menu
187
  function register_cau_menu_page() {
188
- add_submenu_page( cau_menloc() , __( 'Auto Updater', 'companion-auto-update' ), __( 'Auto Updater', 'companion-auto-update' ), 'manage_options', 'cau-settings', 'cau_frontend' );
189
  }
190
  add_action( 'admin_menu', 'register_cau_menu_page' );
191
 
@@ -248,7 +256,7 @@ function cau_frontend() { ?>
248
 
249
  // Add a widget to the dashboard.
250
  function cau_add_widget() {
251
- if ( current_user_can( 'manage_options' ) ) wp_add_dashboard_widget( 'cau-update-log', __('Update log', 'companion-auto-update'), 'cau_widget' );
252
  }
253
  add_action( 'wp_dashboard_setup', 'cau_add_widget' );
254
 
@@ -266,24 +274,30 @@ function cau_widget() {
266
  }
267
 
268
  // Load admin styles
269
- function load_cau_sytyles( $hook ) {
270
-
271
- // Only load on plugins' pages
272
- if( $hook != 'tools_page_cau-settings' && $hook != 'index_page_cau-settings' ) return;
273
 
274
  // Plugin scripts
275
  wp_enqueue_style( 'cau_admin_styles', plugins_url( 'backend/style.css' , __FILE__ ) );
276
 
 
 
 
 
 
 
 
 
 
 
 
 
277
  // WordPress scripts we need
278
  wp_enqueue_style( 'thickbox' );
279
  wp_enqueue_script( 'thickbox' );
280
  wp_enqueue_script( 'plugin-install' );
281
 
282
- // Check for issues
283
- wp_enqueue_style( 'cau_warning_styles', plugins_url( 'backend/warningbar.css' , __FILE__ ) );
284
-
285
  }
286
- add_action( 'admin_enqueue_scripts', 'load_cau_sytyles', 100 );
287
 
288
  // Send e-mails
289
  require_once( plugin_dir_path( __FILE__ ) . 'cau_emails.php' );
@@ -291,13 +305,14 @@ require_once( plugin_dir_path( __FILE__ ) . 'cau_emails.php' );
291
  // Add settings link on plugin page
292
  function cau_settings_link( $links ) {
293
 
 
294
  $settings_link = '<a href="'.cau_url( 'dashboard' ).'">'.__( 'Settings' ).'</a>';
295
  $settings_link2 = '<a href="https://translate.wordpress.org/projects/wp-plugins/companion-auto-update">'.__( 'Help us translate', 'companion-auto-update' ).'</a>';
296
  $settings_link3 = '<a href="'.cau_donateUrl().'">'.__( 'Donate to help development', 'companion-auto-update' ).'</a>';
297
 
298
  array_unshift( $links, $settings_link2 );
299
  array_unshift( $links, $settings_link3 );
300
- array_unshift( $links, $settings_link );
301
 
302
  return $links;
303
 
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.6.0
7
  * Author: Papin Schipper
8
  * Author URI: http://codeermeneer.nl/
9
  * Contributors: papin
17
  defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
18
 
19
  // Load translations
20
+ function cau_init() {
21
  load_plugin_textdomain( 'companion-auto-update', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
22
+ add_filter( 'plugins_auto_update_enabled', '__return_false' );
23
+ add_filter( 'themes_auto_update_enabled', '__return_false' );
24
  }
25
+ add_action( 'init', 'cau_init' );
26
 
27
  // Set up the database and required schedules
28
  function cau_install( $network_wide ) {
43
  }
44
  add_action( 'cau_set_schedule_mail', 'cau_check_updates_mail' );
45
  add_action( 'wp_update_plugins', 'cau_run_custom_hooks_p' );
46
+ add_action( 'wp_update_themes', 'cau_run_custom_hooks_t' );
47
+ add_action( 'wp_version_check', 'cau_run_custom_hooks_c' );
48
 
49
  // Redirect to welcome screen on activation of plugin
50
  function cau_pluginActivateWelcome() {
69
 
70
  // Database version
71
  function cau_db_version() {
72
+ return '3.6.0';
73
  }
74
  function cau_database_creation() {
75
 
153
  // Stuff
154
  if( !cau_check_if_exists( 'html_or_text' ) ) $wpdb->insert( $table_name, array( 'name' => 'html_or_text', 'onoroff' => 'html' ) ); // 11
155
 
156
+ // Advanced
157
+ if( !cau_check_if_exists( 'allow_administrator' ) ) $wpdb->insert( $table_name, array( 'name' => 'allow_administrator', 'onoroff' => 'on' ) ); // 12
158
+ if( !cau_check_if_exists( 'allow_editor' ) ) $wpdb->insert( $table_name, array( 'name' => 'allow_editor', 'onoroff' => '' ) ); // 13
159
+ if( !cau_check_if_exists( 'allow_author' ) ) $wpdb->insert( $table_name, array( 'name' => 'allow_author', 'onoroff' => '' ) ); // 14
160
+
161
 
162
  }
163
  register_activation_hook( __FILE__, 'cau_install' );
193
 
194
  // Add plugin to menu
195
  function register_cau_menu_page() {
196
+ if( cau_allowed_user_rights() ) add_submenu_page( cau_menloc() , __( 'Auto Updater', 'companion-auto-update' ), __( 'Auto Updater', 'companion-auto-update' ), 'manage_options', 'cau-settings', 'cau_frontend' );
197
  }
198
  add_action( 'admin_menu', 'register_cau_menu_page' );
199
 
256
 
257
  // Add a widget to the dashboard.
258
  function cau_add_widget() {
259
+ if ( cau_allowed_user_rights() ) wp_add_dashboard_widget( 'cau-update-log', __('Update log', 'companion-auto-update'), 'cau_widget' );
260
  }
261
  add_action( 'wp_dashboard_setup', 'cau_add_widget' );
262
 
274
  }
275
 
276
  // Load admin styles
277
+ function load_cau_global_styles( $hook ) {
 
 
 
278
 
279
  // Plugin scripts
280
  wp_enqueue_style( 'cau_admin_styles', plugins_url( 'backend/style.css' , __FILE__ ) );
281
 
282
+ // Check for issues
283
+ wp_enqueue_style( 'cau_warning_styles', plugins_url( 'backend/warningbar.css' , __FILE__ ) );
284
+
285
+ }
286
+ add_action( 'admin_enqueue_scripts', 'load_cau_global_styles', 99 );
287
+
288
+ // Load admin styles
289
+ function load_cau_page_styles( $hook ) {
290
+
291
+ // Only load on plugins' pages
292
+ if( $hook != 'tools_page_cau-settings' && $hook != 'index_page_cau-settings' ) return;
293
+
294
  // WordPress scripts we need
295
  wp_enqueue_style( 'thickbox' );
296
  wp_enqueue_script( 'thickbox' );
297
  wp_enqueue_script( 'plugin-install' );
298
 
 
 
 
299
  }
300
+ add_action( 'admin_enqueue_scripts', 'load_cau_page_styles', 100 );
301
 
302
  // Send e-mails
303
  require_once( plugin_dir_path( __FILE__ ) . 'cau_emails.php' );
305
  // Add settings link on plugin page
306
  function cau_settings_link( $links ) {
307
 
308
+
309
  $settings_link = '<a href="'.cau_url( 'dashboard' ).'">'.__( 'Settings' ).'</a>';
310
  $settings_link2 = '<a href="https://translate.wordpress.org/projects/wp-plugins/companion-auto-update">'.__( 'Help us translate', 'companion-auto-update' ).'</a>';
311
  $settings_link3 = '<a href="'.cau_donateUrl().'">'.__( 'Donate to help development', 'companion-auto-update' ).'</a>';
312
 
313
  array_unshift( $links, $settings_link2 );
314
  array_unshift( $links, $settings_link3 );
315
+ if( cau_allowed_user_rights() ) array_unshift( $links, $settings_link );
316
 
317
  return $links;
318
 
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.5
7
  Requires PHP: 5.1
8
- Stable tag: 3.5.5
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -68,6 +68,12 @@ Your feedback is what made this plugin what is and what it’ll become so keep t
68
 
69
  == Changelog ==
70
 
 
 
 
 
 
 
71
  = 3.5.5 (August 5, 2020) =
72
  * Fix: Added better multisite support
73
  * Better status log: We've added a bunch more checks and you can now see more passed checks.
5
  Requires at least: 3.6.0
6
  Tested up to: 5.5
7
  Requires PHP: 5.1
8
+ Stable tag: 3.6.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
68
 
69
  == Changelog ==
70
 
71
+ = 3.6 (August 12, 2020) =
72
+ * Tweak: Added Theme and Core update method the log
73
+ * Tweak: Few WordPress 5.5 improvements
74
+ * New: Added an "after core update" hook [More info](https://codeermeneer.nl/documentation/codex-auto-updater/)
75
+ * New: Select which userroles can access settings. (Defaults to only administrators)
76
+
77
  = 3.5.5 (August 5, 2020) =
78
  * Fix: Added better multisite support
79
  * Better status log: We've added a bunch more checks and you can now see more passed checks.