Companion Auto Update - Version 3.3.0

Version Description

(November 5, 2018) = * New: Custom hooks afer succesfull update, How to use custom hooks in Companion Auto Update

Download this release

Release Info

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

Code changes from version 3.2.5 to 3.3.0

admin/schedule.php CHANGED
@@ -4,6 +4,8 @@ $plugin_schedule = wp_get_schedule( 'wp_update_plugins' );
4
  $theme_schedule = wp_get_schedule( 'wp_update_themes' );
5
  $core_schedule = wp_get_schedule( 'wp_version_check' );
6
  $mail_sc = wp_get_schedule( 'cau_set_schedule_mail' );
 
 
7
 
8
  if( isset( $_POST['submit'] ) ) {
9
 
@@ -21,6 +23,8 @@ if( isset( $_POST['submit'] ) ) {
21
  wp_clear_scheduled_hook('wp_update_themes');
22
  wp_clear_scheduled_hook('wp_version_check');
23
  wp_clear_scheduled_hook('cau_set_schedule_mail');
 
 
24
 
25
  // Then set the new times
26
  if( $plugin_sc == 'daily' ) {
@@ -33,10 +37,12 @@ if( isset( $_POST['submit'] ) ) {
33
  $pluginSetTime = strtotime( $fullDate );
34
 
35
  wp_schedule_event( $pluginSetTime, $plugin_sc, 'wp_update_plugins' );
 
36
 
37
  } else {
38
 
39
  wp_schedule_event( time(), $plugin_sc, 'wp_update_plugins' );
 
40
 
41
  }
42
  if( $theme_sc == 'daily' ) {
@@ -49,10 +55,12 @@ if( isset( $_POST['submit'] ) ) {
49
  $themeSetTime = strtotime( $fullDateT );
50
 
51
  wp_schedule_event( $themeSetTime, $theme_sc, 'wp_update_themes' );
 
52
 
53
  } else {
54
 
55
  wp_schedule_event( time(), $theme_sc, 'wp_update_themes' );
 
56
 
57
  }
58
 
4
  $theme_schedule = wp_get_schedule( 'wp_update_themes' );
5
  $core_schedule = wp_get_schedule( 'wp_version_check' );
6
  $mail_sc = wp_get_schedule( 'cau_set_schedule_mail' );
7
+ $cs_hooks_p = wp_get_schedule( 'cau_custom_hooks_plugins' );
8
+ $cs_hooks_t = wp_get_schedule( 'cau_custom_hooks_themes' );
9
 
10
  if( isset( $_POST['submit'] ) ) {
11
 
23
  wp_clear_scheduled_hook('wp_update_themes');
24
  wp_clear_scheduled_hook('wp_version_check');
25
  wp_clear_scheduled_hook('cau_set_schedule_mail');
26
+ wp_clear_scheduled_hook('cau_custom_hooks_plugins');
27
+ wp_clear_scheduled_hook('cau_custom_hooks_themes');
28
 
29
  // Then set the new times
30
  if( $plugin_sc == 'daily' ) {
37
  $pluginSetTime = strtotime( $fullDate );
38
 
39
  wp_schedule_event( $pluginSetTime, $plugin_sc, 'wp_update_plugins' );
40
+ wp_schedule_event( $pluginSetTime, $plugin_sc, 'cau_custom_hooks_plugins' );
41
 
42
  } else {
43
 
44
  wp_schedule_event( time(), $plugin_sc, 'wp_update_plugins' );
45
+ wp_schedule_event( time(), $plugin_sc, 'cau_custom_hooks_plugins' );
46
 
47
  }
48
  if( $theme_sc == 'daily' ) {
55
  $themeSetTime = strtotime( $fullDateT );
56
 
57
  wp_schedule_event( $themeSetTime, $theme_sc, 'wp_update_themes' );
58
+ wp_schedule_event( $themeSetTime, $theme_sc, 'cau_custom_hooks_themes' );
59
 
60
  } else {
61
 
62
  wp_schedule_event( time(), $theme_sc, 'wp_update_themes' );
63
+ wp_schedule_event( time(), $theme_sc, 'cau_custom_hooks_themes' );
64
 
65
  }
66
 
admin/support.php CHANGED
@@ -1,6 +1,6 @@
1
 
2
  <h2 class="title"><?php _e('Support', 'companion-auto-update');?></h2>
3
- <?php _e('Feel free to reach out to me if you have any questions or feedback.', 'companion-auto-update'); ?>
4
 
5
 
6
  <table class="form-table cau_support">
@@ -32,9 +32,15 @@
32
  </td>
33
  </tr>
34
  <tr>
35
- <th scope="row"><?php _e('Check out my other plugins', 'companion-auto-update');?></th>
36
  <td>
37
- <a href="https://codeermeneer.nl/plugins/" target="_blank" class="button"><span class="dashicons dashicons-category"></span> <?php _e('View my portfolio', 'companion-auto-update'); ?></a>
 
 
 
 
 
 
38
  </td>
39
  </tr>
40
 
1
 
2
  <h2 class="title"><?php _e('Support', 'companion-auto-update');?></h2>
3
+ <?php _e('Feel free to reach out to us if you have any questions or feedback.', 'companion-auto-update'); ?>
4
 
5
 
6
  <table class="form-table cau_support">
32
  </td>
33
  </tr>
34
  <tr>
35
+ <th scope="row"><?php _e('Check out our other plugins', 'companion-auto-update');?></th>
36
  <td>
37
+ <a href="https://codeermeneer.nl/plugins/" target="_blank" class="button"><span class="dashicons dashicons-category"></span> <?php _e('View portfolio', 'companion-auto-update'); ?></a>
38
+ </td>
39
+ </tr>
40
+ <tr>
41
+ <th scope="row"><?php _e('Developer?', 'companion-auto-update');?></th>
42
+ <td>
43
+ <a href="https://codeermeneer.nl/stuffs/codex-auto-updater/" target="_blank" class="button"><span class="dashicons dashicons-media-code"></span> <?php _e('Check out our codex', 'companion-auto-update'); ?></a>
44
  </td>
45
  </tr>
46
 
cau_functions.php CHANGED
@@ -1,13 +1,106 @@
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  function checkAutomaticUpdaterDisabled() {
4
 
5
  if ( defined( 'automatic_updater_disabled' ) OR defined( 'AUTOMATIC_UPDATER_DISABLED' ) ) {
6
  if( doing_filter( 'AUTOMATIC_UPDATER_DISABLED' ) ) {
7
  return true;
8
- } elseif( automatic_updater_disabled == 'true' OR AUTOMATIC_UPDATER_DISABLED == 'true' ) {
9
  return true;
10
- } elseif( automatic_updater_disabled == 'minor' OR AUTOMATIC_UPDATER_DISABLED == 'minor' ) {
11
  return true;
12
  } else {
13
  return false;
@@ -18,12 +111,12 @@ function checkAutomaticUpdaterDisabled() {
18
 
19
  }
20
 
 
21
  function cau_menloc() {
22
-
23
  return 'tools.php';
24
-
25
  }
26
 
 
27
  function active_tab( $page, $identifier = 'tab' ) {
28
 
29
  if( !isset( $_GET[ $identifier ] ) ) {
@@ -38,6 +131,7 @@ function active_tab( $page, $identifier = 'tab' ) {
38
 
39
  }
40
 
 
41
  function active_subtab( $page, $identifier = 'tab' ) {
42
 
43
  if( !isset( $_GET[ $identifier ] ) ) {
1
  <?php
2
 
3
+ // Run custom hooks on plugin update
4
+ function cau_run_custom_hooks_p() {
5
+
6
+ // Create array
7
+ $allDates = array();
8
+
9
+ // Where to look for plugins
10
+ $dirr = plugin_dir_path( __DIR__ );
11
+ $listOfAll = get_plugins();
12
+
13
+ // Loop trough all plugins
14
+ foreach ( $listOfAll as $key => $value) {
15
+
16
+ // Get data
17
+ $fullPath = $dirr.'/'.$key;
18
+ $fileDate = date ( 'YmdHi', filemtime( $fullPath ) );
19
+ $updateSched = wp_get_schedule( 'wp_update_plugins' );
20
+
21
+ // Check when the last update was
22
+ if( $updateSched == 'hourly' ) {
23
+ $lastday = date( 'YmdHi', strtotime( '-1 hour' ) );
24
+ } elseif( $updateSched == 'twicedaily' ) {
25
+ $lastday = date( 'YmdHi', strtotime( '-12 hours' ) );
26
+ } elseif( $updateSched == 'daily' ) {
27
+ $lastday = date( 'YmdHi', strtotime( '-1 day' ) );
28
+ }
29
+
30
+ // Push to array
31
+ if( $fileDate >= $lastday ) {
32
+ array_push( $allDates, $fileDate );
33
+ }
34
+
35
+ }
36
+
37
+ $totalNum = 0;
38
+
39
+ // Count number of updated plugins
40
+ foreach ( $allDates as $key => $value ) $totalNum++;
41
+
42
+ // If there have been plugin updates run hook
43
+ if( $totalNum > 0 ) {
44
+ do_action( 'cau_after_plugin_update' );
45
+ }
46
+
47
+ }
48
+
49
+ // Run custom hooks on theme update
50
+ function cau_run_custom_hooks_t() {
51
+
52
+ // Create array
53
+ $allDates = array();
54
+
55
+ // Where to look for plugins
56
+ $dirr = get_theme_root();
57
+ $listOfAll = wp_get_themes();
58
+
59
+ // Loop trough all plugins
60
+ foreach ( $listOfAll as $key => $value) {
61
+
62
+ // Get data
63
+ $fullPath = $dirr.'/'.$key;
64
+ $fileDate = date ( 'YmdHi', filemtime( $fullPath ) );
65
+ $updateSched = wp_get_schedule( 'wp_update_themes' );
66
+
67
+ // Check when the last update was
68
+ if( $updateSched == 'hourly' ) {
69
+ $lastday = date( 'YmdHi', strtotime( '-1 hour' ) );
70
+ } elseif( $updateSched == 'twicedaily' ) {
71
+ $lastday = date( 'YmdHi', strtotime( '-12 hours' ) );
72
+ } elseif( $updateSched == 'daily' ) {
73
+ $lastday = date( 'YmdHi', strtotime( '-1 day' ) );
74
+ }
75
+
76
+ // Push to array
77
+ if( $fileDate >= $lastday ) {
78
+ array_push( $allDates, $fileDate );
79
+ }
80
+
81
+ }
82
+
83
+ $totalNum = 0;
84
+
85
+ // Count number of updated plugins
86
+ foreach ( $allDates as $key => $value ) $totalNum++;
87
+
88
+ // If there have been plugin updates run hook
89
+ if( $totalNum > 0 ) {
90
+ do_action( 'cau_after_theme_update' );
91
+ }
92
+
93
+ }
94
+
95
+ // Check if automatic updating is disabled globally
96
  function checkAutomaticUpdaterDisabled() {
97
 
98
  if ( defined( 'automatic_updater_disabled' ) OR defined( 'AUTOMATIC_UPDATER_DISABLED' ) ) {
99
  if( doing_filter( 'AUTOMATIC_UPDATER_DISABLED' ) ) {
100
  return true;
101
+ } elseif( constant('automatic_updater_disabled') == 'true' OR constant('AUTOMATIC_UPDATER_DISABLED') == 'true' ) {
102
  return true;
103
+ } elseif( constant('automatic_updater_disabled') == 'minor' OR constant('AUTOMATIC_UPDATER_DISABLED') == 'minor' ) {
104
  return true;
105
  } else {
106
  return false;
111
 
112
  }
113
 
114
+ // Menu location
115
  function cau_menloc() {
 
116
  return 'tools.php';
 
117
  }
118
 
119
+ // Get the active tab
120
  function active_tab( $page, $identifier = 'tab' ) {
121
 
122
  if( !isset( $_GET[ $identifier ] ) ) {
131
 
132
  }
133
 
134
+ // Get the active subtab
135
  function active_subtab( $page, $identifier = 'tab' ) {
136
 
137
  if( !isset( $_GET[ $identifier ] ) ) {
companion-auto-update-check-updates.php DELETED
@@ -1,6 +0,0 @@
1
- <?php
2
-
3
- // Deprecated file as of version 3.0. Will be removed in a future update.
4
- require_once( 'cau_emails.php' ); // Fallback
5
-
6
- ?>
 
 
 
 
 
 
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.2.5
7
  * Author: Papin Schipper
8
  * Author URI: http://codeermeneer.nl/
9
  * Contributors: papin
@@ -22,13 +22,18 @@ function cau_load_translations() {
22
  }
23
  add_action( 'init', 'cau_load_translations' );
24
 
25
- // Install db
26
  function cau_install() {
27
  cau_database_creation(); // Db handle
28
- if (! wp_next_scheduled ( 'cau_set_schedule_mail' )) wp_schedule_event( time(), 'daily', 'cau_set_schedule_mail'); //Set schedule
 
 
29
  }
30
  add_action('cau_set_schedule_mail', 'cau_check_updates_mail');
 
 
31
 
 
32
  function cau_database_creation() {
33
 
34
  global $wpdb;
@@ -78,7 +83,7 @@ function cau_check_if_exists( $whattocheck ) {
78
 
79
  }
80
 
81
- // Inset Data
82
  function cau_install_data() {
83
 
84
  global $wpdb;
@@ -104,7 +109,7 @@ function cau_install_data() {
104
  }
105
  register_activation_hook( __FILE__, 'cau_install' );
106
 
107
- // Clear everything
108
  function cau_remove() {
109
  global $wpdb;
110
  $table_name = $wpdb->prefix . "auto_updates";
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.0
7
  * Author: Papin Schipper
8
  * Author URI: http://codeermeneer.nl/
9
  * Contributors: papin
22
  }
23
  add_action( 'init', 'cau_load_translations' );
24
 
25
+ // Set up the database and required schedules
26
  function cau_install() {
27
  cau_database_creation(); // Db handle
28
+ if (! wp_next_scheduled ( 'cau_set_schedule_mail' )) wp_schedule_event( time(), 'daily', 'cau_set_schedule_mail'); // Set schedule for mail etc.
29
+ if (! wp_next_scheduled ( 'cau_custom_hooks_plugins' )) wp_schedule_event( time(), 'daily', 'cau_custom_hooks_plugins'); // Run custom hooks on plugin updates
30
+ if (! wp_next_scheduled ( 'cau_custom_hooks_themes' )) wp_schedule_event( time(), 'daily', 'cau_custom_hooks_themes'); // Run custom hooks on theme updates
31
  }
32
  add_action('cau_set_schedule_mail', 'cau_check_updates_mail');
33
+ add_action('cau_custom_hooks_plugins', 'cau_run_custom_hooks_p');
34
+ add_action('cau_custom_hooks_themes', 'cau_run_custom_hooks_t');
35
 
36
+ // Create database
37
  function cau_database_creation() {
38
 
39
  global $wpdb;
83
 
84
  }
85
 
86
+ // Insert date into database
87
  function cau_install_data() {
88
 
89
  global $wpdb;
109
  }
110
  register_activation_hook( __FILE__, 'cau_install' );
111
 
112
+ // Clear everything on deactivation
113
  function cau_remove() {
114
  global $wpdb;
115
  $table_name = $wpdb->prefix . "auto_updates";
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.me/dakel/2
4
  Tags: auto, automatic, background, update, updates, updating, automatic updates, automatic background updates, easy update, wordpress update, theme update, plugin update, up-to-date, security, update latest version, update core, update wp, update wp core, major updates, minor updates, update to new version, update core, update plugin, update plugins, update plugins automatically, update theme, plugin, theme, advance, control, mail, notifations, enable
5
  Requires at least: 3.5.0
6
  Tested up to: 5.0
7
- Stable tag: 3.2.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -71,6 +71,9 @@ For some reason this plugin seems to have trouble with updating themes by Elegan
71
 
72
  == Changelog ==
73
 
 
 
 
74
  = 3.2.5 (October 26, 2018) =
75
  * Improvement: Few minor tweaks to the critical error messages
76
 
@@ -81,7 +84,7 @@ For some reason this plugin seems to have trouble with updating themes by Elegan
81
  * Improved: New error notification when plugins runs into a critical error
82
 
83
  = 3.2.2 (October 5, 2018) =
84
- * Fix: Parse error: syntax error, unexpected [ in cau_functions.php on line 247
85
 
86
  = 3.2.1 ( October 2, 2018) =
87
  * Fix: Cross-site request forgery (CSRF)/local file inclusion (LFI) vulnerability.
4
  Tags: auto, automatic, background, update, updates, updating, automatic updates, automatic background updates, easy update, wordpress update, theme update, plugin update, up-to-date, security, update latest version, update core, update wp, update wp core, major updates, minor updates, update to new version, update core, update plugin, update plugins, update plugins automatically, update theme, plugin, theme, advance, control, mail, notifations, enable
5
  Requires at least: 3.5.0
6
  Tested up to: 5.0
7
+ Stable tag: 3.3.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
71
 
72
  == Changelog ==
73
 
74
+ = 3.3.0 (November 5, 2018) =
75
+ * New: Custom hooks afer succesfull update, [How to use custom hooks in Companion Auto Update](https://codeermeneer.nl/stuffs/codex-auto-updater/)
76
+
77
  = 3.2.5 (October 26, 2018) =
78
  * Improvement: Few minor tweaks to the critical error messages
79
 
84
  * Improved: New error notification when plugins runs into a critical error
85
 
86
  = 3.2.2 (October 5, 2018) =
87
+ * Fix: Parse error: syntax error, unexpected [ in cau_functions.php on line 247
88
 
89
  = 3.2.1 ( October 2, 2018) =
90
  * Fix: Cross-site request forgery (CSRF)/local file inclusion (LFI) vulnerability.