Companion Auto Update - Version 2.5.0

Version Description

  • New: If you have disabled one or multiple auto-updates, we can email you when an update is available.
Download this release

Release Info

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

Code changes from version 2.0.3 to 2.5.0

companion-auto-update-check-updates.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function cau_check_updates_mail() {
3
+
4
+ global $wpdb;
5
+ $table_name = $wpdb->prefix . "auto_updates";
6
+
7
+ $cau_configs = $wpdb->get_results( "SELECT * FROM $table_name" );
8
+
9
+ if( $cau_configs[5]->onoroff == 'on' ) {
10
+
11
+ // Check for theme updates
12
+ cau_list_theme_updates();
13
+
14
+ // Check for plugin updates
15
+ cau_list_plugin_updates();
16
+
17
+ }
18
+
19
+ }
20
+
21
+ function cau_set_email() {
22
+
23
+ global $wpdb;
24
+ $table_name = $wpdb->prefix . "auto_updates";
25
+
26
+ $cau_configs = $wpdb->get_results( "SELECT * FROM $table_name" );
27
+
28
+ if( $cau_configs[4]->onoroff == '' ) {
29
+ $toemail = get_option('admin_email');
30
+ } else {
31
+ $toemail = $cau_configs[4]->onoroff;
32
+ }
33
+
34
+ return $toemail;
35
+
36
+ }
37
+
38
+ function cau_set_content( $single, $plural ) {
39
+
40
+ return sprintf( esc_html__(
41
+ 'There are one or more %1$s updates available on your WordPress site at: %2$s, but you have disabled auto-updating for %3$s. Login to your dashboard to manually update your %3$s.', 'companion-auto-update'
42
+ ), $single, get_site_url(), $plural);
43
+
44
+ }
45
+
46
+ function cau_list_theme_updates() {
47
+
48
+ global $wpdb;
49
+ $table_name = $wpdb->prefix . "auto_updates";
50
+
51
+ $configs = $wpdb->get_results( "SELECT * FROM $table_name WHERE name = 'themes'");
52
+ foreach ( $configs as $config ) {
53
+
54
+ if( $config->onoroff != 'on' ) {
55
+
56
+ require_once ABSPATH . '/wp-admin/includes/update.php';
57
+ $themes = get_theme_updates();
58
+
59
+ if ( !empty( $themes ) ) {
60
+
61
+ $subject = __('Theme update available.', 'companion-auto-update');
62
+ $type = __('theme', 'companion-auto-update');
63
+ $type_plural = __('themes', 'companion-auto-update');
64
+ $message = cau_set_content( $type, $type_plural );
65
+
66
+ wp_mail( cau_set_email() , $subject, $message, $headers );
67
+ }
68
+
69
+ }
70
+
71
+ }
72
+
73
+ }
74
+
75
+ function cau_list_plugin_updates() {
76
+
77
+ global $wpdb;
78
+ $table_name = $wpdb->prefix . "auto_updates";
79
+
80
+ $configs = $wpdb->get_results( "SELECT * FROM $table_name WHERE name = 'plugins'");
81
+ foreach ( $configs as $config ) {
82
+
83
+ if( $config->onoroff != 'on' ) {
84
+
85
+ require_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
86
+ $plugins = get_plugin_updates();
87
+
88
+ if ( !empty( $plugins ) ) {
89
+
90
+ $subject = __('Plugin update available.', 'companion-auto-update');
91
+ $type = __('plugin', 'companion-auto-update');
92
+ $type_plural = __('plugins', 'companion-auto-update');
93
+ $message = cau_set_content( $type, $type_plural );
94
+
95
+ wp_mail( cau_set_email() , $subject, $message, $headers );
96
+ }
97
+
98
+ }
99
+
100
+ }
101
+
102
+ }
103
+
104
+ ?>
companion-auto-update.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Companion Auto Update
4
  * Plugin URI: https://qreative-web.com
5
  * Description: This plugin auto updates all plugins, all themes and the wordpress core.
6
- * Version: 2.0.3
7
  * Author: Qreative-Web
8
  * Author URI: https://qreative-web.com/en/
9
  * Contributors: papin
@@ -27,35 +27,44 @@ add_action( 'init', 'cau_load_translations' );
27
  // Install db
28
  function cau_install() {
29
 
 
30
  global $wpdb;
31
  $table_name = $wpdb->prefix . "auto_updates";
32
 
33
  $sql = "CREATE TABLE $table_name (
34
  id INT(9) NOT NULL AUTO_INCREMENT,
35
- description VARCHAR(255) NOT NULL,
36
  name VARCHAR(255) NOT NULL,
37
- onoroff VARCHAR(3) NOT NULL,
38
  UNIQUE KEY id (id)
39
  ) $charset_collate;";
40
 
41
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
42
  dbDelta( $sql );
43
 
44
- add_option( "cau_db_version", "1.0" );
 
45
 
 
46
  cau_install_data();
 
 
 
 
 
47
  }
 
48
 
49
  // Inset Data
50
  function cau_install_data() {
51
 
52
- global $wpdb;
53
- $table_name = $wpdb->prefix . "auto_updates";
 
54
 
 
55
  $wpdb->insert(
56
  $table_name,
57
  array(
58
- 'description' => 'Auto update plugins?',
59
  'name' => 'plugins',
60
  'onoroff' => 'on',
61
  )
@@ -64,7 +73,6 @@ function cau_install_data() {
64
  $wpdb->insert(
65
  $table_name,
66
  array(
67
- 'description' => 'Auto update themes?',
68
  'name' => 'themes',
69
  'onoroff' => 'on',
70
  )
@@ -73,7 +81,6 @@ function cau_install_data() {
73
  $wpdb->insert(
74
  $table_name,
75
  array(
76
- 'description' => 'Auto update minor core updates?',
77
  'name' => 'minor',
78
  'onoroff' => 'on',
79
  )
@@ -82,21 +89,40 @@ function cau_install_data() {
82
  $wpdb->insert(
83
  $table_name,
84
  array(
85
- 'description' => 'Auto update major core updates?',
86
  'name' => 'major',
87
  'onoroff' => 'on',
88
  )
89
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
 
91
  }
92
  register_activation_hook( __FILE__, 'cau_install' );
93
 
94
  function cau_remove() {
95
 
 
96
  global $wpdb;
97
  $table_name = $wpdb->prefix . "auto_updates";
98
  $wpdb->query( "DROP TABLE IF EXISTS $table_name" );
99
 
 
 
100
  }
101
  register_deactivation_hook( __FILE__, 'cau_remove' );
102
 
@@ -125,39 +151,103 @@ function cau_frontend() { ?>
125
  $themes = $_POST['themes'];
126
  $minor = $_POST['minor'];
127
  $major = $_POST['major'];
 
 
128
 
129
  $wpdb->query( " UPDATE $table_name SET onoroff = '$plugins' WHERE name = 'plugins' " );
130
  $wpdb->query( " UPDATE $table_name SET onoroff = '$themes' WHERE name = 'themes' " );
131
  $wpdb->query( " UPDATE $table_name SET onoroff = '$minor' WHERE name = 'minor' " );
132
  $wpdb->query( " UPDATE $table_name SET onoroff = '$major' WHERE name = 'major' " );
 
 
133
 
134
- echo '<div id="message" class="updated"><p>'.__('Settings saved', 'companion-auto-update').'</p></div>';
135
  }
136
 
137
  ?>
138
 
139
  <form method="POST">
140
 
141
- <?php
 
 
 
 
142
 
143
- global $wpdb;
144
- $table_name = $wpdb->prefix . "auto_updates";
 
 
 
 
 
 
 
 
 
 
 
 
145
 
146
- $cau_configs = $wpdb->get_results( "SELECT * FROM $table_name" );
147
 
148
- foreach ( $cau_configs as $config ) {
 
 
149
 
150
- echo '<p><input id="'.$config->name.'" name="'.$config->name.'" type="checkbox"';
151
- if( $config->onoroff == 'on' ) {
152
- echo 'checked';
153
- }
154
- echo '/> <label for="'.$config->name.'">'.__(''.$config->description.'', 'companion-auto-update').'</label></p>';
155
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
 
158
- submit_button(); ?>
 
159
 
160
- </form>
 
 
161
 
162
  </div>
163
 
@@ -214,9 +304,10 @@ class CAU_auto_update {
214
  }
215
 
216
  }
217
-
218
  new CAU_auto_update();
219
 
 
 
220
  // Add settings link on plugin page
221
  function cau_settings_link( $links ) {
222
 
3
  * Plugin Name: Companion Auto Update
4
  * Plugin URI: https://qreative-web.com
5
  * Description: This plugin auto updates all plugins, all themes and the wordpress core.
6
+ * Version: 2.5.0
7
  * Author: Qreative-Web
8
  * Author URI: https://qreative-web.com/en/
9
  * Contributors: papin
27
  // Install db
28
  function cau_install() {
29
 
30
+ // Create db table
31
  global $wpdb;
32
  $table_name = $wpdb->prefix . "auto_updates";
33
 
34
  $sql = "CREATE TABLE $table_name (
35
  id INT(9) NOT NULL AUTO_INCREMENT,
 
36
  name VARCHAR(255) NOT NULL,
37
+ onoroff VARCHAR(255) NOT NULL,
38
  UNIQUE KEY id (id)
39
  ) $charset_collate;";
40
 
41
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
42
  dbDelta( $sql );
43
 
44
+ // Database version
45
+ add_option( "cau_db_version", "1.1.1" );
46
 
47
+ // Insert data
48
  cau_install_data();
49
+
50
+ // Set schedule for emails
51
+ if (! wp_next_scheduled ( 'cau_set_schedule_mail' )) {
52
+ wp_schedule_event(time(), 'daily', 'cau_set_schedule_mail');
53
+ }
54
  }
55
+ add_action('cau_set_schedule_mail', 'cau_check_updates_mail');
56
 
57
  // Inset Data
58
  function cau_install_data() {
59
 
60
+ global $wpdb;
61
+ $table_name = $wpdb->prefix . "auto_updates";
62
+ $toemail = get_option('admin_email');
63
 
64
+ // Update configs
65
  $wpdb->insert(
66
  $table_name,
67
  array(
 
68
  'name' => 'plugins',
69
  'onoroff' => 'on',
70
  )
73
  $wpdb->insert(
74
  $table_name,
75
  array(
 
76
  'name' => 'themes',
77
  'onoroff' => 'on',
78
  )
81
  $wpdb->insert(
82
  $table_name,
83
  array(
 
84
  'name' => 'minor',
85
  'onoroff' => 'on',
86
  )
89
  $wpdb->insert(
90
  $table_name,
91
  array(
 
92
  'name' => 'major',
93
  'onoroff' => 'on',
94
  )
95
  );
96
+
97
+ // Email configs
98
+ $wpdb->insert(
99
+ $table_name,
100
+ array(
101
+ 'name' => 'email',
102
+ 'onoroff' => '',
103
+ )
104
+ );
105
+
106
+ $wpdb->insert(
107
+ $table_name,
108
+ array(
109
+ 'name' => 'send',
110
+ 'onoroff' => 'on',
111
+ )
112
+ );
113
 
114
  }
115
  register_activation_hook( __FILE__, 'cau_install' );
116
 
117
  function cau_remove() {
118
 
119
+ // Clear everything
120
  global $wpdb;
121
  $table_name = $wpdb->prefix . "auto_updates";
122
  $wpdb->query( "DROP TABLE IF EXISTS $table_name" );
123
 
124
+ wp_clear_scheduled_hook('cau_set_schedule_mail');
125
+
126
  }
127
  register_deactivation_hook( __FILE__, 'cau_remove' );
128
 
151
  $themes = $_POST['themes'];
152
  $minor = $_POST['minor'];
153
  $major = $_POST['major'];
154
+ $email = $_POST['cau_email'];
155
+ $send = $_POST['cau_send'];
156
 
157
  $wpdb->query( " UPDATE $table_name SET onoroff = '$plugins' WHERE name = 'plugins' " );
158
  $wpdb->query( " UPDATE $table_name SET onoroff = '$themes' WHERE name = 'themes' " );
159
  $wpdb->query( " UPDATE $table_name SET onoroff = '$minor' WHERE name = 'minor' " );
160
  $wpdb->query( " UPDATE $table_name SET onoroff = '$major' WHERE name = 'major' " );
161
+ $wpdb->query( " UPDATE $table_name SET onoroff = '$email' WHERE name = 'email' " );
162
+ $wpdb->query( " UPDATE $table_name SET onoroff = '$send' WHERE name = 'send' " );
163
 
164
+ echo '<div id="message" class="updated"><p><b>'.__('Settings saved', 'companion-auto-update').'.</b></p></div>';
165
  }
166
 
167
  ?>
168
 
169
  <form method="POST">
170
 
171
+ <table class="form-table">
172
+ <tr>
173
+ <th scope="row"><?php _e('Auto Updater', 'companion-auto-update');?></th>
174
+ <td>
175
+ <fieldset>
176
 
177
+ <?php
178
+
179
+ global $wpdb;
180
+ $table_name = $wpdb->prefix . "auto_updates";
181
+
182
+ $cau_configs = $wpdb->get_results( "SELECT * FROM $table_name" );
183
+
184
+ echo '<p><input id="'.$cau_configs[0]->name.'" name="'.$cau_configs[0]->name.'" type="checkbox"';
185
+ if( $cau_configs[0]->onoroff == 'on' ) echo 'checked';
186
+ echo '/> <label for="'.$cau_configs[0]->name.'">'.__('Auto update plugins?', 'companion-auto-update').'</label></p>';
187
+
188
+ echo '<p><input id="'.$cau_configs[1]->name.'" name="'.$cau_configs[1]->name.'" type="checkbox"';
189
+ if( $cau_configs[1]->onoroff == 'on' ) echo 'checked';
190
+ echo '/> <label for="'.$cau_configs[1]->name.'">'.__('Auto update themes?', 'companion-auto-update').'</label></p>';
191
 
 
192
 
193
+ echo '<p><input id="'.$cau_configs[2]->name.'" name="'.$cau_configs[2]->name.'" type="checkbox"';
194
+ if( $cau_configs[2]->onoroff == 'on' ) echo 'checked';
195
+ echo '/> <label for="'.$cau_configs[2]->name.'">'.__('Auto update minor core updates?', 'companion-auto-update').'</label></p>';
196
 
 
 
 
 
 
197
 
198
+ echo '<p><input id="'.$cau_configs[3]->name.'" name="'.$cau_configs[3]->name.'" type="checkbox"';
199
+ if( $cau_configs[3]->onoroff == 'on' ) echo 'checked';
200
+ echo '/> <label for="'.$cau_configs[3]->name.'">'.__('Auto update major core updates?', 'companion-auto-update').'</label></p>';
201
+
202
+ ?>
203
+
204
+ </fieldset>
205
+ </td>
206
+ </tr>
207
+ </table>
208
+
209
+ <h2 class="title"><?php _e('Email Settings', 'companion-auto-update');?></h2>
210
+ <p><?php _e('If you have disabled one or multiple auto-updates, we can email you when an update is available.', 'companion-auto-update');?><br />
211
+ (<?php _e('We wil not send more than one mail per day', 'companion-auto-update');?>)</p>
212
+
213
+ <?php
214
+ if( $cau_configs[4]->onoroff == '' ) {
215
+ $toemail = get_option('admin_email');
216
+ } else {
217
+ $toemail = $cau_configs[4]->onoroff;
218
  }
219
+
220
+ ?>
221
+
222
+ <table class="form-table">
223
+ <tr>
224
+ <th scope="row"><?php _e('Receive Emails', 'companion-auto-update');?></th>
225
+ <td>
226
+ <p>
227
+ <input id="cau_send" name="cau_send" type="checkbox" <?php if( $cau_configs[5]->onoroff == 'on' ) { echo 'checked'; } ?> />
228
+ <label for="cau_send"><?php _e('Send me emails when an update is available.', 'companion-auto-update');?></label>
229
+ </p>
230
+ </td>
231
+ </tr>
232
+ <tr>
233
+ <th scope="row"><?php _e('Email address', 'companion-auto-update');?></th>
234
+ <td>
235
+ <p>
236
+ <label for="cau_email"><?php _e('To', 'companion-auto-update');?>:</label>
237
+ <input type="text" name="cau_email" id="cau_email" class="regular-text" placeholder="<?php echo get_option('admin_email'); ?>" value="<?php echo $toemail; ?>" />
238
+ </p>
239
+
240
+ <p class="description"><?php _e('Seperate email adresses using commas.', 'companion-auto-update');?></p>
241
+ </td>
242
+ </tr>
243
+ </table>
244
 
245
+ <?php submit_button();
246
+
247
 
248
+ if ( !wp_next_scheduled ( 'cau_set_schedule_mail' )) {
249
+ echo '<div id="message" class="error"><p><b>'.__('Companion Auto Update was not able to set the event for sending you emails, please re-activate the plugin in order to set the event', 'companion-auto-update').'.</b></p></div>';
250
+ } ?>
251
 
252
  </div>
253
 
304
  }
305
 
306
  }
 
307
  new CAU_auto_update();
308
 
309
+ require_once('companion-auto-update-check-updates.php');
310
+
311
  // Add settings link on plugin page
312
  function cau_settings_link( $links ) {
313
 
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Companion Auto Update ===
2
  Contributors: Papin
3
  Donate link: https://www.paypal.me/dakel/1
4
- Tags: auto, automatic, background, update, updates, 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
5
  Requires at least: 3.5.0
6
- Tested up to: 4.5
7
- Stable tag: 2.0.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -13,7 +13,13 @@ This plugin automatically updates all plugins, all themes and the wordpress core
13
  == Description ==
14
 
15
  = Keep your website safe! =
16
- This plugin automatically updates all plugins, all themes and the wordpress core (both major and minor updates), you can configure whether you want to update everything (default) or only some.
 
 
 
 
 
 
17
 
18
  == Installation ==
19
 
@@ -24,17 +30,17 @@ This plugin automatically updates all plugins, all themes and the wordpress core
24
  == Screenshots ==
25
 
26
  1. Easily configure what you'd like to auto-update and what not
 
27
 
28
  == Changelog ==
29
 
30
- = 2.0.3 =
31
- * Fully migrated translations to translate.wordpress.org
32
 
33
- = 2.0.2 =
 
34
  * Fixed issue where setting would show up multiple times when re-activating multiple times
35
  * Added settings link to plugin list
36
-
37
- = 2.0 =
38
  * You can now select what to update and what not (plugins, themes, major and minor core updates)
39
 
40
  = 1.0 =
1
  === Companion Auto Update ===
2
  Contributors: Papin
3
  Donate link: https://www.paypal.me/dakel/1
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: 4.6
7
+ Stable tag: 2.5.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
13
  == Description ==
14
 
15
  = Keep your website safe! =
16
+ We understand that you might not always be able to check if your wordpress site has any updates that need to be installed, especially when you maintain multiple websites keeping them up-to-date can be a lot of work.
17
+ This plugin enables background auto-updating for all plugins, all themes and the wordpress core (both major and minor updates).
18
+ We give you full control over what is updated and what isn't, via the settings page you can easily disallow auto-updating for either plugins, themes or wordpress core.
19
+
20
+ = Update Available Emails =
21
+ If you have disabled one or multiple auto-updates, we can email you when an update is available.
22
+ We will only do this once a day ;)
23
 
24
  == Installation ==
25
 
30
  == Screenshots ==
31
 
32
  1. Easily configure what you'd like to auto-update and what not
33
+ 2. If you have disabled one or multiple auto-updates, we can email you when an update is available.
34
 
35
  == Changelog ==
36
 
37
+ = 2.5.0 =
38
+ * New: If you have disabled one or multiple auto-updates, we can email you when an update is available.
39
 
40
+ = 2.0 / 2.0.2 / 2.0.4 =
41
+ * Fully migrated translations to translate.wordpress.org
42
  * Fixed issue where setting would show up multiple times when re-activating multiple times
43
  * Added settings link to plugin list
 
 
44
  * You can now select what to update and what not (plugins, themes, major and minor core updates)
45
 
46
  = 1.0 =