Companion Auto Update - Version 2.8

Version Description

  • Enable/disable updates for translation files (Enabled by default).
  • Core Emails: By default wordpress sends an email when a core update happend, you can now disable this.
  • Several under-the-hood perfomance improvements and a few minor bug fixes.
Download this release

Release Info

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

Code changes from version 2.7.7 to 2.8

companion-auto-update-check-updates.php CHANGED
@@ -2,41 +2,25 @@
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
- if( $cau_configs[6]->onoroff == 'on' ) {
20
-
21
- // Check for updated plugins
22
- if( $cau_configs[0]->onoroff == 'on' ) cau_plugin_updated();
23
-
24
  }
25
 
 
26
  }
27
 
28
  function cau_set_email() {
29
 
30
  global $wpdb;
31
- $table_name = $wpdb->prefix . "auto_updates";
32
-
33
- $cau_configs = $wpdb->get_results( "SELECT * FROM $table_name" );
34
 
35
- if( $cau_configs[4]->onoroff == '' ) {
36
- $toemail = get_option('admin_email');
37
- } else {
38
- $toemail = $cau_configs[4]->onoroff;
39
- }
40
 
41
  return $toemail;
42
 
@@ -126,7 +110,7 @@ function cau_plugin_updated() {
126
  $updatedList = '';
127
  $all_plugins = get_plugins();
128
 
129
- $updatedPlugins = false;
130
 
131
  foreach ( $all_plugins as $key => $value ) {
132
 
@@ -143,14 +127,14 @@ function cau_plugin_updated() {
143
  $last_updated = explode( ' ', $last_updated );
144
  $last_updated = $last_updated[0];
145
 
146
- $updatedPlugins = true;
147
-
148
  if( $last_updated == $today OR $last_updated == $yesterday ) {
149
  foreach ( $value as $k => $v ) {
150
  if( $k == "Name" ) $updatedList .= "- ".$v;
151
  if( $k == "Version" ) $updatedList .= " ".__("to version:")." ".$v."\n";
152
  }
153
 
 
 
154
  $subject = '[' . get_bloginfo( 'name' ) . '] ' . __('One ore more plugins have been updated.', 'companion-auto-update');
155
  $type = __('plugins', 'companion-auto-update');
156
  $message = cau_updated_message( $type, "\n".$updatedList );
2
  function cau_check_updates_mail() {
3
 
4
  global $wpdb;
5
+ $table_name = $wpdb->prefix . "auto_updates";
6
+ $cau_configs = $wpdb->get_results( "SELECT * FROM $table_name" );
 
7
 
8
  if( $cau_configs[5]->onoroff == 'on' ) {
9
+ cau_list_theme_updates(); // Check for theme updates
10
+ cau_list_plugin_updates(); // Check for plugin updates
 
 
 
 
 
 
 
 
 
 
 
 
11
  }
12
 
13
+ if( $cau_configs[6]->onoroff == 'on' ) if( $cau_configs[0]->onoroff == 'on' ) cau_plugin_updated(); // Check for updated plugins
14
  }
15
 
16
  function cau_set_email() {
17
 
18
  global $wpdb;
19
+ $table_name = $wpdb->prefix . "auto_updates";
20
+ $cau_configs = $wpdb->get_results( "SELECT * FROM $table_name" );
 
21
 
22
+ if( $cau_configs[4]->onoroff == '' ) $toemail = get_option('admin_email');
23
+ else $toemail = $cau_configs[4]->onoroff;
 
 
 
24
 
25
  return $toemail;
26
 
110
  $updatedList = '';
111
  $all_plugins = get_plugins();
112
 
113
+ $updatedPlugins = false;
114
 
115
  foreach ( $all_plugins as $key => $value ) {
116
 
127
  $last_updated = explode( ' ', $last_updated );
128
  $last_updated = $last_updated[0];
129
 
 
 
130
  if( $last_updated == $today OR $last_updated == $yesterday ) {
131
  foreach ( $value as $k => $v ) {
132
  if( $k == "Name" ) $updatedList .= "- ".$v;
133
  if( $k == "Version" ) $updatedList .= " ".__("to version:")." ".$v."\n";
134
  }
135
 
136
+ $updatedPlugins = true;
137
+
138
  $subject = '[' . get_bloginfo( 'name' ) . '] ' . __('One ore more plugins have been updated.', 'companion-auto-update');
139
  $type = __('plugins', 'companion-auto-update');
140
  $message = cau_updated_message( $type, "\n".$updatedList );
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.7.7
7
  * Author: Qreative-Web
8
  * Author URI: http://papinschipper.nl
9
  * Contributors: papin
@@ -11,28 +11,21 @@
11
  * License URI: https://www.gnu.org/licenses/gpl-2.0.html
12
  * Text Domain: companion-auto-update
13
  * Domain Path: /languages/
14
- */
15
 
16
  // Disable direct access
17
  defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
18
 
 
19
  function cau_load_translations() {
20
-
21
- // Load translations
22
  load_plugin_textdomain( 'companion-auto-update', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
23
-
24
  }
25
  add_action( 'init', 'cau_load_translations' );
26
 
27
  // Install db
28
  function cau_install() {
29
-
30
- cau_database_creation();
31
-
32
- // Set schedule for emails
33
- if (! wp_next_scheduled ( 'cau_set_schedule_mail' )) {
34
- wp_schedule_event(time(), 'daily', 'cau_set_schedule_mail');
35
- }
36
  }
37
  add_action('cau_set_schedule_mail', 'cau_check_updates_mail');
38
 
@@ -41,7 +34,7 @@ function cau_database_creation() {
41
  global $wpdb;
42
  global $cau_db_version;
43
 
44
- $cau_db_version = '1.3';
45
 
46
  // Create db table
47
  $table_name = $wpdb->prefix . "auto_updates";
@@ -49,7 +42,7 @@ function cau_database_creation() {
49
  $sql = "CREATE TABLE $table_name (
50
  id INT(9) NOT NULL AUTO_INCREMENT,
51
  name VARCHAR(255) NOT NULL,
52
- onoroff VARCHAR(255) NOT NULL,
53
  UNIQUE KEY id (id)
54
  )";
55
 
@@ -90,7 +83,7 @@ function cau_install_data() {
90
 
91
  global $wpdb;
92
  $table_name = $wpdb->prefix . "auto_updates";
93
- $toemail = get_option('admin_email');
94
 
95
  // Update configs
96
  if( !cau_check_if_exists( 'plugins' ) ) $wpdb->insert( $table_name, array( 'name' => 'plugins', 'onoroff' => 'on' ) );
@@ -103,18 +96,20 @@ function cau_install_data() {
103
  if( !cau_check_if_exists( 'send' ) ) $wpdb->insert( $table_name, array( 'name' => 'send', 'onoroff' => '' ) );
104
  if( !cau_check_if_exists( 'sendupdate' ) ) $wpdb->insert( $table_name, array( 'name' => 'sendupdate', 'onoroff' => '' ) );
105
 
 
 
 
 
 
106
  }
107
  register_activation_hook( __FILE__, 'cau_install' );
108
 
 
109
  function cau_remove() {
110
-
111
- // Clear everything
112
  global $wpdb;
113
  $table_name = $wpdb->prefix . "auto_updates";
114
  $wpdb->query( "DROP TABLE IF EXISTS $table_name" );
115
-
116
  wp_clear_scheduled_hook('cau_set_schedule_mail');
117
-
118
  }
119
  register_deactivation_hook( __FILE__, 'cau_remove' );
120
 
@@ -133,132 +128,348 @@ function register_cau_menu_page() {
133
  }
134
  add_action( 'admin_menu', 'register_cau_menu_page' );
135
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  // Settings page
137
  function cau_frontend() { ?>
138
 
139
  <div class='wrap'>
140
 
141
- <h1><?php _e('Auto Updater', 'companion-auto-update');?></h1>
 
 
 
 
 
142
 
143
  <?php
144
 
145
- if ( !wp_next_scheduled ( 'cau_set_schedule_mail' )) 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>';
146
 
147
- global $cau_db_version;
148
- if ( get_site_option( 'cau_db_version' ) != $cau_db_version ) echo '<div id="message" class="error"><p><b>'.__('Database Update', 'companion-auto-update').' &ndash;</b> '.__('It seems like something went wrong while updating the database, please re-activate this plugin', 'companion-auto-update').'.</p></div>';
149
 
150
- if( isset( $_POST['submit'] ) ) {
 
151
 
152
- global $wpdb;
153
- $table_name = $wpdb->prefix . "auto_updates";
154
 
155
- $plugins = $_POST['plugins'];
156
- $themes = $_POST['themes'];
157
- $minor = $_POST['minor'];
158
- $major = $_POST['major'];
159
- $email = $_POST['cau_email'];
160
- $send = $_POST['cau_send'];
161
- $sendupdate = $_POST['cau_send_update'];
162
 
163
- $wpdb->query( " UPDATE $table_name SET onoroff = '$plugins' WHERE name = 'plugins' " );
164
- $wpdb->query( " UPDATE $table_name SET onoroff = '$themes' WHERE name = 'themes' " );
165
- $wpdb->query( " UPDATE $table_name SET onoroff = '$minor' WHERE name = 'minor' " );
166
- $wpdb->query( " UPDATE $table_name SET onoroff = '$major' WHERE name = 'major' " );
167
- $wpdb->query( " UPDATE $table_name SET onoroff = '$email' WHERE name = 'email' " );
168
- $wpdb->query( " UPDATE $table_name SET onoroff = '$send' WHERE name = 'send' " );
169
- $wpdb->query( " UPDATE $table_name SET onoroff = '$sendupdate' WHERE name = 'sendupdate' " );
 
 
170
 
171
- echo '<div id="message" class="updated"><p><b>'.__('Settings saved', 'companion-auto-update').'.</b></p></div>';
172
- }
 
 
 
 
 
 
 
173
 
174
- ?>
 
175
 
176
- <form method="POST">
177
 
178
- <table class="form-table">
179
- <tr>
180
- <th scope="row"><?php _e('Auto Updater', 'companion-auto-update');?></th>
181
- <td>
182
- <fieldset>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
 
184
- <?php
185
 
186
- global $wpdb;
187
- $table_name = $wpdb->prefix . "auto_updates";
188
 
189
- $cau_configs = $wpdb->get_results( "SELECT * FROM $table_name" );
190
 
191
- echo '<p><input id="'.$cau_configs[0]->name.'" name="'.$cau_configs[0]->name.'" type="checkbox"';
192
- if( $cau_configs[0]->onoroff == 'on' ) echo 'checked';
193
- echo '/> <label for="'.$cau_configs[0]->name.'">'.__('Auto update plugins?', 'companion-auto-update').'</label></p>';
194
 
195
- echo '<p><input id="'.$cau_configs[1]->name.'" name="'.$cau_configs[1]->name.'" type="checkbox"';
196
- if( $cau_configs[1]->onoroff == 'on' ) echo 'checked';
197
- echo '/> <label for="'.$cau_configs[1]->name.'">'.__('Auto update themes?', 'companion-auto-update').'</label></p>';
198
 
 
 
 
199
 
200
- echo '<p><input id="'.$cau_configs[2]->name.'" name="'.$cau_configs[2]->name.'" type="checkbox"';
201
- if( $cau_configs[2]->onoroff == 'on' ) echo 'checked';
202
- echo '/> <label for="'.$cau_configs[2]->name.'">'.__('Auto update minor core updates?', 'companion-auto-update').'</label></p>';
203
 
 
204
 
205
- echo '<p><input id="'.$cau_configs[3]->name.'" name="'.$cau_configs[3]->name.'" type="checkbox"';
206
- if( $cau_configs[3]->onoroff == 'on' ) echo 'checked';
207
- echo '/> <label for="'.$cau_configs[3]->name.'">'.__('Auto update major core updates?', 'companion-auto-update').'</label></p>';
208
 
209
- ?>
210
 
211
- </fieldset>
212
- </td>
213
- </tr>
214
- </table>
215
 
216
- <h2 class="title"><?php _e('Email Notifications', 'companion-auto-update');?></h2>
217
- <p><?php _e('Email notifications are send once a day, you can choose what notifications to send below.', 'companion-auto-update');?></p>
218
 
219
- <?php
220
- if( $cau_configs[4]->onoroff == '' ) $toemail = get_option('admin_email');
221
- else $toemail = $cau_configs[4]->onoroff;
222
- ?>
 
 
 
 
 
 
 
 
 
223
 
224
- <table class="form-table">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
  <tr>
226
- <th scope="row"><?php _e('Update Available', 'companion-auto-update');?></th>
227
- <td>
228
- <p>
229
- <input id="cau_send" name="cau_send" type="checkbox" <?php if( $cau_configs[5]->onoroff == 'on' ) { echo 'checked'; } ?> />
230
- <label for="cau_send"><?php _e('Send me emails when an update is available.', 'companion-auto-update');?></label>
231
- </p>
232
- </td>
233
  </tr>
234
- <tr>
235
- <th scope="row"><?php _e('Successful Update', 'companion-auto-update');?></th>
236
- <td>
237
- <p>
238
- <input id="cau_send_update" name="cau_send_update" type="checkbox" <?php if( $cau_configs[6]->onoroff == 'on' ) { echo 'checked'; } ?> />
239
- <label for="cau_send_update"><?php _e('Send me emails when something has been updated.', 'companion-auto-update');?></label>
240
- </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
241
  </td>
242
- </tr>
243
- <tr>
244
- <th scope="row"><?php _e('Email address', 'companion-auto-update');?></th>
245
- <td>
246
- <p>
247
- <label for="cau_email"><?php _e('To', 'companion-auto-update');?>:</label>
248
- <input type="text" name="cau_email" id="cau_email" class="regular-text" placeholder="<?php echo get_option('admin_email'); ?>" value="<?php echo $toemail; ?>" />
249
- </p>
250
-
251
- <p class="description"><?php _e('Seperate email adresses using commas.', 'companion-auto-update');?></p>
252
  </td>
253
- </tr>
254
- </table>
255
-
256
- <?php submit_button(); ?>
257
 
258
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
259
 
260
  <?php }
261
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
262
  // Auto Update Class
263
  class CAU_auto_update {
264
 
@@ -304,29 +515,27 @@ class CAU_auto_update {
304
  // Enable for themes
305
  $configs = $wpdb->get_results( "SELECT * FROM $table_name WHERE name = 'themes'");
306
  foreach ( $configs as $config ) {
307
-
308
  if( $config->onoroff == 'on' ) add_filter( 'auto_update_theme', '__return_true', 1 ); // Turn on
309
  if( $config->onoroff != 'on' ) add_filter( 'auto_update_theme', '__return_false', 1 ); // Turn off
 
310
 
 
 
 
 
 
311
  }
312
 
 
 
 
 
 
 
 
313
  }
314
 
315
  }
316
  new CAU_auto_update();
317
 
318
- // Send e-mails
319
- require_once('companion-auto-update-check-updates.php');
320
-
321
- // Add settings link on plugin page
322
- function cau_settings_link( $links ) {
323
-
324
- $settings_link = '<a href="tools.php?page=cau-settings">'.__('Settings', 'companion-auto-update' ).'</a>';
325
- array_unshift($links, $settings_link);
326
- return $links;
327
-
328
- }
329
- $plugin = plugin_basename(__FILE__);
330
- add_filter("plugin_action_links_$plugin", 'cau_settings_link' );
331
-
332
  ?>
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.8.0
7
  * Author: Qreative-Web
8
  * Author URI: http://papinschipper.nl
9
  * Contributors: papin
11
  * License URI: https://www.gnu.org/licenses/gpl-2.0.html
12
  * Text Domain: companion-auto-update
13
  * Domain Path: /languages/
14
+ */
15
 
16
  // Disable direct access
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
  // 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
 
34
  global $wpdb;
35
  global $cau_db_version;
36
 
37
+ $cau_db_version = '1.4.3';
38
 
39
  // Create db table
40
  $table_name = $wpdb->prefix . "auto_updates";
42
  $sql = "CREATE TABLE $table_name (
43
  id INT(9) NOT NULL AUTO_INCREMENT,
44
  name VARCHAR(255) NOT NULL,
45
+ onoroff VARCHAR(99999) NOT NULL,
46
  UNIQUE KEY id (id)
47
  )";
48
 
83
 
84
  global $wpdb;
85
  $table_name = $wpdb->prefix . "auto_updates";
86
+ $toemail = get_option('admin_email');
87
 
88
  // Update configs
89
  if( !cau_check_if_exists( 'plugins' ) ) $wpdb->insert( $table_name, array( 'name' => 'plugins', 'onoroff' => 'on' ) );
96
  if( !cau_check_if_exists( 'send' ) ) $wpdb->insert( $table_name, array( 'name' => 'send', 'onoroff' => '' ) );
97
  if( !cau_check_if_exists( 'sendupdate' ) ) $wpdb->insert( $table_name, array( 'name' => 'sendupdate', 'onoroff' => '' ) );
98
 
99
+ // Advanced
100
+ if( !cau_check_if_exists( 'notUpdateList' ) ) $wpdb->insert( $table_name, array( 'name' => 'notUpdateList', 'onoroff' => '' ) );
101
+ if( !cau_check_if_exists( 'translations' ) ) $wpdb->insert( $table_name, array( 'name' => 'translations', 'onoroff' => 'on' ) );
102
+ if( !cau_check_if_exists( 'wpemails' ) ) $wpdb->insert( $table_name, array( 'name' => 'wpemails', 'onoroff' => 'on' ) );
103
+
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";
111
  $wpdb->query( "DROP TABLE IF EXISTS $table_name" );
 
112
  wp_clear_scheduled_hook('cau_set_schedule_mail');
 
113
  }
114
  register_deactivation_hook( __FILE__, 'cau_remove' );
115
 
128
  }
129
  add_action( 'admin_menu', 'register_cau_menu_page' );
130
 
131
+ function active_tab( $page ) {
132
+
133
+ if( !isset( $_GET['tab'] ) ) {
134
+ $cur_page = '';
135
+ } else {
136
+ $cur_page = $_GET['tab'];
137
+ }
138
+
139
+ if( $page == $cur_page ) {
140
+ echo 'nav-tab-active';
141
+ }
142
+
143
+ }
144
+
145
  // Settings page
146
  function cau_frontend() { ?>
147
 
148
  <div class='wrap'>
149
 
150
+ <h1><?php _e('Auto Updater', 'companion-auto-update'); ?></h1>
151
+
152
+ <h2 class="nav-tab-wrapper wp-clearfix">
153
+ <a href="tools.php?page=cau-settings" class="nav-tab <?php active_tab(''); ?>"><?php _e('Dashboard', 'companion-auto-update'); ?></a>
154
+ <a href="tools.php?page=cau-settings&amp;tab=pluginlist" class="nav-tab <?php active_tab('pluginlist'); ?>"><?php _e('Filter plugins', 'companion-auto-update'); ?></a>
155
+ </h2>
156
 
157
  <?php
158
 
159
+ if( !isset( $_GET['tab'] ) ) {
160
 
161
+ if ( !wp_next_scheduled ( 'cau_set_schedule_mail' )) 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>';
 
162
 
163
+ global $cau_db_version;
164
+ if ( get_site_option( 'cau_db_version' ) != $cau_db_version ) echo '<div id="message" class="error"><p><b>'.__('Database Update', 'companion-auto-update').' &ndash;</b> '.__('It seems like something went wrong while updating the database, please re-activate this plugin', 'companion-auto-update').'.</p></div>';
165
 
166
+ if( isset( $_POST['submit'] ) ) {
 
167
 
168
+ global $wpdb;
169
+ $table_name = $wpdb->prefix . "auto_updates";
 
 
 
 
 
170
 
171
+ $plugins = $_POST['plugins'];
172
+ $themes = $_POST['themes'];
173
+ $minor = $_POST['minor'];
174
+ $major = $_POST['major'];
175
+ $translations = $_POST['translations'];
176
+ $email = $_POST['cau_email'];
177
+ $send = $_POST['cau_send'];
178
+ $sendupdate = $_POST['cau_send_update'];
179
+ $wpemails = $_POST['wpemails'];
180
 
181
+ $wpdb->query( " UPDATE $table_name SET onoroff = '$plugins' WHERE name = 'plugins' " );
182
+ $wpdb->query( " UPDATE $table_name SET onoroff = '$themes' WHERE name = 'themes' " );
183
+ $wpdb->query( " UPDATE $table_name SET onoroff = '$minor' WHERE name = 'minor' " );
184
+ $wpdb->query( " UPDATE $table_name SET onoroff = '$major' WHERE name = 'major' " );
185
+ $wpdb->query( " UPDATE $table_name SET onoroff = '$translations' WHERE name = 'translations' " );
186
+ $wpdb->query( " UPDATE $table_name SET onoroff = '$email' WHERE name = 'email' " );
187
+ $wpdb->query( " UPDATE $table_name SET onoroff = '$send' WHERE name = 'send' " );
188
+ $wpdb->query( " UPDATE $table_name SET onoroff = '$sendupdate' WHERE name = 'sendupdate' " );
189
+ $wpdb->query( " UPDATE $table_name SET onoroff = '$wpemails' WHERE name = 'wpemails' " );
190
 
191
+ echo '<div id="message" class="updated"><p><b>'.__('Settings saved', 'companion-auto-update').'.</b></p></div>';
192
+ }
193
 
194
+ ?>
195
 
196
+ <form method="POST">
197
+
198
+ <table class="form-table">
199
+ <tr>
200
+ <th scope="row"><?php _e('Auto Updater', 'companion-auto-update');?></th>
201
+ <td>
202
+ <fieldset>
203
+
204
+ <?php
205
+
206
+ global $wpdb;
207
+ $table_name = $wpdb->prefix . "auto_updates";
208
+
209
+ $cau_configs = $wpdb->get_results( "SELECT * FROM $table_name" );
210
+
211
+ echo '<p><input id="'.$cau_configs[0]->name.'" name="'.$cau_configs[0]->name.'" type="checkbox"';
212
+ if( $cau_configs[0]->onoroff == 'on' ) echo 'checked';
213
+ echo '/> <label for="'.$cau_configs[0]->name.'">'.__('Auto update plugins?', 'companion-auto-update').'</label></p>';
214
+
215
+ echo '<p><input id="'.$cau_configs[1]->name.'" name="'.$cau_configs[1]->name.'" type="checkbox"';
216
+ if( $cau_configs[1]->onoroff == 'on' ) echo 'checked';
217
+ echo '/> <label for="'.$cau_configs[1]->name.'">'.__('Auto update themes?', 'companion-auto-update').'</label></p>';
218
+
219
+
220
+ echo '<p><input id="'.$cau_configs[2]->name.'" name="'.$cau_configs[2]->name.'" type="checkbox"';
221
+ if( $cau_configs[2]->onoroff == 'on' ) echo 'checked';
222
+ echo '/> <label for="'.$cau_configs[2]->name.'">'.__('Auto update minor core updates?', 'companion-auto-update').'</label></p>';
223
+
224
+
225
+ echo '<p><input id="'.$cau_configs[3]->name.'" name="'.$cau_configs[3]->name.'" type="checkbox"';
226
+ if( $cau_configs[3]->onoroff == 'on' ) echo 'checked';
227
+ echo '/> <label for="'.$cau_configs[3]->name.'">'.__('Auto update major core updates?', 'companion-auto-update').'</label></p>';
228
+
229
+ echo '<p><input id="'.$cau_configs[8]->name.'" name="'.$cau_configs[8]->name.'" type="checkbox"';
230
+ if( $cau_configs[8]->onoroff == 'on' ) echo 'checked';
231
+ echo '/> <label for="'.$cau_configs[8]->name.'">'.__('Auto update translation files?', 'companion-auto-update').'</label></p>';
232
+
233
+ ?>
234
+
235
+ </fieldset>
236
+ </td>
237
+ </tr>
238
+ </table>
239
+
240
+ <h2 class="title"><?php _e('Email Notifications', 'companion-auto-update');?></h2>
241
+ <p><?php _e('Email notifications are send once a day, you can choose what notifications to send below.', 'companion-auto-update');?></p>
242
+
243
+ <?php
244
+ if( $cau_configs[4]->onoroff == '' ) $toemail = get_option('admin_email');
245
+ else $toemail = $cau_configs[4]->onoroff;
246
+ ?>
247
+
248
+ <table class="form-table">
249
+ <tr>
250
+ <th scope="row"><?php _e('Update available', 'companion-auto-update');?></th>
251
+ <td>
252
+ <p>
253
+ <input id="cau_send" name="cau_send" type="checkbox" <?php if( $cau_configs[5]->onoroff == 'on' ) { echo 'checked'; } ?> />
254
+ <label for="cau_send"><?php _e('Send me emails when an update is available.', 'companion-auto-update');?></label>
255
+ </p>
256
+ </td>
257
+ </tr>
258
+ <tr>
259
+ <th scope="row"><?php _e('Successful update', 'companion-auto-update');?></th>
260
+ <td>
261
+ <p>
262
+ <input id="cau_send_update" name="cau_send_update" type="checkbox" <?php if( $cau_configs[6]->onoroff == 'on' ) { echo 'checked'; } ?> />
263
+ <label for="cau_send_update"><?php _e('Send me emails when something has been updated.', 'companion-auto-update');?></label>
264
+ </p>
265
+ </td>
266
+ </tr>
267
+ <tr>
268
+ <th scope="row"><?php _e('Core notifications', 'companion-auto-update');?></th>
269
+ <td>
270
+ <p>
271
+ <input id="wpemails" name="wpemails" type="checkbox" <?php if( $cau_configs[9]->onoroff == 'on' ) { echo 'checked'; } ?> />
272
+ <label for="wpemails"><?php _e('By default wordpress sends an email when a core update happend, here you can disable it.', 'companion-auto-update');?></label>
273
+ </p>
274
+ </td>
275
+ </tr>
276
+ <tr>
277
+ <th scope="row"><?php _e('Email address', 'companion-auto-update');?></th>
278
+ <td>
279
+ <p>
280
+ <label for="cau_email"><?php _e('To', 'companion-auto-update');?>:</label>
281
+ <input type="text" name="cau_email" id="cau_email" class="regular-text" placeholder="<?php echo get_option('admin_email'); ?>" value="<?php echo $toemail; ?>" />
282
+ </p>
283
+
284
+ <p class="description"><?php _e('Seperate email adresses using commas.', 'companion-auto-update');?></p>
285
+ </td>
286
+ </tr>
287
+ </table>
288
+
289
+ <?php submit_button();
290
+
291
+ } else if( $_GET['tab'] == 'pluginlist' ) {
292
+
293
+ echo '<p>Coming soon.. <a href="http://papinschipper.nl/blog/new-feature-filter-plugins/" target="_blank">Read more</a></p>';
294
+ // selectPlugins();
295
+
296
+ } ?>
297
 
298
+ </div>
299
 
300
+ <?php }
 
301
 
302
+ function donotupdatelist() {
303
 
304
+ global $wpdb;
305
+ $table_name = $wpdb->prefix . "auto_updates";
306
+ $config = $wpdb->get_results( "SELECT * FROM $table_name WHERE name = 'notUpdateList'");
307
 
308
+ $list = $config[0]->onoroff;
309
+ $list = explode( ", ", $list );
310
+ $returnList = array();
311
 
312
+ foreach ( $list as $key ) array_push( $returnList, $key );
313
+
314
+ return $returnList;
315
 
316
+ }
 
 
317
 
318
+ function selectPlugins() { ?>
319
 
320
+ <p><?php _e('Here you can select plugins that you do not wish to automatically update', 'companion-auto-update'); ?>.</p>
 
 
321
 
322
+ <?php
323
 
324
+ global $wpdb;
325
+ $table_name = $wpdb->prefix . "auto_updates";
 
 
326
 
327
+ $configs = $wpdb->get_results( "SELECT * FROM $table_name WHERE name = 'plugins'");
328
+ foreach ( $configs as $config ) if( $config->onoroff != 'on' ) echo '<div id="message" class="error"><p><b>'.__('Auto updating disabled', 'companion-auto-update').' &ndash;</b> '.__('You have <strong>disabled</strong> auto updating, these settings do not work unless you <strong>enable</strong> it', 'companion-auto-update').'.</p></div>';
329
 
330
+ if( isset( $_POST['submit'] ) ) {
331
+
332
+ $noUpdateList = '';
333
+ $noUpdateCount = 0;
334
+
335
+ foreach ( $_POST['post'] as $key ) {
336
+ $noUpdateList .= $key.', ';
337
+ $noUpdateCount++;
338
+ }
339
+
340
+ $wpdb->query( " UPDATE $table_name SET onoroff = '$noUpdateList' WHERE name = 'notUpdateList' " );
341
+ echo '<div id="message" class="updated"><p><b>'.__('Succes', 'companion-auto-update').' &ndash;</b> '.sprintf( esc_html__( '%1$s plugins have been added to the no-update-list', 'companion-auto-update' ), $noUpdateCount ).'.</p></div>';
342
+ }
343
 
344
+ if( isset( $_POST['reset'] ) ) {
345
+
346
+ $wpdb->query( " UPDATE $table_name SET onoroff = '' WHERE name = 'notUpdateList' " );
347
+ echo '<div id="message" class="updated"><p><b>'.__('Succes', 'companion-auto-update').' &ndash;</b> '.__( 'The no-update-list has been reset, all plugins will be auto-updated from now on', 'companion-auto-update' ).'.</p></div>';
348
+ }
349
+
350
+ ?>
351
+
352
+ <form method="POST">
353
+
354
+ <p>
355
+ <input type='submit' name='submit' id='submit' class='button button-primary' value='<?php _e( "Save changes" ); ?>'>
356
+ <input type='submit' name='reset' id='reset' class='button button-alt' value='<?php _e( "Reset list", "companion-auto-update" ); ?>'>
357
+ </p>
358
+
359
+ <table class="wp-list-table widefat autoupdate striped plugins">
360
+ <thead>
361
  <tr>
362
+ <td id='cb' class='manage-column column-cb check-column'>&nbsp;</td>
363
+ <th id='name' class='manage-column column-name column-primary'><strong><?php _e('Plugin', 'companion-auto-update'); ?></strong></th>
364
+ <th id='description' class='manage-column column-description'><strong><?php _e('Description', 'companion-auto-update'); ?></strong></th>
 
 
 
 
365
  </tr>
366
+ </thead>
367
+
368
+ <tbody id="the-list">
369
+
370
+ <?php
371
+
372
+ foreach ( get_plugins() as $key => $value ) {
373
+
374
+ $slug = $key;
375
+ $hash = explode( '/', $slug );
376
+ $slug_hash = md5( $slug[0] );
377
+
378
+ foreach ( $value as $k => $v ) {
379
+
380
+ if( $k == "Name" ) $name = $v;
381
+ if( $k == "Description" ) $description = $v;
382
+
383
+ }
384
+
385
+ if( in_array( $slug, donotupdatelist() ) ) {
386
+
387
+ $class = 'inactive';
388
+ $checked = 'CHECKED';
389
+ $status = __( 'Auto-updating: disabled' , 'companion-auto-update' );
390
+
391
+ } else {
392
+
393
+ $class = 'active';
394
+ $checked = '';
395
+ $status = __( 'Auto-updating: enabled' , 'companion-auto-update' );
396
+
397
+ }
398
+
399
+ echo '<tr id="post-'.$slug_hash.'" class="'.$class.'">
400
+
401
+ <th scope="row" class="check-column">
402
+ <label class="screen-reader-text" for="cb-select-'.$slug_hash.'">Select '. $name .'</label>
403
+ <input id="cb-select-'.$slug_hash.'" type="checkbox" name="post[]" value="'.$slug.'" '.$checked.' ><label></label>
404
+ <div class="locked-indicator"></div>
405
+ </th>
406
+
407
+ <td class="plugin-title column-primary">
408
+ <strong class="plugin-name">
409
+ '. $name .'
410
+ </strong>
411
+ <div class="row-actions visible status">
412
+ '. $status .'
413
+ </div>
414
  </td>
415
+
416
+ <td class="column-description desc">
417
+ <div class="plugin-description">
418
+ <p>'.$description.'</p>
419
+ </div>
 
 
 
 
 
420
  </td>
 
 
 
 
421
 
422
+ </tr>';
423
+
424
+ }
425
+ ?>
426
+
427
+ </tbody>
428
+ </table>
429
+
430
+ <p>
431
+ <input type='submit' name='submit' id='submit' class='button button-primary' value='<?php _e( "Save changes" ); ?>'>
432
+ <input type='submit' name='reset' id='reset' class='button button-alt' value='<?php _e( "Reset list", "companion-auto-update" ); ?>'>
433
+ </p>
434
+
435
+ </form>
436
 
437
  <?php }
438
 
439
+ // Load admin styles
440
+ function load_cau_sytyles( $hook ) {
441
+
442
+ if( $hook != 'tools_page_cau-settings' ) return;
443
+ wp_enqueue_style( 'cau_admin_styles', plugins_url('backend/style.css', __FILE__) );
444
+
445
+ }
446
+ add_action( 'admin_enqueue_scripts', 'load_cau_sytyles' );
447
+
448
+ // Send e-mails
449
+ require_once('companion-auto-update-check-updates.php');
450
+
451
+ // Add settings link on plugin page
452
+ function cau_settings_link( $links ) {
453
+
454
+ $settings_link = '<a href="tools.php?page=cau-settings">'.__('Settings', 'companion-auto-update' ).'</a>';
455
+ array_unshift($links, $settings_link);
456
+ return $links;
457
+
458
+ }
459
+ $plugin = plugin_basename(__FILE__);
460
+ add_filter("plugin_action_links_$plugin", 'cau_settings_link' );
461
+
462
+ // Only update plugin which are enabled
463
+ function cau_dont_update ( $update, $item ) {
464
+
465
+ if ( in_array( $item->slug, donotupdatelist() ) ) {
466
+ return $update;
467
+ } else {
468
+ return true;
469
+ }
470
+
471
+ }
472
+
473
  // Auto Update Class
474
  class CAU_auto_update {
475
 
515
  // Enable for themes
516
  $configs = $wpdb->get_results( "SELECT * FROM $table_name WHERE name = 'themes'");
517
  foreach ( $configs as $config ) {
 
518
  if( $config->onoroff == 'on' ) add_filter( 'auto_update_theme', '__return_true', 1 ); // Turn on
519
  if( $config->onoroff != 'on' ) add_filter( 'auto_update_theme', '__return_false', 1 ); // Turn off
520
+ }
521
 
522
+ // Enable for translation files
523
+ $configs = $wpdb->get_results( "SELECT * FROM $table_name WHERE name = 'translations'");
524
+ foreach ( $configs as $config ) {
525
+ if( $config->onoroff == 'on' ) add_filter( 'auto_update_translation', '__return_true' ); // Turn on
526
+ if( $config->onoroff != 'on' ) add_filter( 'auto_update_translation', '__return_false' ); // Turn off
527
  }
528
 
529
+ // WP Email Config
530
+ $configs = $wpdb->get_results( "SELECT * FROM $table_name WHERE name = 'wpemail'");
531
+ foreach ( $configs as $config ) {
532
+ if( $config->onoroff != 'on' ) add_filter( 'auto_core_update_send_email', '__return_false' );
533
+ }
534
+
535
+
536
  }
537
 
538
  }
539
  new CAU_auto_update();
540
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
541
  ?>
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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.7
7
- Stable tag: 2.7.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -22,12 +22,18 @@ We give you full control over what is updated and what isn't, via the settings p
22
  1. Enable/disable updates for themes (Enabled by default).
23
  1. Enable/disable updates for minor WordPress updates (Enabled by default).
24
  1. Enable/disable updates for major WordPress updates (Enabled by default).
 
25
 
26
- = Email Notifications (Disabled by default) =
27
- Email notifications are send once a day, right now two notifications are available:
 
 
28
 
29
- 1. Update Available: Sends an email when an update is available and you've disabled auto-updates
30
- 1. Successful Update: Sends an email when something has been updated (only works for plugins right now)
 
 
 
31
 
32
  == Installation ==
33
 
@@ -49,7 +55,15 @@ Email notifications are send once a day, right now two notifications are availab
49
  1. Easily configure what you'd like to auto-update and what not
50
  2. If you have disabled one or multiple auto-updates, we can email you when an update is available.
51
 
52
- == Changelog ==
 
 
 
 
 
 
 
 
53
 
54
  = 2.7.7 =
55
  * New: Added site name to e-mail subject. Example: [Qreative-Web] One ore more plugins have been updated.
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.7
7
+ Stable tag: 2.8.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
22
  1. Enable/disable updates for themes (Enabled by default).
23
  1. Enable/disable updates for minor WordPress updates (Enabled by default).
24
  1. Enable/disable updates for major WordPress updates (Enabled by default).
25
+ 1. Enable/disable updates for translation files (Enabled by default).
26
 
27
+ = Email Notifications =
28
+ 1. Update Available: Sends an email when an update is available and you've disabled auto-updates (Disabled by default).
29
+ 1. Successful Update: Sends an email when something has been updated (Disabled by default).
30
+ 1. Core Emails: By default wordpress sends an email when a core update happend, you can now disable this.
31
 
32
+ Email notifications are send once a day in order to prevent spamming :)
33
+
34
+ = Advanced Controls: Coming soon =
35
+ You can control auto-updating per plugin via the plugin filter.
36
+ For example: If you have Woocommerce installed but you do not wan't to have it auto-updated you can now disable auto-updating for Woocommerce only, so your other plugins will continue to be updated.
37
 
38
  == Installation ==
39
 
55
  1. Easily configure what you'd like to auto-update and what not
56
  2. If you have disabled one or multiple auto-updates, we can email you when an update is available.
57
 
58
+ == Changelog ==
59
+
60
+ = What to expect: 2.9 =
61
+ * Advanced Controls: You can control auto-updating per plugin via the plugin filter.
62
+
63
+ = 2.8 =
64
+ * Enable/disable updates for translation files (Enabled by default).
65
+ * Core Emails: By default wordpress sends an email when a core update happend, you can now disable this.
66
+ * Several under-the-hood perfomance improvements and a few minor bug fixes.
67
 
68
  = 2.7.7 =
69
  * New: Added site name to e-mail subject. Example: [Qreative-Web] One ore more plugins have been updated.