Companion Auto Update - Version 3.8.3

Version Description

(December 9, 2021) = * New: Plugin update e-mails now have an option to link to a few important pages * Fix: Error: Undefined index: dbupdateemails * Fix: Error: A non-numeric value encountered

Download this release

Release Info

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

Code changes from version 3.8.2 to 3.8.3

Files changed (10) hide show
  1. admin/dashboard.php +577 -572
  2. admin/log.php +18 -18
  3. admin/pluginlist.php +184 -184
  4. admin/rollback.php +2 -2
  5. admin/status.php +404 -404
  6. backend/style.css +574 -566
  7. cau_emails.php +525 -512
  8. cau_functions.php +18 -7
  9. companion-auto-update.php +467 -466
  10. readme.txt +7 -2
admin/dashboard.php CHANGED
@@ -1,573 +1,578 @@
1
- <?php
2
-
3
- // Event schedules failed
4
- if ( !wp_next_scheduled ( 'cau_set_schedule_mail' ) ) {
5
- 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>';
6
- }
7
-
8
- // Database requires an update
9
- if ( cau_incorrectDatabaseVersion() ) {
10
- echo '<div id="message" class="error"><p><b>'.__( 'Companion Auto Update Database Update', 'companion-auto-update' ).' &ndash;</b>
11
- '.__( 'We need you to update to the latest database version', 'companion-auto-update' ).'. <a href="'.cau_url( 'status' ).'&run=db_update" class="button button-alt" style="background: #FFF;">'.__( 'Run updater now', 'companion-auto-update' ).'</a></p></div>';
12
- }
13
-
14
- // Update log DB is empty
15
- if ( cau_updateLogDBisEmpty() ) {
16
- echo '<div id="message" class="error"><p><b>'.__( 'Companion Auto Update Database Update', 'companion-auto-update' ).' &ndash;</b>
17
- '.__( 'We need to add some information to your database', 'companion-auto-update' ).'. <a href="'.cau_url( 'status' ).'&run=db_info_update" class="button button-alt" style="background: #FFF;">'.__( 'Run updater now', 'companion-auto-update' ).'</a></p></div>';
18
- }
19
-
20
- // Save settings
21
- if( isset( $_POST['submit'] ) ) {
22
-
23
- check_admin_referer( 'cau_save_settings' );
24
-
25
- global $wpdb;
26
- $table_name = $wpdb->prefix . "auto_updates";
27
-
28
- // Auto updater
29
- $plugins = isset( $_POST['plugins'] ) ? sanitize_text_field( $_POST['plugins'] ) : '';
30
- $themes = isset( $_POST['themes'] ) ? sanitize_text_field( $_POST['themes'] ) : '';
31
- $minor = isset( $_POST['minor'] ) ? sanitize_text_field( $_POST['minor'] ) : '';
32
- $major = isset( $_POST['major'] ) ? sanitize_text_field( $_POST['major'] ) : '';
33
- $translations = isset( $_POST['translations'] ) ? sanitize_text_field( $_POST['translations'] ) : '';
34
-
35
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'plugins'", $plugins ) );
36
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'themes'", $themes ) );
37
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'minor'", $minor ) );
38
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'major'", $major ) );
39
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'translations'", $translations ) );
40
-
41
- // Emails
42
- $send = isset( $_POST['cau_send'] ) ? sanitize_text_field( $_POST['cau_send'] ) : '';
43
- $sendupdate = isset( $_POST['cau_send_update'] ) ? sanitize_text_field( $_POST['cau_send_update'] ) : '';
44
- $sendoutdated = isset( $_POST['cau_send_outdated'] ) ? sanitize_text_field( $_POST['cau_send_outdated'] ) : '';
45
- $wpemails = isset( $_POST['wpemails'] ) ? sanitize_text_field( $_POST['wpemails'] ) : '';
46
- $email = isset( $_POST['cau_email'] ) ? sanitize_text_field( $_POST['cau_email'] ) : '';
47
- $html_or_text = isset( $_POST['html_or_text'] ) ? sanitize_text_field( $_POST['html_or_text'] ) : 'html';
48
- $dbupdateemails = isset( $_POST['dbupdateemails'] ) ? sanitize_text_field( $_POST['dbupdateemails'] ) : '';
49
-
50
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'email'", $email ) );
51
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'send'", $send ) );
52
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'sendupdate'", $sendupdate ) );
53
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'sendoutdated'", $sendoutdated ) );
54
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'wpemails'", $wpemails ) );
55
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'html_or_text'", $html_or_text ) );
56
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'dbupdateemails'", $dbupdateemails ) );
57
-
58
- // Advanced
59
- $allow_editor = isset( $_POST['allow_editor'] ) ? sanitize_text_field( $_POST['allow_editor'] ) : '';
60
- $allow_author = isset( $_POST['allow_author'] ) ? sanitize_text_field( $_POST['allow_author'] ) : '';
61
- $advanced_info_emails = isset( $_POST['advanced_info_emails'] ) ? sanitize_text_field( $_POST['advanced_info_emails'] ) : '';
62
-
63
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'allow_editor'", $allow_editor ) );
64
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'allow_author'", $allow_author ) );
65
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'advanced_info_emails'", $advanced_info_emails ) );
66
-
67
- // Delay
68
- $update_delay = isset( $_POST['update_delay'] ) ? sanitize_text_field( $_POST['update_delay'] ) : '';
69
- $update_delay_days = isset( $_POST['update_delay_days'] ) ? sanitize_text_field( $_POST['update_delay_days'] ) : '';
70
-
71
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'update_delay'", $update_delay ) );
72
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'update_delay_days'", $update_delay_days ) );
73
-
74
- // Intervals
75
-
76
- // Set variables
77
- $plugin_sc = sanitize_text_field( $_POST['plugin_schedule'] );
78
- $theme_sc = sanitize_text_field( $_POST['theme_schedule'] );
79
- $core_sc = sanitize_text_field( $_POST['core_schedule'] );
80
- $schedule_mail = sanitize_text_field( $_POST['update_notifications'] );
81
- $outdated_notifier = sanitize_text_field( $_POST['outdated_notifier'] );
82
- $html_or_text = sanitize_text_field( $_POST['html_or_text'] );
83
- $dbupdateemails = sanitize_text_field( $_POST['dbupdateemails'] );
84
-
85
- // First clear schedules
86
- wp_clear_scheduled_hook('wp_update_plugins');
87
- wp_clear_scheduled_hook('wp_update_themes');
88
- wp_clear_scheduled_hook('wp_version_check');
89
- wp_clear_scheduled_hook('cau_set_schedule_mail');
90
- wp_clear_scheduled_hook('cau_custom_hooks_plugins');
91
- wp_clear_scheduled_hook('cau_custom_hooks_themes');
92
- wp_clear_scheduled_hook('cau_log_updater');
93
- wp_clear_scheduled_hook('cau_outdated_notifier');
94
-
95
- // Then set the new times
96
-
97
- // Plugins
98
- if( $plugin_sc == 'daily' ) {
99
-
100
- $date = date( 'Y-m-d' );
101
- $hours = sanitize_text_field( $_POST['plugin_schedule-sethour'] );
102
- $minutes = sanitize_text_field( $_POST['plugin_schedule-setminutes'] );
103
- $seconds = date( 's' );
104
- $fullDate = $date.' '.$hours.':'.$minutes.':'.$seconds;
105
- $pluginSetTime = strtotime( $fullDate );
106
-
107
- wp_schedule_event( $pluginSetTime, $plugin_sc, 'wp_update_plugins' );
108
- wp_schedule_event( $pluginSetTime, $plugin_sc, 'cau_custom_hooks_plugins' );
109
- wp_schedule_event( ( $pluginSetTime - 1800 ), $plugin_sc, 'cau_log_updater' );
110
-
111
- } else {
112
-
113
- wp_schedule_event( time(), $plugin_sc, 'wp_update_plugins' );
114
- wp_schedule_event( time(), $plugin_sc, 'cau_custom_hooks_plugins' );
115
- wp_schedule_event( ( time() - 1800 ), $plugin_sc, 'cau_log_updater' );
116
-
117
- }
118
-
119
- // Themes
120
- if( $theme_sc == 'daily' ) {
121
-
122
- $dateT = date( 'Y-m-d' );
123
- $hoursT = sanitize_text_field( $_POST['theme_schedule-sethour'] );
124
- $minutesT = sanitize_text_field( $_POST['theme_schedule-setminutes'] );
125
- $secondsT = date( 's' );
126
- $fullDateT = $dateT.' '.$hoursT.':'.$minutesT.':'.$secondsT;
127
- $themeSetTime = strtotime( $fullDateT );
128
-
129
- wp_schedule_event( $themeSetTime, $theme_sc, 'wp_update_themes' );
130
- wp_schedule_event( $themeSetTime, $theme_sc, 'cau_custom_hooks_themes' );
131
-
132
- } else {
133
-
134
- wp_schedule_event( time(), $theme_sc, 'wp_update_themes' );
135
- wp_schedule_event( time(), $theme_sc, 'cau_custom_hooks_themes' );
136
-
137
- }
138
-
139
- // Core
140
- if( $core_sc == 'daily' ) {
141
-
142
- $dateC = date( 'Y-m-d' );
143
- $hoursC = sanitize_text_field( $_POST['core_schedule-sethour'] );
144
- $minutesC = sanitize_text_field( $_POST['core_schedule-setminutes'] );
145
- $secondsC = date( 's' );
146
- $fullDateC = $dateC.' '.$hoursC.':'.$minutesC.':'.$secondsC;
147
- $coreSetTime = strtotime( $fullDateC );
148
-
149
- wp_schedule_event( $coreSetTime, $core_sc, 'wp_version_check' );
150
-
151
- } else {
152
-
153
- wp_schedule_event( time(), $core_sc, 'wp_version_check' );
154
-
155
- }
156
-
157
- // Update notifications
158
- if( $schedule_mail == 'daily' ) {
159
-
160
- $dateT = date( 'Y-m-d' );
161
- $hoursT = sanitize_text_field( $_POST['update_notifications-sethour'] );
162
- $minutesT = sanitize_text_field( $_POST['update_notifications-setminutes'] );
163
- $secondsT = date( 's' );
164
- $fullDateT = $dateT.' '.$hoursT.':'.$minutesT.':'.$secondsT;
165
- $emailSetTime = strtotime( $fullDateT );
166
-
167
- wp_schedule_event( $emailSetTime, $schedule_mail, 'cau_set_schedule_mail' );
168
-
169
- } else {
170
-
171
- wp_schedule_event( time(), $schedule_mail, 'cau_set_schedule_mail' );
172
-
173
- }
174
-
175
- // Outdated notifications
176
- if( $outdated_notifier == 'daily' ) {
177
-
178
- $dateT = date( 'Y-m-d' );
179
- $hoursT = sanitize_text_field( $_POST['outdated_notifier-sethour'] );
180
- $minutesT = sanitize_text_field( $_POST['outdated_notifier-setminutes'] );
181
- $secondsT = date( 's' );
182
- $fullDateT = $dateT.' '.$hoursT.':'.$minutesT.':'.$secondsT;
183
- $emailSetTime = strtotime( $fullDateT );
184
-
185
- wp_schedule_event( $emailSetTime, $outdated_notifier, 'cau_outdated_notifier' );
186
-
187
- } else {
188
-
189
- wp_schedule_event( time(), $outdated_notifier, 'cau_outdated_notifier' );
190
-
191
- }
192
-
193
-
194
- echo '<div id="message" class="updated"><p><b>'.__( 'Settings saved.' ).'</b></p></div>';
195
-
196
- }
197
-
198
- if( isset( $_GET['welcome'] ) ) {
199
-
200
- echo '<div class="welcome-to-cau welcome-bg welcome-panel" style="margin-bottom: 0px;">
201
- <div class="welcome-image">
202
- </div><div class="welcome-content">
203
-
204
- <h3>'.__( 'Welcome to Companion Auto Update', 'companion-auto-update' ).'</h3>
205
- <br />
206
- <p><strong>'.__( 'You\'re set and ready to go', 'companion-auto-update' ).'</strong></p>
207
- <p>'.__( 'The plugin is all set and ready to go with the recommended settings, but if you\'d like you can change them below.' ).'</p>
208
- <br />
209
- <p><strong>'.__( 'Get Started' ).': </strong> <a href="'.cau_url( 'pluginlist' ).'">'.__( 'Update filter', 'companion-auto-update' ).'</a> &nbsp; | &nbsp;
210
- <strong>'.__( 'More Actions' ).': </strong> <a href="http://codeermeneer.nl/cau_poll/" target="_blank">'.__('Give feedback', 'companion-auto-update').'</a> - <a href="https://translate.wordpress.org/projects/wp-plugins/companion-auto-update/" target="_blank">'.__( 'Help us translate', 'companion-auto-update' ).'</a></p>
211
-
212
- </div>
213
- </div>';
214
- }
215
-
216
- $cs_hooks_p = wp_get_schedule( 'cau_custom_hooks_plugins' );
217
- $cs_hooks_t = wp_get_schedule( 'cau_custom_hooks_themes' );
218
-
219
- ?>
220
-
221
- <div class="cau-column-wide">
222
-
223
- <form method="POST">
224
-
225
- <div class="welcome-to-cau update-bg welcome-panel cau-dashboard-box">
226
-
227
- <h2 class="title"><?php _e('Auto Updater', 'companion-auto-update');?></h2>
228
-
229
- <table class="form-table">
230
- <tr>
231
- <td>
232
- <fieldset>
233
-
234
- <?php
235
-
236
- echo '<p><input id="plugins" name="plugins" type="checkbox"';
237
- if( cau_get_db_value( 'plugins' ) == 'on' ) echo 'checked';
238
- echo '/> <label for="plugins">'.__('Auto update plugins?', 'companion-auto-update').'</label></p>';
239
-
240
- echo '<p><input id="themes" name="themes" type="checkbox"';
241
- if( cau_get_db_value( 'themes' ) == 'on' ) echo 'checked';
242
- echo '/> <label for="themes">'.__('Auto update themes?', 'companion-auto-update').'</label></p>';
243
-
244
- echo '<p><input id="minor" name="minor" type="checkbox"';
245
- if( cau_get_db_value( 'minor' ) == 'on' ) echo 'checked';
246
- echo '/> <label for="minor">'.__('Auto update minor core updates?', 'companion-auto-update').' <code class="majorMinorExplain">5.3.0 > 5.3.1</code></label></p>';
247
-
248
- echo '<p><input id="major" name="major" type="checkbox"';
249
- if( cau_get_db_value( 'major' ) == 'on' ) echo 'checked';
250
- echo '/> <label for="major">'.__('Auto update major core updates?', 'companion-auto-update').' <code class="majorMinorExplain">5.3.0 > 5.4.0</code></label></p>';
251
-
252
- echo '<p><input id="translations" name="translations" type="checkbox"';
253
- if( cau_get_db_value( 'translations' ) == 'on' ) echo 'checked';
254
- echo '/> <label for="translations">'.__('Auto update translation files?', 'companion-auto-update').'</label></p>';
255
-
256
- ?>
257
-
258
- </fieldset>
259
- </td>
260
- </tr>
261
- </table>
262
-
263
- </div>
264
-
265
- <div class="welcome-to-cau email-bg welcome-panel cau-dashboard-box">
266
-
267
- <h2 class="title"><?php _e( 'Email Notifications', 'companion-auto-update' );?></h2>
268
-
269
- <?php
270
- if( cau_get_db_value( 'email' ) == '' ) $toemail = get_option('admin_email');
271
- else $toemail = cau_get_db_value( 'email' );
272
- ?>
273
-
274
- <table class="form-table">
275
- <tr>
276
- <th scope="row"><?php _e( 'Update notifications', 'companion-auto-update' );?></th>
277
- <td>
278
- <p>
279
- <input id="cau_send_update" name="cau_send_update" type="checkbox" <?php if( cau_get_db_value( 'sendupdate' ) == 'on' ) { echo 'checked'; } ?> />
280
- <label for="cau_send_update"><?php _e( 'Send me emails when something has been updated.', 'companion-auto-update' );?></label>
281
- </p>
282
- <p>
283
- <input id="cau_send" name="cau_send" type="checkbox" <?php if( cau_get_db_value( 'send' ) == 'on' ) { echo 'checked'; } ?> />
284
- <label for="cau_send"><?php _e('Send me emails when an update is available.', 'companion-auto-update');?></label>
285
- </p>
286
- </td>
287
- </tr>
288
- <tr>
289
- <th scope="row"><?php _e( 'Check for outdated software', 'companion-auto-update' );?></th>
290
- <td>
291
- <p>
292
- <input id="cau_send_outdated" name="cau_send_outdated" type="checkbox" <?php if( cau_get_db_value( 'sendoutdated' ) == 'on' ) { echo 'checked'; } ?> />
293
- <label for="cau_send_outdated"><?php _e( 'Be notified of plugins that have not been tested with the 3 latest major versions of WordPress.', 'companion-auto-update' );?></label>
294
- </p>
295
- </td>
296
- </tr>
297
- <tr>
298
- <th scope="row"><?php _e( 'Email Address', 'companion-auto-update' );?></th>
299
- <td>
300
- <p>
301
- <label for="cau_email"><?php _e( 'To', 'companion-auto-update' ); ?>:</label>
302
- <input type="text" name="cau_email" id="cau_email" class="regular-text" placeholder="<?php echo get_option('admin_email'); ?>" value="<?php echo esc_html( $toemail ); ?>" />
303
- </p>
304
-
305
- <p class="description"><?php _e('Seperate email addresses using commas.', 'companion-auto-update');?></p>
306
- </td>
307
- </tr>
308
- <tr>
309
- <th scope="row"><?php _e( 'Use HTML in emails?', 'companion-auto-update' );?></th>
310
- <td>
311
- <p>
312
- <select id='html_or_text' name='html_or_text'>
313
- <option value='html' <?php if( cau_get_db_value( 'html_or_text' ) == 'html' ) { echo "SELECTED"; } ?>><?php _e( 'Use HTML', 'companion-auto-update' ); ?></option>
314
- <option value='text' <?php if( cau_get_db_value( 'html_or_text' ) == 'text' ) { echo "SELECTED"; } ?>><?php _e( 'Use plain text', 'companion-auto-update' ); ?></option>
315
- </select>
316
- </p>
317
- </td>
318
- </tr>
319
- <tr>
320
- <th scope="row"><?php _e( 'Show more info in emails', 'companion-auto-update' );?></th>
321
- <td>
322
- <p>
323
- <label for="advanced_info_emails"><input name="advanced_info_emails" type="checkbox" id="advanced_info_emails" <?php if( cau_get_db_value( 'advanced_info_emails' ) == 'on' ) { echo "CHECKED"; } ?>> <?php _e( 'Show the time of the update', 'companion-auto-update' ); ?></label>
324
- </p>
325
- </td>
326
- </tr>
327
- <tr>
328
- <th scope="row">
329
- <?php _e( 'WordPress notifications', 'companion-auto-update' );?>
330
- <span class='cau_tooltip'><span class="dashicons dashicons-editor-help"></span>
331
- <span class='cau_tooltip_text'>
332
- <?php _e( 'Core notifications are handled by WordPress and not by this plugin. You can only disable them, changing your email address in the settings above will not affect these notifications.', 'companion-auto-update' );?>
333
- </span>
334
- </span>
335
- </th>
336
- <td>
337
- <p>
338
- <input id="wpemails" name="wpemails" type="checkbox" <?php if( cau_get_db_value( 'wpemails' ) == 'on' ) { echo 'checked'; } ?> />
339
- <label for="wpemails"><?php _e( 'By default WordPress sends an email when a core update has occurred. Uncheck this box to disable these emails.', 'companion-auto-update' ); ?></label>
340
- </p>
341
- </td>
342
- </tr>
343
- <tr>
344
- <th scope="row"><?php _e( 'Database update required', 'companion-auto-update' );?></th>
345
- <td>
346
- <p>
347
- <input id="dbupdateemails" name="dbupdateemails" type="checkbox" <?php if( cau_get_db_value( 'dbupdateemails' ) == 'on' ) { echo 'checked'; } ?> />
348
- <label for="dbupdateemails"><?php _e( 'Sometimes we\'ll need your help updating our database version to the latest version, check this box to allow us to send you an email about this.', 'companion-auto-update' ); ?></label>
349
- </p>
350
- </td>
351
- </tr>
352
- </table>
353
-
354
- </div>
355
-
356
- <div class="welcome-to-cau interval-bg welcome-panel cau-dashboard-box" style="overflow: hidden;">
357
-
358
- <h2 class="title"><?php _e( 'Intervals', 'companion-auto-update' );?></h2>
359
-
360
- <?php
361
-
362
- function cau_show_interval_selection( $identiefier, $schedule ) {
363
-
364
- // Get the info
365
- $setValue = wp_get_schedule( $schedule );
366
- $setTime = wp_next_scheduled( $schedule );
367
- $setHour = date( 'H' , $setTime );
368
- $setMinutes = date( 'i' , $setTime );
369
-
370
- // Show interval selection
371
- echo "<p>";
372
- echo "<select name='$identiefier' id='$identiefier' class='schedule_interval wide interval_scheduler' data-timeblock='$identiefier'>";
373
- foreach ( cau_wp_get_schedules() as $key => $value ) {
374
- echo "<option "; if( $setValue == $key ) { echo "selected "; } echo "value='".$key."'>".$value."</option>";
375
- }
376
- echo "</select>";
377
- echo "</p>";
378
-
379
- // Set the time when daily is selected
380
- echo "<div class='timeblock-$identiefier' style='display: none;'>";
381
-
382
- echo "<div class='cau_schedule_input'>
383
- <input type='number' min='0' max='23' name='".$identiefier."-sethour' value='$setHour' maxlength='2' >
384
- </div><div class='cau_schedule_input_div'>
385
- :
386
- </div><div class='cau_schedule_input'>
387
- <input type='number' min='0' max='59' name='".$identiefier."-setminutes' value='$setMinutes' maxlength='2' >
388
- </div><div class='cau_shedule_notation'>
389
- <span class='cau_tooltip'><span class='dashicons dashicons-editor-help'></span>
390
- <span class='cau_tooltip_text'>".__( 'At what time should the updater run? Only works when set to <u>daily</u>.', 'companion-auto-update' )." - ".__( 'Time notation: 24H', 'companion-auto-update' )."</span>
391
- </span>
392
- </div>";
393
-
394
- echo "</div>";
395
-
396
- }
397
-
398
- ?>
399
-
400
- <div class="welcome-column">
401
-
402
- <h4><?php _e( 'Plugin update interval', 'companion-auto-update' );?></h4>
403
- <?php cau_show_interval_selection( 'plugin_schedule', 'wp_update_plugins' ); ?>
404
-
405
- </div>
406
-
407
- <div class="welcome-column">
408
-
409
- <h4><?php _e( 'Theme update interval', 'companion-auto-update' );?></h4>
410
- <?php cau_show_interval_selection( 'theme_schedule', 'wp_update_themes' ); ?>
411
-
412
- </div>
413
-
414
- <div class="welcome-column">
415
-
416
- <h4><?php _e( 'Core update interval', 'companion-auto-update' );?></h4>
417
- <?php cau_show_interval_selection( 'core_schedule', 'wp_version_check' ); ?>
418
-
419
- </div>
420
-
421
- <p></p>
422
-
423
- <div class="welcome-column">
424
-
425
- <h4><?php _e( 'Update notifications', 'companion-auto-update' );?></h4>
426
- <?php cau_show_interval_selection( 'update_notifications', 'cau_set_schedule_mail' ); ?>
427
-
428
- </div>
429
-
430
- <div class="welcome-column">
431
-
432
- <h4><?php _e( 'Outdated software', 'companion-auto-update' );?></h4>
433
- <?php cau_show_interval_selection( 'outdated_notifier', 'cau_outdated_notifier' ); ?>
434
-
435
- </div>
436
-
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><?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', 'companion-auto-update' ); ?></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', 'companion-auto-update' ); ?></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', 'companion-auto-update' ); ?></label></p>
451
- </td>
452
- </tr>
453
- <tr>
454
- <th scope="row"><label><?php _e( 'Delay updates', 'companion-auto-update' ); ?></label></th>
455
- <td>
456
- <p><label for="update_delay"><input name="update_delay" type="checkbox" id="update_delay" <?php if( cau_get_db_value( 'update_delay' ) == 'on' ) { echo "CHECKED"; } ?>><?php _e( 'Delay updates', 'companion-auto-update' ); ?></label></p>
457
- </td>
458
- </tr>
459
- <tr id='update_delay_days_block' <?php if( cau_get_db_value( 'update_delay' ) != 'on' ) { echo "class='disabled_option'"; } ?>>
460
- <th scope="row"><label><?php _e( 'Number of days', 'companion-auto-update' ); ?></label></th>
461
- <td>
462
- <input type="number" min="0" max="31" name="update_delay_days" id="update_delay_days" class="regular-text" value="<?php echo cau_get_db_value( 'update_delay_days' ); ?>" />
463
- <p><?php _e( 'For how many days should updates be put on hold?', 'companion-auto-update' ); ?></p>
464
- </td>
465
- </tr>
466
- </tbody>
467
- </table>
468
-
469
- </div>
470
-
471
- <?php wp_nonce_field( 'cau_save_settings' ); ?>
472
-
473
- <div class="cau_save_button">
474
- <?php submit_button(); ?>
475
- </div>
476
- <div class="cau_save_button__space"></div>
477
-
478
- </form>
479
-
480
- </div><div class="cau-column-small">
481
-
482
- <div class="welcome-to-cau help-bg welcome-panel cau-dashboard-box">
483
- <div class="welcome-column welcome-column.welcome-column-half">
484
- <h3 class="support-sidebar-title"><?php _e( 'Help' ); ?></h3>
485
- <ul class="support-sidebar-list">
486
- <li><a href="https://codeermeneer.nl/stuffs/faq-auto-updater/" target="_blank"><?php _e( 'Frequently Asked Questions', 'companion-auto-update' ); ?></a></li>
487
- <li><a href="https://wordpress.org/support/plugin/companion-auto-update" target="_blank"><?php _e( 'Support Forums' ); ?></a></li>
488
- </ul>
489
-
490
- <h3 class="support-sidebar-title"><?php _e( 'Want to contribute?', 'companion-auto-update' ); ?></h3>
491
- <ul class="support-sidebar-list">
492
- <li><a href="http://codeermeneer.nl/cau_poll/" target="_blank"><?php _e( 'Give feedback', 'companion-auto-update' ); ?></a></li>
493
- <li><a href="https://codeermeneer.nl/blog/companion-auto-update-and-its-future/" target="_blank"><?php _e( 'Feature To-Do List', 'companion-auto-update' ); ?></a></li>
494
- <li><a href="https://translate.wordpress.org/projects/wp-plugins/companion-auto-update/" target="_blank"><?php _e( 'Help us translate', 'companion-auto-update' ); ?></a></li>
495
- </ul>
496
- </div>
497
- <div class="welcome-column welcome-column.welcome-column-half">
498
- <h3 class="support-sidebar-title"><?php _e( 'Developer?', 'companion-auto-update' ); ?></h3>
499
- <ul class="support-sidebar-list">
500
- <li><a href="https://codeermeneer.nl/documentation/auto-update/" target="_blank"><?php _e( 'Documentation' ); ?></a></li>
501
- </ul>
502
- </div>
503
- </div>
504
-
505
- <div class="welcome-to-cau support-bg welcome-panel cau-dashboard-box">
506
- <div class="welcome-column welcome-column">
507
- <h3><?php _e('Support', 'companion-auto-update');?></h3>
508
- <p><?php _e('Feel free to reach out to us if you have any questions or feedback.', 'companion-auto-update'); ?></p>
509
- <p><a href="https://codeermeneer.nl/contact/" target="_blank" class="button button-primary"><?php _e( 'Contact us', 'companion-auto-update' ); ?></a></p>
510
- <p><a href="https://codeermeneer.nl/plugins/" target="_blank" class="button button-alt"><?php _e('Check out our other plugins', 'companion-auto-update');?></a></p>
511
- </div>
512
- </div>
513
-
514
- <div class="welcome-to-cau love-bg cau-show-love welcome-panel cau-dashboard-box">
515
- <h3><?php _e( 'Like our plugin?', 'companion-auto-update' ); ?></h3>
516
- <p><?php _e('Companion Auto Update is free to use. It has required a great deal of time and effort to develop and you can help support this development by making a small donation.<br />You get useful software and we get to carry on making it better.', 'companion-auto-update'); ?></p>
517
- <a href="https://wordpress.org/support/plugin/companion-auto-update/reviews/#new-post" target="_blank" class="button button-alt button-hero">
518
- <?php _e('Rate us (5 stars?)', 'companion-auto-update'); ?>
519
- </a>
520
- <a href="<?php echo cau_donateUrl(); ?>" target="_blank" class="button button-primary button-hero">
521
- <?php _e('Donate to help development', 'companion-auto-update'); ?>
522
- </a>
523
- <p style="font-size: 12px; color: #BDBDBD;"><?php _e( 'Donations via PayPal. Amount can be changed.', 'companion-auto-update'); ?></p>
524
- </div>
525
-
526
- <div class="welcome-to-cau welcome-panel cau-dashboard-box">
527
- <h3><span style='background: #EBE3F7; color: #BCADD3; padding: 1px 5px; border-radius: 3px; font-size: .8em'>Plugin Promotion</span></h3>
528
- <h3>Keep your site fast with our Revision Manager</h3>
529
- <p>Post Revisions are great, but will also slow down your site. Take back control over revisions with Companion Revision Manager!</p>
530
- <a href="https://codeermeneer.nl/portfolio/plugin/companion-revision-manager/" target="_blank" class="button button-alt">Read more</a>
531
- </div>
532
-
533
- </div>
534
-
535
- <style>
536
- .disabled_option {
537
- opacity: .5;
538
- }
539
- </style>
540
-
541
- <script type="text/javascript">
542
-
543
- jQuery( '#update_delay' ).change( function() {
544
- jQuery( '#update_delay_days_block' ).toggleClass( 'disabled_option' );
545
- });
546
-
547
- jQuery( '.interval_scheduler' ).change( function() {
548
-
549
- var selected = jQuery(this).val(); // Selected value
550
- var timeblock = jQuery(this).data( 'timeblock' ); // Corresponding time block
551
-
552
- if( selected == 'daily' ) {
553
- jQuery( '.timeblock-'+timeblock ).show();
554
- } else {
555
- jQuery( '.timeblock-'+timeblock ).hide();
556
- }
557
-
558
- });
559
-
560
- jQuery( '.interval_scheduler' ).each( function() {
561
-
562
- var selected = jQuery(this).val(); // Selected value
563
- var timeblock = jQuery(this).data( 'timeblock' ); // Corresponding time block
564
-
565
- if( selected == 'daily' ) {
566
- jQuery( '.timeblock-'+timeblock ).show();
567
- } else {
568
- jQuery( '.timeblock-'+timeblock ).hide();
569
- }
570
-
571
- });
572
-
 
 
 
 
 
573
  </script>
1
+ <?php
2
+
3
+ // Event schedules failed
4
+ if ( !wp_next_scheduled ( 'cau_set_schedule_mail' ) ) {
5
+ 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>';
6
+ }
7
+
8
+ // Database requires an update
9
+ if ( cau_incorrectDatabaseVersion() ) {
10
+ echo '<div id="message" class="error"><p><b>'.__( 'Companion Auto Update Database Update', 'companion-auto-update' ).' &ndash;</b>
11
+ '.__( 'We need you to update to the latest database version', 'companion-auto-update' ).'. <a href="'.cau_url( 'status' ).'&run=db_update" class="button button-alt" style="background: #FFF;">'.__( 'Run updater now', 'companion-auto-update' ).'</a></p></div>';
12
+ }
13
+
14
+ // Update log DB is empty
15
+ if ( cau_updateLogDBisEmpty() ) {
16
+ echo '<div id="message" class="error"><p><b>'.__( 'Companion Auto Update Database Update', 'companion-auto-update' ).' &ndash;</b>
17
+ '.__( 'We need to add some information to your database', 'companion-auto-update' ).'. <a href="'.cau_url( 'status' ).'&run=db_info_update" class="button button-alt" style="background: #FFF;">'.__( 'Run updater now', 'companion-auto-update' ).'</a></p></div>';
18
+ }
19
+
20
+ // Save settings
21
+ if( isset( $_POST['submit'] ) ) {
22
+
23
+ check_admin_referer( 'cau_save_settings' );
24
+
25
+ global $wpdb;
26
+ $table_name = $wpdb->prefix . "auto_updates";
27
+
28
+ // Auto updater
29
+ $plugins = isset( $_POST['plugins'] ) ? sanitize_text_field( $_POST['plugins'] ) : '';
30
+ $themes = isset( $_POST['themes'] ) ? sanitize_text_field( $_POST['themes'] ) : '';
31
+ $minor = isset( $_POST['minor'] ) ? sanitize_text_field( $_POST['minor'] ) : '';
32
+ $major = isset( $_POST['major'] ) ? sanitize_text_field( $_POST['major'] ) : '';
33
+ $translations = isset( $_POST['translations'] ) ? sanitize_text_field( $_POST['translations'] ) : '';
34
+
35
+ $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'plugins'", $plugins ) );
36
+ $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'themes'", $themes ) );
37
+ $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'minor'", $minor ) );
38
+ $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'major'", $major ) );
39
+ $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'translations'", $translations ) );
40
+
41
+ // Emails
42
+ $send = isset( $_POST['cau_send'] ) ? sanitize_text_field( $_POST['cau_send'] ) : '';
43
+ $sendupdate = isset( $_POST['cau_send_update'] ) ? sanitize_text_field( $_POST['cau_send_update'] ) : '';
44
+ $sendoutdated = isset( $_POST['cau_send_outdated'] ) ? sanitize_text_field( $_POST['cau_send_outdated'] ) : '';
45
+ $wpemails = isset( $_POST['wpemails'] ) ? sanitize_text_field( $_POST['wpemails'] ) : '';
46
+ $email = isset( $_POST['cau_email'] ) ? sanitize_text_field( $_POST['cau_email'] ) : '';
47
+ $html_or_text = isset( $_POST['html_or_text'] ) ? sanitize_text_field( $_POST['html_or_text'] ) : 'html';
48
+ $dbupdateemails = isset( $_POST['dbupdateemails'] ) ? sanitize_text_field( $_POST['dbupdateemails'] ) : '';
49
+
50
+ $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'email'", $email ) );
51
+ $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'send'", $send ) );
52
+ $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'sendupdate'", $sendupdate ) );
53
+ $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'sendoutdated'", $sendoutdated ) );
54
+ $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'wpemails'", $wpemails ) );
55
+ $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'html_or_text'", $html_or_text ) );
56
+ $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'dbupdateemails'", $dbupdateemails ) );
57
+
58
+ // Advanced
59
+ $allow_editor = isset( $_POST['allow_editor'] ) ? sanitize_text_field( $_POST['allow_editor'] ) : '';
60
+ $allow_author = isset( $_POST['allow_author'] ) ? sanitize_text_field( $_POST['allow_author'] ) : '';
61
+ $advanced_info_emails = isset( $_POST['advanced_info_emails'] ) ? sanitize_text_field( $_POST['advanced_info_emails'] ) : '';
62
+ $plugin_links_emails = isset( $_POST['plugin_links_emails'] ) ? sanitize_text_field( $_POST['plugin_links_emails'] ) : '';
63
+
64
+ $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'allow_editor'", $allow_editor ) );
65
+ $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'allow_author'", $allow_author ) );
66
+ $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'advanced_info_emails'", $advanced_info_emails ) );
67
+ $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'plugin_links_emails'", $plugin_links_emails ) );
68
+
69
+ // Delay
70
+ $update_delay = isset( $_POST['update_delay'] ) ? sanitize_text_field( $_POST['update_delay'] ) : '';
71
+ $update_delay_days = isset( $_POST['update_delay_days'] ) ? sanitize_text_field( $_POST['update_delay_days'] ) : '';
72
+
73
+ $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'update_delay'", $update_delay ) );
74
+ $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'update_delay_days'", $update_delay_days ) );
75
+
76
+ // Intervals
77
+
78
+ // Set variables
79
+ $plugin_sc = sanitize_text_field( $_POST['plugin_schedule'] );
80
+ $theme_sc = sanitize_text_field( $_POST['theme_schedule'] );
81
+ $core_sc = sanitize_text_field( $_POST['core_schedule'] );
82
+ $schedule_mail = sanitize_text_field( $_POST['update_notifications'] );
83
+ $outdated_notifier = sanitize_text_field( $_POST['outdated_notifier'] );
84
+
85
+ // First clear schedules
86
+ wp_clear_scheduled_hook('wp_update_plugins');
87
+ wp_clear_scheduled_hook('wp_update_themes');
88
+ wp_clear_scheduled_hook('wp_version_check');
89
+ wp_clear_scheduled_hook('cau_set_schedule_mail');
90
+ wp_clear_scheduled_hook('cau_custom_hooks_plugins');
91
+ wp_clear_scheduled_hook('cau_custom_hooks_themes');
92
+ wp_clear_scheduled_hook('cau_log_updater');
93
+ wp_clear_scheduled_hook('cau_outdated_notifier');
94
+
95
+ // Then set the new times
96
+
97
+ // Plugins
98
+ if( $plugin_sc == 'daily' ) {
99
+
100
+ $date = date( 'Y-m-d' );
101
+ $hours = sanitize_text_field( $_POST['plugin_schedule-sethour'] );
102
+ $minutes = sanitize_text_field( $_POST['plugin_schedule-setminutes'] );
103
+ $seconds = date( 's' );
104
+ $fullDate = $date.' '.$hours.':'.$minutes.':'.$seconds;
105
+ $pluginSetTime = strtotime( $fullDate );
106
+
107
+ wp_schedule_event( $pluginSetTime, $plugin_sc, 'wp_update_plugins' );
108
+ wp_schedule_event( $pluginSetTime, $plugin_sc, 'cau_custom_hooks_plugins' );
109
+ wp_schedule_event( ( $pluginSetTime - 1800 ), $plugin_sc, 'cau_log_updater' );
110
+
111
+ } else {
112
+
113
+ wp_schedule_event( time(), $plugin_sc, 'wp_update_plugins' );
114
+ wp_schedule_event( time(), $plugin_sc, 'cau_custom_hooks_plugins' );
115
+ wp_schedule_event( ( time() - 1800 ), $plugin_sc, 'cau_log_updater' );
116
+
117
+ }
118
+
119
+ // Themes
120
+ if( $theme_sc == 'daily' ) {
121
+
122
+ $dateT = date( 'Y-m-d' );
123
+ $hoursT = sanitize_text_field( $_POST['theme_schedule-sethour'] );
124
+ $minutesT = sanitize_text_field( $_POST['theme_schedule-setminutes'] );
125
+ $secondsT = date( 's' );
126
+ $fullDateT = $dateT.' '.$hoursT.':'.$minutesT.':'.$secondsT;
127
+ $themeSetTime = strtotime( $fullDateT );
128
+
129
+ wp_schedule_event( $themeSetTime, $theme_sc, 'wp_update_themes' );
130
+ wp_schedule_event( $themeSetTime, $theme_sc, 'cau_custom_hooks_themes' );
131
+
132
+ } else {
133
+
134
+ wp_schedule_event( time(), $theme_sc, 'wp_update_themes' );
135
+ wp_schedule_event( time(), $theme_sc, 'cau_custom_hooks_themes' );
136
+
137
+ }
138
+
139
+ // Core
140
+ if( $core_sc == 'daily' ) {
141
+
142
+ $dateC = date( 'Y-m-d' );
143
+ $hoursC = sanitize_text_field( $_POST['core_schedule-sethour'] );
144
+ $minutesC = sanitize_text_field( $_POST['core_schedule-setminutes'] );
145
+ $secondsC = date( 's' );
146
+ $fullDateC = $dateC.' '.$hoursC.':'.$minutesC.':'.$secondsC;
147
+ $coreSetTime = strtotime( $fullDateC );
148
+
149
+ wp_schedule_event( $coreSetTime, $core_sc, 'wp_version_check' );
150
+
151
+ } else {
152
+
153
+ wp_schedule_event( time(), $core_sc, 'wp_version_check' );
154
+
155
+ }
156
+
157
+ // Update notifications
158
+ if( $schedule_mail == 'daily' ) {
159
+
160
+ $dateT = date( 'Y-m-d' );
161
+ $hoursT = sanitize_text_field( $_POST['update_notifications-sethour'] );
162
+ $minutesT = sanitize_text_field( $_POST['update_notifications-setminutes'] );
163
+ $secondsT = date( 's' );
164
+ $fullDateT = $dateT.' '.$hoursT.':'.$minutesT.':'.$secondsT;
165
+ $emailSetTime = strtotime( $fullDateT );
166
+
167
+ wp_schedule_event( $emailSetTime, $schedule_mail, 'cau_set_schedule_mail' );
168
+
169
+ } else {
170
+
171
+ wp_schedule_event( time(), $schedule_mail, 'cau_set_schedule_mail' );
172
+
173
+ }
174
+
175
+ // Outdated notifications
176
+ if( $outdated_notifier == 'daily' ) {
177
+
178
+ $dateT = date( 'Y-m-d' );
179
+ $hoursT = sanitize_text_field( $_POST['outdated_notifier-sethour'] );
180
+ $minutesT = sanitize_text_field( $_POST['outdated_notifier-setminutes'] );
181
+ $secondsT = date( 's' );
182
+ $fullDateT = $dateT.' '.$hoursT.':'.$minutesT.':'.$secondsT;
183
+ $emailSetTime = strtotime( $fullDateT );
184
+
185
+ wp_schedule_event( $emailSetTime, $outdated_notifier, 'cau_outdated_notifier' );
186
+
187
+ } else {
188
+
189
+ wp_schedule_event( time(), $outdated_notifier, 'cau_outdated_notifier' );
190
+
191
+ }
192
+
193
+
194
+ echo '<div id="message" class="updated"><p><b>'.__( 'Settings saved.' ).'</b></p></div>';
195
+
196
+ }
197
+
198
+ if( isset( $_GET['welcome'] ) ) {
199
+
200
+ echo '<div class="welcome-to-cau welcome-bg welcome-panel" style="margin-bottom: 0px;">
201
+ <div class="welcome-image">
202
+ </div><div class="welcome-content">
203
+
204
+ <h3>'.__( 'Welcome to Companion Auto Update', 'companion-auto-update' ).'</h3>
205
+ <br />
206
+ <p><strong>'.__( 'You\'re set and ready to go', 'companion-auto-update' ).'</strong></p>
207
+ <p>'.__( 'The plugin is all set and ready to go with the recommended settings, but if you\'d like you can change them below.' ).'</p>
208
+ <br />
209
+ <p><strong>'.__( 'Get Started' ).': </strong> <a href="'.cau_url( 'pluginlist' ).'">'.__( 'Update filter', 'companion-auto-update' ).'</a> &nbsp; | &nbsp;
210
+ <strong>'.__( 'More Actions' ).': </strong> <a href="http://codeermeneer.nl/cau_poll/" target="_blank">'.__('Give feedback', 'companion-auto-update').'</a> - <a href="https://translate.wordpress.org/projects/wp-plugins/companion-auto-update/" target="_blank">'.__( 'Help us translate', 'companion-auto-update' ).'</a></p>
211
+
212
+ </div>
213
+ </div>';
214
+ }
215
+
216
+ $cs_hooks_p = wp_get_schedule( 'cau_custom_hooks_plugins' );
217
+ $cs_hooks_t = wp_get_schedule( 'cau_custom_hooks_themes' );
218
+
219
+ ?>
220
+
221
+ <div class="cau-dashboard cau-column-wide">
222
+
223
+ <form method="POST">
224
+
225
+ <div class="welcome-to-cau update-bg welcome-panel cau-dashboard-box">
226
+
227
+ <h2 class="title"><?php _e('Auto Updater', 'companion-auto-update');?></h2>
228
+
229
+ <table class="form-table">
230
+ <tr>
231
+ <td>
232
+ <fieldset>
233
+
234
+ <?php
235
+
236
+ echo '<p><input id="plugins" name="plugins" type="checkbox"';
237
+ if( cau_get_db_value( 'plugins' ) == 'on' ) echo 'checked';
238
+ echo '/> <label for="plugins">'.__('Auto update plugins?', 'companion-auto-update').'</label></p>';
239
+
240
+ echo '<p><input id="themes" name="themes" type="checkbox"';
241
+ if( cau_get_db_value( 'themes' ) == 'on' ) echo 'checked';
242
+ echo '/> <label for="themes">'.__('Auto update themes?', 'companion-auto-update').'</label></p>';
243
+
244
+ echo '<p><input id="minor" name="minor" type="checkbox"';
245
+ if( cau_get_db_value( 'minor' ) == 'on' ) echo 'checked';
246
+ echo '/> <label for="minor">'.__('Auto update minor core updates?', 'companion-auto-update').' <code class="majorMinorExplain">5.3.0 > 5.3.1</code></label></p>';
247
+
248
+ echo '<p><input id="major" name="major" type="checkbox"';
249
+ if( cau_get_db_value( 'major' ) == 'on' ) echo 'checked';
250
+ echo '/> <label for="major">'.__('Auto update major core updates?', 'companion-auto-update').' <code class="majorMinorExplain">5.3.0 > 5.4.0</code></label></p>';
251
+
252
+ echo '<p><input id="translations" name="translations" type="checkbox"';
253
+ if( cau_get_db_value( 'translations' ) == 'on' ) echo 'checked';
254
+ echo '/> <label for="translations">'.__('Auto update translation files?', 'companion-auto-update').'</label></p>';
255
+
256
+ ?>
257
+
258
+ </fieldset>
259
+ </td>
260
+ </tr>
261
+ </table>
262
+
263
+ </div>
264
+
265
+ <div class="welcome-to-cau email-bg welcome-panel cau-dashboard-box">
266
+
267
+ <h2 class="title"><?php _e( 'Email Notifications', 'companion-auto-update' );?></h2>
268
+
269
+ <?php
270
+ if( cau_get_db_value( 'email' ) == '' ) $toemail = get_option('admin_email');
271
+ else $toemail = cau_get_db_value( 'email' );
272
+ ?>
273
+
274
+ <table class="form-table">
275
+ <tr>
276
+ <th scope="row"><?php _e( 'Update notifications', 'companion-auto-update' );?></th>
277
+ <td>
278
+ <p>
279
+ <input id="cau_send_update" name="cau_send_update" type="checkbox" <?php if( cau_get_db_value( 'sendupdate' ) == 'on' ) { echo 'checked'; } ?> />
280
+ <label for="cau_send_update"><?php _e( 'Send me emails when something has been updated.', 'companion-auto-update' );?></label>
281
+ </p>
282
+ <p>
283
+ <input id="cau_send" name="cau_send" type="checkbox" <?php if( cau_get_db_value( 'send' ) == 'on' ) { echo 'checked'; } ?> />
284
+ <label for="cau_send"><?php _e('Send me emails when an update is available.', 'companion-auto-update');?></label>
285
+ </p>
286
+ </td>
287
+ </tr>
288
+ <tr>
289
+ <th scope="row"><?php _e( 'Check for outdated software', 'companion-auto-update' );?></th>
290
+ <td>
291
+ <p>
292
+ <input id="cau_send_outdated" name="cau_send_outdated" type="checkbox" <?php if( cau_get_db_value( 'sendoutdated' ) == 'on' ) { echo 'checked'; } ?> />
293
+ <label for="cau_send_outdated"><?php _e( 'Be notified of plugins that have not been tested with the 3 latest major versions of WordPress.', 'companion-auto-update' );?></label>
294
+ </p>
295
+ </td>
296
+ </tr>
297
+ <tr>
298
+ <th scope="row"><?php _e( 'Email Address', 'companion-auto-update' );?></th>
299
+ <td>
300
+ <p>
301
+ <label for="cau_email"><?php _e( 'To', 'companion-auto-update' ); ?>:</label>
302
+ <input type="text" name="cau_email" id="cau_email" class="regular-text" placeholder="<?php echo get_option('admin_email'); ?>" value="<?php echo esc_html( $toemail ); ?>" />
303
+ </p>
304
+
305
+ <p class="description"><?php _e('Seperate email addresses using commas.', 'companion-auto-update');?></p>
306
+ </td>
307
+ </tr>
308
+ <tr>
309
+ <th scope="row"><?php _e( 'Use HTML in emails?', 'companion-auto-update' );?></th>
310
+ <td>
311
+ <p>
312
+ <select id='html_or_text' name='html_or_text'>
313
+ <option value='html' <?php if( cau_get_db_value( 'html_or_text' ) == 'html' ) { echo "SELECTED"; } ?>><?php _e( 'Use HTML', 'companion-auto-update' ); ?></option>
314
+ <option value='text' <?php if( cau_get_db_value( 'html_or_text' ) == 'text' ) { echo "SELECTED"; } ?>><?php _e( 'Use plain text', 'companion-auto-update' ); ?></option>
315
+ </select>
316
+ </p>
317
+ </td>
318
+ </tr>
319
+ <tr>
320
+ <th scope="row"><?php _e( 'Show more info in emails', 'companion-auto-update' );?></th>
321
+ <td>
322
+ <p>
323
+ <label for="advanced_info_emails"><input name="advanced_info_emails" type="checkbox" id="advanced_info_emails" <?php if( cau_get_db_value( 'advanced_info_emails' ) == 'on' ) { echo "CHECKED"; } ?>> <?php _e( 'Show the time of the update', 'companion-auto-update' ); ?></label>
324
+ </p>
325
+ <p>
326
+ <label for="plugin_links_emails"><input name="plugin_links_emails" type="checkbox" id="plugin_links_emails" <?php if( cau_get_db_value( 'plugin_links_emails' ) == 'on' ) { echo "CHECKED"; } ?>> <?php _e( 'Show links to WordPress.org pages', 'companion-auto-update' ); ?></label>
327
+ </p>
328
+ </td>
329
+ </tr>
330
+ <tr>
331
+ <th scope="row">
332
+ <?php _e( 'WordPress notifications', 'companion-auto-update' );?>
333
+ <span class='cau_tooltip'><span class="dashicons dashicons-editor-help"></span>
334
+ <span class='cau_tooltip_text'>
335
+ <?php _e( 'Core notifications are handled by WordPress and not by this plugin. You can only disable them, changing your email address in the settings above will not affect these notifications.', 'companion-auto-update' );?>
336
+ </span>
337
+ </span>
338
+ </th>
339
+ <td>
340
+ <p>
341
+ <input id="wpemails" name="wpemails" type="checkbox" <?php if( cau_get_db_value( 'wpemails' ) == 'on' ) { echo 'checked'; } ?> />
342
+ <label for="wpemails"><?php _e( 'By default WordPress sends an email when a core update has occurred. Uncheck this box to disable these emails.', 'companion-auto-update' ); ?></label>
343
+ </p>
344
+ </td>
345
+ </tr>
346
+ <tr>
347
+ <th scope="row"><?php _e( 'Database update required', 'companion-auto-update' );?></th>
348
+ <td>
349
+ <p>
350
+ <input id="dbupdateemails" name="dbupdateemails" type="checkbox" <?php if( cau_get_db_value( 'dbupdateemails' ) == 'on' ) { echo 'checked'; } ?> />
351
+ <label for="dbupdateemails"><?php _e( 'Sometimes we\'ll need your help updating our database version to the latest version, check this box to allow us to send you an email about this.', 'companion-auto-update' ); ?></label>
352
+ </p>
353
+ </td>
354
+ </tr>
355
+ </table>
356
+
357
+ </div>
358
+
359
+ <div class="welcome-to-cau interval-bg welcome-panel cau-dashboard-box" style="overflow: hidden;">
360
+
361
+ <h2 class="title"><?php _e( 'Intervals', 'companion-auto-update' );?></h2>
362
+
363
+ <?php
364
+
365
+ function cau_show_interval_selection( $identiefier, $schedule ) {
366
+
367
+ // Get the info
368
+ $setValue = wp_get_schedule( $schedule );
369
+ $setTime = wp_next_scheduled( $schedule );
370
+ $setHour = date( 'H' , $setTime );
371
+ $setMinutes = date( 'i' , $setTime );
372
+
373
+ // Show interval selection
374
+ echo "<p>";
375
+ echo "<select name='$identiefier' id='$identiefier' class='schedule_interval wide interval_scheduler' data-timeblock='$identiefier'>";
376
+ foreach ( cau_wp_get_schedules() as $key => $value ) {
377
+ echo "<option "; if( $setValue == $key ) { echo "selected "; } echo "value='".$key."'>".$value."</option>";
378
+ }
379
+ echo "</select>";
380
+ echo "</p>";
381
+
382
+ // Set the time when daily is selected
383
+ echo "<div class='timeblock-$identiefier' style='display: none;'>";
384
+
385
+ echo "<div class='cau_schedule_input'>
386
+ <input type='number' min='0' max='23' name='".$identiefier."-sethour' value='$setHour' maxlength='2' >
387
+ </div><div class='cau_schedule_input_div'>
388
+ :
389
+ </div><div class='cau_schedule_input'>
390
+ <input type='number' min='0' max='59' name='".$identiefier."-setminutes' value='$setMinutes' maxlength='2' >
391
+ </div><div class='cau_shedule_notation'>
392
+ <span class='cau_tooltip'><span class='dashicons dashicons-editor-help'></span>
393
+ <span class='cau_tooltip_text'>".__( 'At what time should the updater run? Only works when set to <u>daily</u>.', 'companion-auto-update' )." - ".__( 'Time notation: 24H', 'companion-auto-update' )."</span>
394
+ </span>
395
+ </div>";
396
+
397
+ echo "</div>";
398
+
399
+ }
400
+
401
+ ?>
402
+
403
+ <div class="welcome-column">
404
+
405
+ <h4><?php _e( 'Plugin update interval', 'companion-auto-update' );?></h4>
406
+ <?php cau_show_interval_selection( 'plugin_schedule', 'wp_update_plugins' ); ?>
407
+
408
+ </div>
409
+
410
+ <div class="welcome-column">
411
+
412
+ <h4><?php _e( 'Theme update interval', 'companion-auto-update' );?></h4>
413
+ <?php cau_show_interval_selection( 'theme_schedule', 'wp_update_themes' ); ?>
414
+
415
+ </div>
416
+
417
+ <div class="welcome-column">
418
+
419
+ <h4><?php _e( 'Core update interval', 'companion-auto-update' );?></h4>
420
+ <?php cau_show_interval_selection( 'core_schedule', 'wp_version_check' ); ?>
421
+
422
+ </div>
423
+
424
+ <p></p>
425
+
426
+ <div class="welcome-column">
427
+
428
+ <h4><?php _e( 'Update notifications', 'companion-auto-update' );?></h4>
429
+ <?php cau_show_interval_selection( 'update_notifications', 'cau_set_schedule_mail' ); ?>
430
+
431
+ </div>
432
+
433
+ <div class="welcome-column">
434
+
435
+ <h4><?php _e( 'Outdated software', 'companion-auto-update' );?></h4>
436
+ <?php cau_show_interval_selection( 'outdated_notifier', 'cau_outdated_notifier' ); ?>
437
+
438
+ </div>
439
+
440
+ </div>
441
+
442
+ <div class="welcome-to-cau advanced-bg welcome-panel cau-dashboard-box">
443
+
444
+ <h2 class="title"><?php _e( 'Advanced settings', 'companion-auto-update' ); ?></h2>
445
+
446
+ <table class="form-table">
447
+ <tbody>
448
+ <tr>
449
+ <th scope="row"><label><?php _e( 'Allow access to:', 'companion-auto-update' ); ?></label></th>
450
+ <td>
451
+ <p><label for="allow_administrator"><input name="allow_administrator" type="checkbox" id="allow_administrator" disabled="" checked=""><?php _e( 'Administrator', 'companion-auto-update' ); ?></label></p>
452
+ <p><label for="allow_editor"><input name="allow_editor" type="checkbox" id="allow_editor" <?php if( cau_get_db_value( 'allow_editor' ) == 'on' ) { echo "CHECKED"; } ?>><?php _e( 'Editor', 'companion-auto-update' ); ?></label></p>
453
+ <p><label for="allow_author"><input name="allow_author" type="checkbox" id="allow_author" <?php if( cau_get_db_value( 'allow_author' ) == 'on' ) { echo "CHECKED"; } ?>><?php _e( 'Author', 'companion-auto-update' ); ?></label></p>
454
+ </td>
455
+ </tr>
456
+ <tr>
457
+ <th scope="row"><label><?php _e( 'Delay updates', 'companion-auto-update' ); ?></label></th>
458
+ <td>
459
+ <p><label for="update_delay"><input name="update_delay" type="checkbox" id="update_delay" <?php if( cau_get_db_value( 'update_delay' ) == 'on' ) { echo "CHECKED"; } ?>><?php _e( 'Delay updates', 'companion-auto-update' ); ?></label></p>
460
+ </td>
461
+ </tr>
462
+ <tr id='update_delay_days_block' <?php if( cau_get_db_value( 'update_delay' ) != 'on' ) { echo "class='disabled_option'"; } ?>>
463
+ <th scope="row"><label><?php _e( 'Number of days', 'companion-auto-update' ); ?></label></th>
464
+ <td>
465
+ <input type="number" min="0" max="31" name="update_delay_days" id="update_delay_days" class="regular-text" value="<?php echo cau_get_db_value( 'update_delay_days' ); ?>" />
466
+ <p><?php _e( 'For how many days should updates be put on hold?', 'companion-auto-update' ); ?></p>
467
+ </td>
468
+ </tr>
469
+ </tbody>
470
+ </table>
471
+
472
+ </div>
473
+
474
+ <?php wp_nonce_field( 'cau_save_settings' ); ?>
475
+
476
+ <div class="cau_save_button">
477
+ <?php submit_button(); ?>
478
+ </div>
479
+ <div class="cau_save_button__space"></div>
480
+
481
+ <script>jQuery( '.cau-dashboard input, .cau-dashboard select, .cau-dashboard textarea' ).on( 'change', function() { jQuery('.cau_save_button').addClass( 'fixed_button' ); } );</script>
482
+
483
+ </form>
484
+
485
+ </div><div class="cau-column-small">
486
+
487
+ <div class="welcome-to-cau help-bg welcome-panel cau-dashboard-box">
488
+ <div class="welcome-column welcome-column.welcome-column-half">
489
+ <h3 class="support-sidebar-title"><?php _e( 'Help' ); ?></h3>
490
+ <ul class="support-sidebar-list">
491
+ <li><a href="https://codeermeneer.nl/stuffs/faq-auto-updater/" target="_blank"><?php _e( 'Frequently Asked Questions', 'companion-auto-update' ); ?></a></li>
492
+ <li><a href="https://wordpress.org/support/plugin/companion-auto-update" target="_blank"><?php _e( 'Support Forums' ); ?></a></li>
493
+ </ul>
494
+
495
+ <h3 class="support-sidebar-title"><?php _e( 'Want to contribute?', 'companion-auto-update' ); ?></h3>
496
+ <ul class="support-sidebar-list">
497
+ <li><a href="http://codeermeneer.nl/cau_poll/" target="_blank"><?php _e( 'Give feedback', 'companion-auto-update' ); ?></a></li>
498
+ <li><a href="https://codeermeneer.nl/blog/companion-auto-update-and-its-future/" target="_blank"><?php _e( 'Feature To-Do List', 'companion-auto-update' ); ?></a></li>
499
+ <li><a href="https://translate.wordpress.org/projects/wp-plugins/companion-auto-update/" target="_blank"><?php _e( 'Help us translate', 'companion-auto-update' ); ?></a></li>
500
+ </ul>
501
+ </div>
502
+ <div class="welcome-column welcome-column.welcome-column-half">
503
+ <h3 class="support-sidebar-title"><?php _e( 'Developer?', 'companion-auto-update' ); ?></h3>
504
+ <ul class="support-sidebar-list">
505
+ <li><a href="https://codeermeneer.nl/documentation/auto-update/" target="_blank"><?php _e( 'Documentation' ); ?></a></li>
506
+ </ul>
507
+ </div>
508
+ </div>
509
+
510
+ <div class="welcome-to-cau support-bg welcome-panel cau-dashboard-box">
511
+ <div class="welcome-column welcome-column">
512
+ <h3><?php _e('Support', 'companion-auto-update');?></h3>
513
+ <p><?php _e('Feel free to reach out to us if you have any questions or feedback.', 'companion-auto-update'); ?></p>
514
+ <p><a href="https://codeermeneer.nl/contact/" target="_blank" class="button button-primary"><?php _e( 'Contact us', 'companion-auto-update' ); ?></a></p>
515
+ <p><a href="https://codeermeneer.nl/plugins/" target="_blank" class="button button-alt"><?php _e('Check out our other plugins', 'companion-auto-update');?></a></p>
516
+ </div>
517
+ </div>
518
+
519
+ <div class="welcome-to-cau love-bg cau-show-love welcome-panel cau-dashboard-box">
520
+ <h3><?php _e( 'Like our plugin?', 'companion-auto-update' ); ?></h3>
521
+ <p><?php _e('Companion Auto Update is free to use. It has required a great deal of time and effort to develop and you can help support this development by making a small donation.<br />You get useful software and we get to carry on making it better.', 'companion-auto-update'); ?></p>
522
+ <a href="https://wordpress.org/support/plugin/companion-auto-update/reviews/#new-post" target="_blank" class="button button-alt button-hero">
523
+ <?php _e('Rate us (5 stars?)', 'companion-auto-update'); ?>
524
+ </a>
525
+ <a href="<?php echo cau_donateUrl(); ?>" target="_blank" class="button button-primary button-hero">
526
+ <?php _e('Donate to help development', 'companion-auto-update'); ?>
527
+ </a>
528
+ <p style="font-size: 12px; color: #BDBDBD;"><?php _e( 'Donations via PayPal. Amount can be changed.', 'companion-auto-update'); ?></p>
529
+ </div>
530
+
531
+ <div class="welcome-to-cau welcome-panel cau-dashboard-box">
532
+ <h3><span style='background: #EBE3F7; color: #BCADD3; padding: 1px 5px; border-radius: 3px; font-size: .8em'>Plugin Promotion</span></h3>
533
+ <h3>Keep your site fast with our Revision Manager</h3>
534
+ <p>Post Revisions are great, but will also slow down your site. Take back control over revisions with Companion Revision Manager!</p>
535
+ <a href="https://codeermeneer.nl/portfolio/plugin/companion-revision-manager/" target="_blank" class="button button-alt">Read more</a>
536
+ </div>
537
+
538
+ </div>
539
+
540
+ <style>
541
+ .disabled_option {
542
+ opacity: .5;
543
+ }
544
+ </style>
545
+
546
+ <script type="text/javascript">
547
+
548
+ jQuery( '#update_delay' ).change( function() {
549
+ jQuery( '#update_delay_days_block' ).toggleClass( 'disabled_option' );
550
+ });
551
+
552
+ jQuery( '.interval_scheduler' ).change( function() {
553
+
554
+ var selected = jQuery(this).val(); // Selected value
555
+ var timeblock = jQuery(this).data( 'timeblock' ); // Corresponding time block
556
+
557
+ if( selected == 'daily' ) {
558
+ jQuery( '.timeblock-'+timeblock ).show();
559
+ } else {
560
+ jQuery( '.timeblock-'+timeblock ).hide();
561
+ }
562
+
563
+ });
564
+
565
+ jQuery( '.interval_scheduler' ).each( function() {
566
+
567
+ var selected = jQuery(this).val(); // Selected value
568
+ var timeblock = jQuery(this).data( 'timeblock' ); // Corresponding time block
569
+
570
+ if( selected == 'daily' ) {
571
+ jQuery( '.timeblock-'+timeblock ).show();
572
+ } else {
573
+ jQuery( '.timeblock-'+timeblock ).hide();
574
+ }
575
+
576
+ });
577
+
578
  </script>
admin/log.php CHANGED
@@ -1,19 +1,19 @@
1
- <?php
2
- if( isset( $_GET['filter'] ) ) {
3
- $filter = $_GET['filter'];
4
- } else {
5
- $filter = 'all';
6
- }
7
- ?>
8
-
9
- <ul class="subsubsub">
10
- <li><a <?php if( $filter == 'all' ) { echo "class='current'"; } ?> href='<?php echo cau_url( 'log&filter=all' ); ?>'><?php _e( 'View full changelog', 'companion-auto-update' ); ?></a></li> |
11
- <li><a <?php if( $filter == 'plugins' ) { echo "class='current'"; } ?> href='<?php echo cau_url( 'log&filter=plugins' ); ?>'><?php _e( 'Plugins', 'companion-auto-update' ); ?></a></li> |
12
- <li><a <?php if( $filter == 'themes' ) { echo "class='current'"; } ?> href='<?php echo cau_url( 'log&filter=themes' ); ?>'><?php _e( 'Themes', 'companion-auto-update' ); ?></a></li> |
13
- <li><a <?php if( $filter == 'translations' ) { echo "class='current'"; } ?> href='<?php echo cau_url( 'log&filter=translations' ); ?>'><?php _e( 'Translations', 'companion-auto-update' ); ?></a></li>
14
- </ul>
15
-
16
- <div class='cau_spacing'></div>
17
-
18
- <?php
19
  cau_fetch_log( 'all', 'table' );
1
+ <?php
2
+ if( isset( $_GET['filter'] ) ) {
3
+ $filter = $_GET['filter'];
4
+ } else {
5
+ $filter = 'all';
6
+ }
7
+ ?>
8
+
9
+ <ul class="subsubsub">
10
+ <li><a <?php if( $filter == 'all' ) { echo "class='current'"; } ?> href='<?php echo cau_url( 'log&filter=all' ); ?>'><?php _e( 'View full changelog', 'companion-auto-update' ); ?></a></li> |
11
+ <li><a <?php if( $filter == 'plugins' ) { echo "class='current'"; } ?> href='<?php echo cau_url( 'log&filter=plugins' ); ?>'><?php _e( 'Plugins', 'companion-auto-update' ); ?></a></li> |
12
+ <li><a <?php if( $filter == 'themes' ) { echo "class='current'"; } ?> href='<?php echo cau_url( 'log&filter=themes' ); ?>'><?php _e( 'Themes', 'companion-auto-update' ); ?></a></li> |
13
+ <li><a <?php if( $filter == 'translations' ) { echo "class='current'"; } ?> href='<?php echo cau_url( 'log&filter=translations' ); ?>'><?php _e( 'Translations', 'companion-auto-update' ); ?></a></li>
14
+ </ul>
15
+
16
+ <div class='cau_spacing'></div>
17
+
18
+ <?php
19
  cau_fetch_log( 'all', 'table' );
admin/pluginlist.php CHANGED
@@ -1,185 +1,185 @@
1
- <?php
2
-
3
- // Get selected filter type
4
- if( isset( $_GET['filter'] ) ) {
5
- $filter = sanitize_key( $_GET['filter'] );
6
- } else {
7
- $filter = 'plugins';
8
- }
9
-
10
- // Select correct database row
11
- switch ( $filter ) {
12
- case 'themes':
13
- $db_table = 'notUpdateListTh';
14
- $filter_name = __( 'Themes', 'companion-auto-update' );
15
- $filterFunction = wp_get_themes();
16
- break;
17
- case 'plugins':
18
- $db_table = 'notUpdateList';
19
- $filter_name = __( 'Plugins', 'companion-auto-update' );
20
- $filterFunction = get_plugins();
21
- break;
22
- default:
23
- $db_table = 'notUpdateList';
24
- $filter_name = __( 'Plugins', 'companion-auto-update' );
25
- $filterFunction = get_plugins();
26
- break;
27
- }
28
-
29
- ?>
30
-
31
- <ul class="subsubsub">
32
- <li><a <?php if( $filter == 'plugins' ) { echo "class='current'"; } ?> href='<?php echo cau_url( 'pluginlist&filter=plugins' ); ?>'><?php _e( 'Plugins', 'companion-auto-update' ); ?></a></li> |
33
- <li><a <?php if( $filter == 'themes' ) { echo "class='current'"; } ?> href='<?php echo cau_url( 'pluginlist&filter=themes' ); ?>'><?php _e( 'Themes', 'companion-auto-update' ); ?></a></li>
34
- </ul>
35
-
36
- <div style='clear: both;'></div>
37
-
38
- <?php if( $filter == 'themes' ) { ?>
39
- <div id="message" class="cau">
40
- We've had to (temporarily) disable the theme filter because it was causing issues on some installations. We'll try to get it working again in a future update.
41
- </div>
42
- <?php } ?>
43
-
44
- <p><?php echo sprintf( esc_html__( 'Prevent certain %s from updating automatically. %s that you select here will be skipped by Companion Auto Update and will require manual updating.', 'companion-auto-update' ), strtolower( $filter_name ), $filter_name ); ?></p>
45
-
46
- <?php
47
-
48
- global $wpdb;
49
- $table_name = $wpdb->prefix."auto_updates";
50
-
51
- // Save list
52
- if( isset( $_POST['submit'] ) ) {
53
-
54
- check_admin_referer( 'cau_save_pluginlist' );
55
-
56
- $noUpdateList = '';
57
- $i = 0;
58
- $noUpdateCount = 0;
59
-
60
- if( isset( $_POST['post'] ) ) {
61
- $noUpdateCount = count( $_POST['post'] );
62
- }
63
-
64
- if( $noUpdateCount > 0 ) {
65
- foreach ( $_POST['post'] as $key ) {
66
- $noUpdateList .= sanitize_text_field( $key );
67
- $i++;
68
- if( $i != $noUpdateCount ) $noUpdateList .= ', ';
69
- }
70
- }
71
-
72
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = '%s' WHERE name = '%s'", $noUpdateList, $db_table ) );
73
- echo '<div id="message" class="updated"><p><b>'.__( 'Succes', 'companion-auto-update' ).' &ndash;</b> '.sprintf( esc_html__( '%1$s %2$s have been added to the no-update-list', 'companion-auto-update' ), $noUpdateCount, strtolower( $filter_name ) ).'.</p></div>';
74
- }
75
-
76
-
77
- // Reset list
78
- if( isset( $_POST['reset'] ) ) {
79
-
80
- check_admin_referer( 'cau_save_pluginlist' );
81
-
82
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = '%s' WHERE name = %s", "", $db_table ) );
83
- echo '<div id="message" class="updated"><p><b>'.__( 'Succes', 'companion-auto-update' ).' &ndash;</b> '.sprintf( esc_html__( 'The no-update-list has been reset, all %s will be auto-updated from now on', 'companion-auto-update' ), strtolower( $filter_name ) ).'.</p></div>';
84
- }
85
-
86
-
87
- ?>
88
-
89
- <form method="POST">
90
-
91
- <div class='pluginListButtons'>
92
- <?php submit_button(); ?>
93
- <input type='submit' name='reset' id='reset' class='button button-alt' value='<?php _e( "Reset list", "companion-auto-update" ); ?>'>
94
- </div>
95
-
96
- <table class="wp-list-table widefat autoupdate striped">
97
- <thead>
98
- <tr>
99
- <td>&nbsp;</td>
100
- <th class="head-plugin"><strong><?php _e( 'Name', 'companion-auto-update' ); ?></strong></th>
101
- <th class="head-status"><strong><?php _e( 'Status', 'companion-auto-update' ); ?></strong></th>
102
- <th class="head-description"><strong><?php _e( 'Description' ); ?></strong></th>
103
- </tr>
104
- </thead>
105
-
106
- <tbody id="the-list">
107
-
108
- <?php
109
-
110
- foreach ( $filterFunction as $key => $value ) {
111
-
112
- $slug = $key;
113
- $explosion = explode( '/', $slug );
114
- $actualSlug = array_shift( $explosion );
115
- $slug_hash = md5( $slug[0] );
116
-
117
- if( $filter == 'themes' ) {
118
-
119
- $theme = wp_get_theme( $actualSlug );
120
- $name = $theme->get( 'Name' );
121
- $description = $theme->get( 'Description' );
122
-
123
- } else {
124
-
125
- foreach ( $value as $k => $v ) {
126
-
127
- if( $k == "Name" ) $name = $v;
128
- if( $k == "Description" ) $description = $v;
129
-
130
- }
131
-
132
- }
133
-
134
- if( in_array( $actualSlug, donotupdatelist( $filter ) ) ) {
135
-
136
- $class = 'inactive';
137
- $checked = 'CHECKED';
138
- $statusicon = 'no';
139
- $statusName = 'disabled';
140
-
141
- } else {
142
-
143
- $class = 'active';
144
- $checked = '';
145
- $statusicon = 'yes';
146
- $statusName = 'enabled';
147
- }
148
-
149
- echo '<tr id="post-'.$slug_hash.'" class="'.$class.'">
150
-
151
- <th class="check-column">
152
- <label class="screen-reader-text" for="cb-select-'.$slug_hash.'">Select '. $name .'</label>
153
- <input id="cb-select-'.$slug_hash.'" type="checkbox" name="post[]" value="'.$actualSlug.'" '.$checked.' ><label></label>
154
- <div class="locked-indicator"></div>
155
- </th>
156
-
157
- <td class="column-name">
158
- <p style="margin-bottom: 0px;"><strong>'. $name .'</strong></p>
159
- <small class="description" style="opacity: 0.5; margin-bottom: 3px;">'.$actualSlug.'</small>
160
- </td>
161
-
162
- <td class="cau_hide_on_mobile column-status">
163
- <p><span class="nowrap">'.__( 'Auto Updater', 'companion-auto-update' ).': <span class="cau_'.$statusName.'"><span class="dashicons dashicons-'.$statusicon.'"></span></span></span></p>
164
- </td>
165
-
166
- <td class="cau_hide_on_mobile column-description">
167
- <p>'.$description.'</p>
168
- </td>
169
-
170
- </tr>';
171
-
172
- }
173
- ?>
174
-
175
- </tbody>
176
- </table>
177
-
178
- <?php wp_nonce_field( 'cau_save_pluginlist' ); ?>
179
-
180
- <div class='pluginListButtons'>
181
- <?php submit_button(); ?>
182
- <input type='submit' name='reset' id='reset' class='button button-alt' value='<?php _e( "Reset list", "companion-auto-update" ); ?>'>
183
- </div>
184
-
185
  </form>
1
+ <?php
2
+
3
+ // Get selected filter type
4
+ if( isset( $_GET['filter'] ) ) {
5
+ $filter = sanitize_key( $_GET['filter'] );
6
+ } else {
7
+ $filter = 'plugins';
8
+ }
9
+
10
+ // Select correct database row
11
+ switch ( $filter ) {
12
+ case 'themes':
13
+ $db_table = 'notUpdateListTh';
14
+ $filter_name = __( 'Themes', 'companion-auto-update' );
15
+ $filterFunction = wp_get_themes();
16
+ break;
17
+ case 'plugins':
18
+ $db_table = 'notUpdateList';
19
+ $filter_name = __( 'Plugins', 'companion-auto-update' );
20
+ $filterFunction = get_plugins();
21
+ break;
22
+ default:
23
+ $db_table = 'notUpdateList';
24
+ $filter_name = __( 'Plugins', 'companion-auto-update' );
25
+ $filterFunction = get_plugins();
26
+ break;
27
+ }
28
+
29
+ ?>
30
+
31
+ <ul class="subsubsub">
32
+ <li><a <?php if( $filter == 'plugins' ) { echo "class='current'"; } ?> href='<?php echo cau_url( 'pluginlist&filter=plugins' ); ?>'><?php _e( 'Plugins', 'companion-auto-update' ); ?></a></li> |
33
+ <li><a <?php if( $filter == 'themes' ) { echo "class='current'"; } ?> href='<?php echo cau_url( 'pluginlist&filter=themes' ); ?>'><?php _e( 'Themes', 'companion-auto-update' ); ?></a></li>
34
+ </ul>
35
+
36
+ <div style='clear: both;'></div>
37
+
38
+ <?php if( $filter == 'themes' ) { ?>
39
+ <div id="message" class="cau">
40
+ We've had to (temporarily) disable the theme filter because it was causing issues on some installations. We'll try to get it working again in a future update.
41
+ </div>
42
+ <?php } ?>
43
+
44
+ <p><?php echo sprintf( esc_html__( 'Prevent certain %s from updating automatically. %s that you select here will be skipped by Companion Auto Update and will require manual updating.', 'companion-auto-update' ), strtolower( $filter_name ), $filter_name ); ?></p>
45
+
46
+ <?php
47
+
48
+ global $wpdb;
49
+ $table_name = $wpdb->prefix."auto_updates";
50
+
51
+ // Save list
52
+ if( isset( $_POST['submit'] ) ) {
53
+
54
+ check_admin_referer( 'cau_save_pluginlist' );
55
+
56
+ $noUpdateList = '';
57
+ $i = 0;
58
+ $noUpdateCount = 0;
59
+
60
+ if( isset( $_POST['post'] ) ) {
61
+ $noUpdateCount = count( $_POST['post'] );
62
+ }
63
+
64
+ if( $noUpdateCount > 0 ) {
65
+ foreach ( $_POST['post'] as $key ) {
66
+ $noUpdateList .= sanitize_text_field( $key );
67
+ $i++;
68
+ if( $i != $noUpdateCount ) $noUpdateList .= ', ';
69
+ }
70
+ }
71
+
72
+ $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = '%s' WHERE name = '%s'", $noUpdateList, $db_table ) );
73
+ echo '<div id="message" class="updated"><p><b>'.__( 'Succes', 'companion-auto-update' ).' &ndash;</b> '.sprintf( esc_html__( '%1$s %2$s have been added to the no-update-list', 'companion-auto-update' ), $noUpdateCount, strtolower( $filter_name ) ).'.</p></div>';
74
+ }
75
+
76
+
77
+ // Reset list
78
+ if( isset( $_POST['reset'] ) ) {
79
+
80
+ check_admin_referer( 'cau_save_pluginlist' );
81
+
82
+ $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = '%s' WHERE name = %s", "", $db_table ) );
83
+ echo '<div id="message" class="updated"><p><b>'.__( 'Succes', 'companion-auto-update' ).' &ndash;</b> '.sprintf( esc_html__( 'The no-update-list has been reset, all %s will be auto-updated from now on', 'companion-auto-update' ), strtolower( $filter_name ) ).'.</p></div>';
84
+ }
85
+
86
+
87
+ ?>
88
+
89
+ <form method="POST">
90
+
91
+ <div class='pluginListButtons'>
92
+ <?php submit_button(); ?>
93
+ <input type='submit' name='reset' id='reset' class='button button-alt' value='<?php _e( "Reset list", "companion-auto-update" ); ?>'>
94
+ </div>
95
+
96
+ <table class="wp-list-table widefat autoupdate striped">
97
+ <thead>
98
+ <tr>
99
+ <td>&nbsp;</td>
100
+ <th class="head-plugin"><strong><?php _e( 'Name', 'companion-auto-update' ); ?></strong></th>
101
+ <th class="head-status"><strong><?php _e( 'Status', 'companion-auto-update' ); ?></strong></th>
102
+ <th class="head-description"><strong><?php _e( 'Description' ); ?></strong></th>
103
+ </tr>
104
+ </thead>
105
+
106
+ <tbody id="the-list">
107
+
108
+ <?php
109
+
110
+ foreach ( $filterFunction as $key => $value ) {
111
+
112
+ $slug = $key;
113
+ $explosion = explode( '/', $slug );
114
+ $actualSlug = array_shift( $explosion );
115
+ $slug_hash = md5( $slug[0] );
116
+
117
+ if( $filter == 'themes' ) {
118
+
119
+ $theme = wp_get_theme( $actualSlug );
120
+ $name = $theme->get( 'Name' );
121
+ $description = $theme->get( 'Description' );
122
+
123
+ } else {
124
+
125
+ foreach ( $value as $k => $v ) {
126
+
127
+ if( $k == "Name" ) $name = $v;
128
+ if( $k == "Description" ) $description = $v;
129
+
130
+ }
131
+
132
+ }
133
+
134
+ if( in_array( $actualSlug, donotupdatelist( $filter ) ) ) {
135
+
136
+ $class = 'inactive';
137
+ $checked = 'CHECKED';
138
+ $statusicon = 'no';
139
+ $statusName = 'disabled';
140
+
141
+ } else {
142
+
143
+ $class = 'active';
144
+ $checked = '';
145
+ $statusicon = 'yes';
146
+ $statusName = 'enabled';
147
+ }
148
+
149
+ echo '<tr id="post-'.$slug_hash.'" class="'.$class.'">
150
+
151
+ <th class="check-column">
152
+ <label class="screen-reader-text" for="cb-select-'.$slug_hash.'">Select '. $name .'</label>
153
+ <input id="cb-select-'.$slug_hash.'" type="checkbox" name="post[]" value="'.$actualSlug.'" '.$checked.' ><label></label>
154
+ <div class="locked-indicator"></div>
155
+ </th>
156
+
157
+ <td class="column-name">
158
+ <p style="margin-bottom: 0px;"><strong>'. $name .'</strong></p>
159
+ <small class="description" style="opacity: 0.5; margin-bottom: 3px;">'.$actualSlug.'</small>
160
+ </td>
161
+
162
+ <td class="cau_hide_on_mobile column-status">
163
+ <p><span class="nowrap">'.__( 'Auto Updater', 'companion-auto-update' ).': <span class="cau_'.$statusName.'"><span class="dashicons dashicons-'.$statusicon.'"></span></span></span></p>
164
+ </td>
165
+
166
+ <td class="cau_hide_on_mobile column-description">
167
+ <p>'.$description.'</p>
168
+ </td>
169
+
170
+ </tr>';
171
+
172
+ }
173
+ ?>
174
+
175
+ </tbody>
176
+ </table>
177
+
178
+ <?php wp_nonce_field( 'cau_save_pluginlist' ); ?>
179
+
180
+ <div class='pluginListButtons'>
181
+ <?php submit_button(); ?>
182
+ <input type='submit' name='reset' id='reset' class='button button-alt' value='<?php _e( "Reset list", "companion-auto-update" ); ?>'>
183
+ </div>
184
+
185
  </form>
admin/rollback.php CHANGED
@@ -1,2 +1,2 @@
1
- <?php
2
- // Currently working on this
1
+ <?php
2
+ // Currently working on this
admin/status.php CHANGED
@@ -1,405 +1,405 @@
1
- <?php
2
-
3
- // Update the database
4
- if( isset( $_GET['run'] ) && $_GET['run'] == 'db_update' ) {
5
- cau_manual_update();
6
- echo '<div id="message" class="updated"><p><b>'.__( 'Database update completed' ).'</b></p></div>';
7
- }
8
-
9
- if( isset( $_GET['run'] ) && $_GET['run'] == 'db_info_update' ) {
10
- cau_savePluginInformation();
11
- echo '<div id="message" class="updated"><p><b>'.__( 'Database information update completed' ).'</b></p></div>';
12
- }
13
-
14
- if( isset( $_GET['ignore_report'] ) ) {
15
-
16
- $report_to_ignore = sanitize_text_field( $_GET['ignore_report'] );
17
- $allowedValues = array( 'seo', 'cron' );
18
-
19
- if( !in_array( $report_to_ignore, $allowedValues ) ) {
20
- wp_die( 'Trying to cheat eh?' );
21
- } else {
22
- global $wpdb;
23
- $table_name = $wpdb->prefix . "auto_updates";
24
- $wpdb->query( $wpdb->prepare( "UPDATE {$table_name} SET onoroff = %s WHERE name = 'ignore_$report_to_ignore'", 'yes' ) );
25
- $__ignored = __( 'This report will now be ignored', 'companion-auto-update' );
26
- echo "<div id='message' class='updated'><p><b>$__ignored</b></p></div>";
27
- }
28
-
29
- }
30
-
31
-
32
-
33
- // Variables
34
- $dateFormat = get_option( 'date_format' );
35
- $dateFormat .= ' '.get_option( 'time_format' );
36
- global $wpdb;
37
- $table_name = $wpdb->prefix . "auto_updates";
38
- $schedules = wp_get_schedules();
39
- $interval_names = cau_wp_get_schedules();
40
-
41
- ?>
42
-
43
- <div class="cau_status_page">
44
-
45
- <table class="cau_status_list widefat striped">
46
-
47
- <thead>
48
- <tr>
49
- <th class="cau_status_name"><strong><?php _e( 'Auto Updater', 'companion-auto-update' ); ?></strong></th>
50
- <th class="cau_status_active_state"><strong><?php _e( 'Status', 'companion-auto-update' ); ?></strong></th>
51
- <th class="cau_status_interval"><strong><?php _e( 'Interval', 'companion-auto-update' ); ?></strong></th>
52
- <th class="cau_status_next"><strong><?php _e( 'Next', 'companion-auto-update' ); ?></strong></th>
53
- </tr>
54
- </thead>
55
-
56
- <tbody id="the-list">
57
- <?php
58
-
59
- $auto_updaters = array(
60
- 'plugins' => __( 'Plugins', 'companion-auto-update' ),
61
- 'themes' => __( 'Themes', 'companion-auto-update' ),
62
- 'minor' => __( 'Core (Minor)', 'companion-auto-update' ),
63
- 'major' => __( 'Core (Major)', 'companion-auto-update' )
64
- );
65
-
66
- $eventNames = array(
67
- 'plugins' => 'wp_update_plugins',
68
- 'themes' => 'wp_update_themes',
69
- 'minor' => 'wp_version_check',
70
- 'major' => 'wp_version_check'
71
- );
72
-
73
- foreach ( $auto_updaters as $key => $value ) {
74
-
75
- if( cau_get_db_value( $key ) == 'on' ) {
76
- $__status = 'enabled';
77
- $__icon = 'yes-alt';
78
- $__text = __( 'Enabled', 'companion-auto-update' );
79
- $__interval = $interval_names[wp_get_schedule( $eventNames[$key] )];
80
- $__next = date_i18n( $dateFormat, wp_next_scheduled( $eventNames[$key] ) );
81
- } else {
82
- $__status = 'disabled';
83
- $__icon = 'marker';
84
- $__text = __( 'Disabled', 'companion-auto-update' );
85
- $__interval = '&dash;';
86
- $__next = '&dash;';
87
- }
88
-
89
- $__nxt = __( 'Next', 'companion-auto-update' );
90
-
91
- echo "<tr>
92
- <td class='cau_status_name'>$value</td>
93
- <td class='cau_status_active_state'><span class='cau_$__status'><span class='dashicons dashicons-$__icon'></span> $__text</span></td>
94
- <td class='cau_status_interval'>$__interval</td>
95
- <td class='cau_status_next'><span class='cau_mobile_prefix'>$__nxt: </span>$__next</td>
96
- </tr>";
97
- }
98
-
99
- ?>
100
- </tbody>
101
-
102
- </table>
103
-
104
- <table class="cau_status_list widefat striped">
105
-
106
- <thead>
107
- <tr>
108
- <th class="cau_status_name"><strong><?php _e( 'Email Notifications', 'companion-auto-update' ); ?></strong></th>
109
- <th class="cau_status_active_state"><strong><?php _e( 'Status', 'companion-auto-update' ); ?></strong></th>
110
- <th class="cau_status_interval"><strong><?php _e( 'Interval', 'companion-auto-update' ); ?></strong></th>
111
- <th class="cau_status_next"><strong><?php _e( 'Next', 'companion-auto-update' ); ?></strong></th>
112
- </tr>
113
- </thead>
114
-
115
- <tbody id="the-list">
116
- <?php
117
-
118
- $other_events = array(
119
- 'send' => __( 'Update available', 'companion-auto-update' ),
120
- 'sendupdate' => __( 'Successful update', 'companion-auto-update' ),
121
- 'wpemails' => __( 'Core notifications', 'companion-auto-update' )
122
- );
123
-
124
- $other_eventNames = array(
125
- 'send' => 'cau_set_schedule_mail',
126
- 'sendupdate' => 'cau_set_schedule_mail',
127
- 'wpemails' => 'cau_set_schedule_mail',
128
- );
129
-
130
- foreach ( $other_events as $key => $value ) {
131
-
132
- if( cau_get_db_value( $key ) == 'on' ) {
133
- $__status = 'enabled';
134
- $__icon = 'yes-alt';
135
- $__text = __( 'Enabled', 'companion-auto-update' );
136
- $__interval = $interval_names[wp_get_schedule( $other_eventNames[$key] )];
137
- $__next = date_i18n( $dateFormat, wp_next_scheduled( $other_eventNames[$key] ) );
138
- } else {
139
- $__status = 'warning';
140
- $__icon = 'marker';
141
- $__text = __( 'Disabled', 'companion-auto-update' );
142
- $__interval = '&dash;';
143
- $__next = '&dash;';
144
- }
145
-
146
- $__nxt = __( 'Next', 'companion-auto-update' );
147
-
148
- echo "<tr>
149
- <td class='cau_status_name'>$value</td>
150
- <td class='cau_status_active_state'><span class='cau_$__status'><span class='dashicons dashicons-$__icon'></span> $__text</span></td>
151
- <td class='cau_status_interval'>$__interval</td>
152
- <td class='cau_status_next'><span class='cau_mobile_prefix'>$__nxt: </span>$__next</td>
153
- </tr>";
154
- }
155
-
156
- ?>
157
- </tbody>
158
-
159
- </table>
160
-
161
- <table class="cau_status_list widefat striped cau_status_warnings">
162
-
163
- <thead>
164
- <tr>
165
- <th class="cau_plugin_issue_name" colspan="4"><strong><?php _e( 'Status' ); ?></strong></th>
166
- </tr>
167
- </thead>
168
-
169
- <tbody id="the-list">
170
-
171
- <tr>
172
- <td><?php _e( 'Auto updates', 'companion-auto-update' ); ?></td>
173
- <?php if ( checkAutomaticUpdaterDisabled() ) { ?>
174
- <td class="cau_status_active_state"><span class='cau_disabled'><span class="dashicons dashicons-no"></span> <?php _e( 'All automatic updates are disabled', 'companion-auto-update' ); ?></span></td>
175
- <td>
176
- <form method="POST">
177
- <?php wp_nonce_field( 'cau_fixit' ); ?>
178
- <button type="submit" name="fixit" class="button button-primary"><?php _e( 'Fix it', 'companion-auto-update' ); ?></button>
179
- <a href="https://codeermeneer.nl/documentation/known-issues-fixes/#updates_disabled" target="_blank" class="button"><?php _e( 'How to fix this', 'companion-auto-update' ); ?></a>
180
- </form>
181
- </td>
182
- <?php } else { ?>
183
- <td class="cau_status_active_state"><span class='cau_enabled'><span class="dashicons dashicons-yes-alt"></span> <?php _e( 'No issues detected', 'companion-auto-update' ); ?></span></td>
184
- <td></td>
185
- <?php } ?>
186
- <td></td>
187
- </tr>
188
-
189
- <tr>
190
- <td><?php _e( 'Connection with WordPress.org', 'companion-auto-update' ); ?></td>
191
- <?php if( wp_http_supports( array( 'ssl' ) ) == '1' ) {
192
- $__text = __( 'No issues detected', 'companion-auto-update' );
193
- echo "<td colspan='3' class='cau_status_active_state'><span class='cau_enabled'><span class='dashicons dashicons-yes-alt'></span> $__text</span></td>";
194
- } else {
195
- $__text = __( 'Disabled', 'companion-auto-update' );
196
- echo "<td colspan='3' class='cau_status_active_state'><span class='cau_disabled'><span class='dashicons dashicons-no'></span> $__text</span></td>";
197
- } ?>
198
- </tr>
199
-
200
- <tr <?php if( cau_get_db_value( 'ignore_seo' ) == 'yes' ) { echo "class='report_hidden'"; } ?> >
201
- <td><?php _e( 'Search Engine Visibility', 'companion-auto-update' ); ?></td>
202
- <?php if( get_option( 'blog_public' ) == 0 ) { ?>
203
- <td colspan="2" class="cau_status_active_state">
204
- <span class='cau_warning'><span class="dashicons dashicons-warning"></span></span>
205
- <?php _e( 'You’ve chosen to discourage Search Engines from indexing your site. Auto-updating works best on sites with more traffic, consider enabling indexing for your site.', 'companion-auto-update' ); ?>
206
- </td>
207
- <td>
208
- <a href="<?php echo admin_url( 'options-reading.php' ); ?>" class="button"><?php _e( 'Fix it', 'companion-auto-update' ); ?></a>
209
- <a href="<?php echo cau_url( 'status' ); ?>&ignore_report=seo" class="button button-alt"><?php _e( 'Ignore this report', 'companion-auto-update' ); ?></a>
210
- </td>
211
- <?php } else { ?>
212
- <td colspan="3" class="cau_status_active_state"><span class='cau_enabled'><span class="dashicons dashicons-yes-alt"></span> <?php _e( 'No issues detected', 'companion-auto-update' ); ?></span></td>
213
- <?php } ?>
214
- </tr>
215
-
216
- <tr <?php if( cau_get_db_value( 'ignore_cron' ) == 'yes' ) { echo "class='report_hidden'"; } ?> >
217
- <td><?php _e( 'Cronjobs', 'companion-auto-update' ); ?></td>
218
- <?php if( checkCronjobsDisabled() ) { ?>
219
- <td class="cau_status_active_state"><span class='cau_warning'><span class="dashicons dashicons-warning"></span> <?php _e( 'Disabled', 'companion-auto-update' ); ?></span></td>
220
- <td><code>DISABLE_WP_CRON true</code></td>
221
- <td>
222
- <a href="https://codeermeneer.nl/contact/" class="button"><?php _e( 'Contact for support', 'companion-auto-update' ); ?></a>
223
- <a href="<?php echo cau_url( 'status' ); ?>&ignore_report=cron" class="button button-alt"><?php _e( 'Ignore this report', 'companion-auto-update' ); ?></a>
224
- </td>
225
- <?php } else { ?>
226
- <td colspan="3" class="cau_status_active_state"><span class='cau_enabled'><span class="dashicons dashicons-yes-alt"></span> <?php _e( 'No issues detected', 'companion-auto-update' ); ?></span></td>
227
- <?php } ?>
228
- </tr>
229
-
230
- <tr>
231
- <td>wp_version_check</td>
232
- <?php if ( !has_filter( 'wp_version_check', 'wp_version_check' ) ) { ?>
233
- <td colspan="2" class="cau_status_active_state"><span class='cau_disabled'><span class="dashicons dashicons-no"></span> <?php _e( 'A plugin has prevented updates by disabling wp_version_check', 'companion-auto-update' ); ?></span></td>
234
- <td><a href="https://codeermeneer.nl/contact/" class="button"><?php _e( 'Contact for support', 'companion-auto-update' ); ?></a></td>
235
- <?php } else { ?>
236
- <td colspan="3" class="cau_status_active_state"><span class='cau_enabled'><span class="dashicons dashicons-yes-alt"></span> <?php _e( 'No issues detected' , 'companion-auto-update' ); ?></span></td>
237
- <?php } ?>
238
- </tr>
239
-
240
- <tr>
241
- <td>VCS</td>
242
- <td colspan="3" class="cau_status_active_state"><span class='cau_<?php echo cau_test_is_vcs_checkout( ABSPATH )['status']; ?>'><span class="dashicons dashicons-<?php echo cau_test_is_vcs_checkout( ABSPATH )['icon']; ?>"></span> <?php echo cau_test_is_vcs_checkout( ABSPATH )['description']; ?></span></td>
243
- </tr>
244
-
245
- </tbody>
246
-
247
- </table>
248
-
249
- <table class="autoupdate cau_status_list widefat striped cau_status_warnings">
250
-
251
- <thead>
252
- <tr>
253
- <th colspan="4"><strong><?php _e( 'Systeminfo', 'companion-auto-update' ); ?></strong></th>
254
- </tr>
255
- </thead>
256
-
257
- <tbody id="the-list">
258
- <tr>
259
- <td>WordPress</td>
260
- <td><?php echo get_bloginfo( 'version' ); ?></td>
261
- <td></td>
262
- <td></td>
263
- </tr>
264
- <tr>
265
- <td>PHP</td>
266
- <td><?php echo phpversion(); ?></td>
267
- <td></td>
268
- <td></td>
269
- </tr>
270
- <tr <?php if( cau_incorrectDatabaseVersion() ) { echo "class='inactive'"; } ?>>
271
- <td>Database</td>
272
- <td><?php echo get_option( "cau_db_version" ); ?> <code>(Latest: <?php echo cau_db_version(); ?>)</code></td>
273
- <td></td>
274
- <td></td>
275
- </tr>
276
- <tr>
277
- <td class="cau_status_name"><?php _e( 'Timezone' ); ?></td>
278
- <td class="cau_status_active_state"><?php echo cau_get_proper_timezone(); ?> (GMT <?php echo get_option('gmt_offset'); ?>) - <?php echo date_default_timezone_get(); ?></td>
279
- <td></td>
280
- <td></td>
281
- </tr>
282
- </tbody>
283
-
284
- </table>
285
-
286
- <?php
287
- // If has incomptable plugins
288
- if( cau_incompatiblePlugins() ) { ?>
289
-
290
- <table class="cau_status_list no_column_width widefat striped cau_status_warnings">
291
-
292
- <thead>
293
- <tr>
294
- <th class="cau_plugin_issue_name" colspan="4"><strong><?php _e( 'Possible plugin issues', 'companion-auto-update' ); ?></strong></th>
295
- </tr>
296
- </thead>
297
-
298
- <tbody id="the-list">
299
- <?php
300
- foreach ( cau_incompatiblePluginlist() as $key => $value ) {
301
- if( is_plugin_active( $key ) ) {
302
- echo '<tr>
303
- <td class="cau_plugin_issue_name"><strong>'.$key.'</strong></td>
304
- <td colspan="2" class="cau_plugin_issue_explain">'.$value.'</td>
305
- <td class="cau_plugin_issue_fixit"><a href="https://codeermeneer.nl/documentation/known-issues-fixes/#plugins" target="_blank" class="button">'.__( 'How to fix this', 'companion-auto-update' ).'</a></td>
306
- </tr>';
307
- }
308
- }
309
- ?>
310
- </tbody>
311
-
312
- </table>
313
-
314
- <?php } ?>
315
-
316
- <table class="autoupdate cau_status_list widefat striped cau_status_warnings">
317
-
318
- <thead>
319
- <tr>
320
- <th><strong><?php _e( 'Advanced info', 'companion-auto-update' ); ?></strong> &dash; <?php _e( 'For when you need our help fixing an issue.', 'companion-auto-update' ); ?></th>
321
- </tr>
322
- </thead>
323
- <tbody id="the-list">
324
- <tr>
325
- <td>
326
- <div class='button button-primary toggle_advanced_button'><?php _e( 'Toggle', 'companion-auto-update' ); ?></div>
327
-
328
- <div class='toggle_advanced_content' style='display: none;'>
329
- <?php
330
- global $wpdb;
331
- $autoupdates = $wpdb->prefix."auto_updates";
332
- $cau_configs = $wpdb->get_results( "SELECT * FROM $autoupdates" );
333
- array_push( $cau_configs, "WordPress: ".get_bloginfo( 'version' ) );
334
- array_push( $cau_configs, "PHP: ".phpversion() );
335
- array_push( $cau_configs, "DB: ".get_option( "cau_db_version" ).' / '.cau_db_version() );
336
-
337
- echo "<textarea style='width: 100%; height: 750px;'>";
338
- print_r( $cau_configs );
339
- echo "</textarea>";
340
- ?>
341
- </div>
342
- </td>
343
- </tr>
344
- </tbody>
345
- </table>
346
-
347
- <script>jQuery( '.toggle_advanced_button' ).click( function() { jQuery( '.toggle_advanced_content' ).toggle(); });</script>
348
-
349
- </div>
350
-
351
- <?php
352
-
353
- // Remove the line
354
- if( isset( $_POST['fixit'] ) ) {
355
- check_admin_referer( 'cau_fixit' );
356
- cau_removeErrorLine();
357
- }
358
-
359
- // Get wp-config location
360
- function cau_configFile() {
361
-
362
- // Config file
363
- if ( file_exists( ABSPATH . 'wp-config.php') ) {
364
- $conFile = ABSPATH . 'wp-config.php';
365
- } else {
366
- $conFile = dirname(ABSPATH) . '/wp-config.php';
367
- }
368
-
369
- return $conFile;
370
-
371
- }
372
-
373
- // Change the AUTOMATIC_UPDATER_DISABLED line
374
- function cau_removeErrorLine() {
375
-
376
- // Config file
377
- $conFile = cau_configFile();
378
-
379
- // Lines to check and replace
380
- $revLine = "define('AUTOMATIC_UPDATER_DISABLED', false);"; // We could just remove the line, but replacing it will be safer
381
- $posibleLines = array( "define( 'AUTOMATIC_UPDATER_DISABLED', true );", "define( 'AUTOMATIC_UPDATER_DISABLED', minor );" ); // The two base options
382
- foreach ( $posibleLines as $value ) array_push( $posibleLines, strtolower( $value ) ); // Support lowercase variants
383
- foreach ( $posibleLines as $value ) array_push( $posibleLines, str_replace( ' ', '', $value ) ); // For variants without spaces
384
-
385
- $melding = __( "We couldn't fix the error for you. Please contact us for further support", 'companion-auto-update' ).'.';
386
- $meldingS = 'error';
387
-
388
- // Check for each string if it exists
389
- foreach ( $posibleLines as $key => $string ) {
390
-
391
- if( strpos( file_get_contents( $conFile ), $string ) !== false) {
392
- $contents = file_get_contents( $conFile );
393
- $contents = str_replace( $string, $revLine, $contents );
394
- file_put_contents( $conFile, $contents );
395
- $melding = __( "We've fixed the error for you", 'companion-auto-update' ).' :)';
396
- $meldingS = 'updated';
397
- }
398
-
399
- }
400
-
401
- echo "<div id='message' class='$meldingS'><p><strong>$melding</strong></p></div>";
402
-
403
- }
404
-
405
  ?>
1
+ <?php
2
+
3
+ // Update the database
4
+ if( isset( $_GET['run'] ) && $_GET['run'] == 'db_update' ) {
5
+ cau_manual_update();
6
+ echo '<div id="message" class="updated"><p><b>'.__( 'Database update completed' ).'</b></p></div>';
7
+ }
8
+
9
+ if( isset( $_GET['run'] ) && $_GET['run'] == 'db_info_update' ) {
10
+ cau_savePluginInformation();
11
+ echo '<div id="message" class="updated"><p><b>'.__( 'Database information update completed' ).'</b></p></div>';
12
+ }
13
+
14
+ if( isset( $_GET['ignore_report'] ) ) {
15
+
16
+ $report_to_ignore = sanitize_text_field( $_GET['ignore_report'] );
17
+ $allowedValues = array( 'seo', 'cron' );
18
+
19
+ if( !in_array( $report_to_ignore, $allowedValues ) ) {
20
+ wp_die( 'Trying to cheat eh?' );
21
+ } else {
22
+ global $wpdb;
23
+ $table_name = $wpdb->prefix . "auto_updates";
24
+ $wpdb->query( $wpdb->prepare( "UPDATE {$table_name} SET onoroff = %s WHERE name = 'ignore_$report_to_ignore'", 'yes' ) );
25
+ $__ignored = __( 'This report will now be ignored', 'companion-auto-update' );
26
+ echo "<div id='message' class='updated'><p><b>$__ignored</b></p></div>";
27
+ }
28
+
29
+ }
30
+
31
+
32
+
33
+ // Variables
34
+ $dateFormat = get_option( 'date_format' );
35
+ $dateFormat .= ' '.get_option( 'time_format' );
36
+ global $wpdb;
37
+ $table_name = $wpdb->prefix . "auto_updates";
38
+ $schedules = wp_get_schedules();
39
+ $interval_names = cau_wp_get_schedules();
40
+
41
+ ?>
42
+
43
+ <div class="cau_status_page">
44
+
45
+ <table class="cau_status_list widefat striped">
46
+
47
+ <thead>
48
+ <tr>
49
+ <th class="cau_status_name"><strong><?php _e( 'Auto Updater', 'companion-auto-update' ); ?></strong></th>
50
+ <th class="cau_status_active_state"><strong><?php _e( 'Status', 'companion-auto-update' ); ?></strong></th>
51
+ <th class="cau_status_interval"><strong><?php _e( 'Interval', 'companion-auto-update' ); ?></strong></th>
52
+ <th class="cau_status_next"><strong><?php _e( 'Next', 'companion-auto-update' ); ?></strong></th>
53
+ </tr>
54
+ </thead>
55
+
56
+ <tbody id="the-list">
57
+ <?php
58
+
59
+ $auto_updaters = array(
60
+ 'plugins' => __( 'Plugins', 'companion-auto-update' ),
61
+ 'themes' => __( 'Themes', 'companion-auto-update' ),
62
+ 'minor' => __( 'Core (Minor)', 'companion-auto-update' ),
63
+ 'major' => __( 'Core (Major)', 'companion-auto-update' )
64
+ );
65
+
66
+ $eventNames = array(
67
+ 'plugins' => 'wp_update_plugins',
68
+ 'themes' => 'wp_update_themes',
69
+ 'minor' => 'wp_version_check',
70
+ 'major' => 'wp_version_check'
71
+ );
72
+
73
+ foreach ( $auto_updaters as $key => $value ) {
74
+
75
+ if( cau_get_db_value( $key ) == 'on' ) {
76
+ $__status = 'enabled';
77
+ $__icon = 'yes-alt';
78
+ $__text = __( 'Enabled', 'companion-auto-update' );
79
+ $__interval = $interval_names[wp_get_schedule( $eventNames[$key] )];
80
+ $__next = date_i18n( $dateFormat, wp_next_scheduled( $eventNames[$key] ) );
81
+ } else {
82
+ $__status = 'disabled';
83
+ $__icon = 'marker';
84
+ $__text = __( 'Disabled', 'companion-auto-update' );
85
+ $__interval = '&dash;';
86
+ $__next = '&dash;';
87
+ }
88
+
89
+ $__nxt = __( 'Next', 'companion-auto-update' );
90
+
91
+ echo "<tr>
92
+ <td class='cau_status_name'>$value</td>
93
+ <td class='cau_status_active_state'><span class='cau_$__status'><span class='dashicons dashicons-$__icon'></span> $__text</span></td>
94
+ <td class='cau_status_interval'>$__interval</td>
95
+ <td class='cau_status_next'><span class='cau_mobile_prefix'>$__nxt: </span>$__next</td>
96
+ </tr>";
97
+ }
98
+
99
+ ?>
100
+ </tbody>
101
+
102
+ </table>
103
+
104
+ <table class="cau_status_list widefat striped">
105
+
106
+ <thead>
107
+ <tr>
108
+ <th class="cau_status_name"><strong><?php _e( 'Email Notifications', 'companion-auto-update' ); ?></strong></th>
109
+ <th class="cau_status_active_state"><strong><?php _e( 'Status', 'companion-auto-update' ); ?></strong></th>
110
+ <th class="cau_status_interval"><strong><?php _e( 'Interval', 'companion-auto-update' ); ?></strong></th>
111
+ <th class="cau_status_next"><strong><?php _e( 'Next', 'companion-auto-update' ); ?></strong></th>
112
+ </tr>
113
+ </thead>
114
+
115
+ <tbody id="the-list">
116
+ <?php
117
+
118
+ $other_events = array(
119
+ 'send' => __( 'Update available', 'companion-auto-update' ),
120
+ 'sendupdate' => __( 'Successful update', 'companion-auto-update' ),
121
+ 'wpemails' => __( 'Core notifications', 'companion-auto-update' )
122
+ );
123
+
124
+ $other_eventNames = array(
125
+ 'send' => 'cau_set_schedule_mail',
126
+ 'sendupdate' => 'cau_set_schedule_mail',
127
+ 'wpemails' => 'cau_set_schedule_mail',
128
+ );
129
+
130
+ foreach ( $other_events as $key => $value ) {
131
+
132
+ if( cau_get_db_value( $key ) == 'on' ) {
133
+ $__status = 'enabled';
134
+ $__icon = 'yes-alt';
135
+ $__text = __( 'Enabled', 'companion-auto-update' );
136
+ $__interval = $interval_names[wp_get_schedule( $other_eventNames[$key] )];
137
+ $__next = date_i18n( $dateFormat, wp_next_scheduled( $other_eventNames[$key] ) );
138
+ } else {
139
+ $__status = 'warning';
140
+ $__icon = 'marker';
141
+ $__text = __( 'Disabled', 'companion-auto-update' );
142
+ $__interval = '&dash;';
143
+ $__next = '&dash;';
144
+ }
145
+
146
+ $__nxt = __( 'Next', 'companion-auto-update' );
147
+
148
+ echo "<tr>
149
+ <td class='cau_status_name'>$value</td>
150
+ <td class='cau_status_active_state'><span class='cau_$__status'><span class='dashicons dashicons-$__icon'></span> $__text</span></td>
151
+ <td class='cau_status_interval'>$__interval</td>
152
+ <td class='cau_status_next'><span class='cau_mobile_prefix'>$__nxt: </span>$__next</td>
153
+ </tr>";
154
+ }
155
+
156
+ ?>
157
+ </tbody>
158
+
159
+ </table>
160
+
161
+ <table class="cau_status_list widefat striped cau_status_warnings">
162
+
163
+ <thead>
164
+ <tr>
165
+ <th class="cau_plugin_issue_name" colspan="4"><strong><?php _e( 'Status' ); ?></strong></th>
166
+ </tr>
167
+ </thead>
168
+
169
+ <tbody id="the-list">
170
+
171
+ <tr>
172
+ <td><?php _e( 'Auto updates', 'companion-auto-update' ); ?></td>
173
+ <?php if ( checkAutomaticUpdaterDisabled() ) { ?>
174
+ <td class="cau_status_active_state"><span class='cau_disabled'><span class="dashicons dashicons-no"></span> <?php _e( 'All automatic updates are disabled', 'companion-auto-update' ); ?></span></td>
175
+ <td>
176
+ <form method="POST">
177
+ <?php wp_nonce_field( 'cau_fixit' ); ?>
178
+ <button type="submit" name="fixit" class="button button-primary"><?php _e( 'Fix it', 'companion-auto-update' ); ?></button>
179
+ <a href="https://codeermeneer.nl/documentation/known-issues-fixes/#updates_disabled" target="_blank" class="button"><?php _e( 'How to fix this', 'companion-auto-update' ); ?></a>
180
+ </form>
181
+ </td>
182
+ <?php } else { ?>
183
+ <td class="cau_status_active_state"><span class='cau_enabled'><span class="dashicons dashicons-yes-alt"></span> <?php _e( 'No issues detected', 'companion-auto-update' ); ?></span></td>
184
+ <td></td>
185
+ <?php } ?>
186
+ <td></td>
187
+ </tr>
188
+
189
+ <tr>
190
+ <td><?php _e( 'Connection with WordPress.org', 'companion-auto-update' ); ?></td>
191
+ <?php if( wp_http_supports( array( 'ssl' ) ) == '1' ) {
192
+ $__text = __( 'No issues detected', 'companion-auto-update' );
193
+ echo "<td colspan='3' class='cau_status_active_state'><span class='cau_enabled'><span class='dashicons dashicons-yes-alt'></span> $__text</span></td>";
194
+ } else {
195
+ $__text = __( 'Disabled', 'companion-auto-update' );
196
+ echo "<td colspan='3' class='cau_status_active_state'><span class='cau_disabled'><span class='dashicons dashicons-no'></span> $__text</span></td>";
197
+ } ?>
198
+ </tr>
199
+
200
+ <tr <?php if( cau_get_db_value( 'ignore_seo' ) == 'yes' ) { echo "class='report_hidden'"; } ?> >
201
+ <td><?php _e( 'Search Engine Visibility', 'companion-auto-update' ); ?></td>
202
+ <?php if( get_option( 'blog_public' ) == 0 ) { ?>
203
+ <td colspan="2" class="cau_status_active_state">
204
+ <span class='cau_warning'><span class="dashicons dashicons-warning"></span></span>
205
+ <?php _e( 'You’ve chosen to discourage Search Engines from indexing your site. Auto-updating works best on sites with more traffic, consider enabling indexing for your site.', 'companion-auto-update' ); ?>
206
+ </td>
207
+ <td>
208
+ <a href="<?php echo admin_url( 'options-reading.php' ); ?>" class="button"><?php _e( 'Fix it', 'companion-auto-update' ); ?></a>
209
+ <a href="<?php echo cau_url( 'status' ); ?>&ignore_report=seo" class="button button-alt"><?php _e( 'Ignore this report', 'companion-auto-update' ); ?></a>
210
+ </td>
211
+ <?php } else { ?>
212
+ <td colspan="3" class="cau_status_active_state"><span class='cau_enabled'><span class="dashicons dashicons-yes-alt"></span> <?php _e( 'No issues detected', 'companion-auto-update' ); ?></span></td>
213
+ <?php } ?>
214
+ </tr>
215
+
216
+ <tr <?php if( cau_get_db_value( 'ignore_cron' ) == 'yes' ) { echo "class='report_hidden'"; } ?> >
217
+ <td><?php _e( 'Cronjobs', 'companion-auto-update' ); ?></td>
218
+ <?php if( checkCronjobsDisabled() ) { ?>
219
+ <td class="cau_status_active_state"><span class='cau_warning'><span class="dashicons dashicons-warning"></span> <?php _e( 'Disabled', 'companion-auto-update' ); ?></span></td>
220
+ <td><code>DISABLE_WP_CRON true</code></td>
221
+ <td>
222
+ <a href="https://codeermeneer.nl/contact/" class="button"><?php _e( 'Contact for support', 'companion-auto-update' ); ?></a>
223
+ <a href="<?php echo cau_url( 'status' ); ?>&ignore_report=cron" class="button button-alt"><?php _e( 'Ignore this report', 'companion-auto-update' ); ?></a>
224
+ </td>
225
+ <?php } else { ?>
226
+ <td colspan="3" class="cau_status_active_state"><span class='cau_enabled'><span class="dashicons dashicons-yes-alt"></span> <?php _e( 'No issues detected', 'companion-auto-update' ); ?></span></td>
227
+ <?php } ?>
228
+ </tr>
229
+
230
+ <tr>
231
+ <td>wp_version_check</td>
232
+ <?php if ( !has_filter( 'wp_version_check', 'wp_version_check' ) ) { ?>
233
+ <td colspan="2" class="cau_status_active_state"><span class='cau_disabled'><span class="dashicons dashicons-no"></span> <?php _e( 'A plugin has prevented updates by disabling wp_version_check', 'companion-auto-update' ); ?></span></td>
234
+ <td><a href="https://codeermeneer.nl/contact/" class="button"><?php _e( 'Contact for support', 'companion-auto-update' ); ?></a></td>
235
+ <?php } else { ?>
236
+ <td colspan="3" class="cau_status_active_state"><span class='cau_enabled'><span class="dashicons dashicons-yes-alt"></span> <?php _e( 'No issues detected' , 'companion-auto-update' ); ?></span></td>
237
+ <?php } ?>
238
+ </tr>
239
+
240
+ <tr>
241
+ <td>VCS</td>
242
+ <td colspan="3" class="cau_status_active_state"><span class='cau_<?php echo cau_test_is_vcs_checkout( ABSPATH )['status']; ?>'><span class="dashicons dashicons-<?php echo cau_test_is_vcs_checkout( ABSPATH )['icon']; ?>"></span> <?php echo cau_test_is_vcs_checkout( ABSPATH )['description']; ?></span></td>
243
+ </tr>
244
+
245
+ </tbody>
246
+
247
+ </table>
248
+
249
+ <table class="autoupdate cau_status_list widefat striped cau_status_warnings">
250
+
251
+ <thead>
252
+ <tr>
253
+ <th colspan="4"><strong><?php _e( 'Systeminfo', 'companion-auto-update' ); ?></strong></th>
254
+ </tr>
255
+ </thead>
256
+
257
+ <tbody id="the-list">
258
+ <tr>
259
+ <td>WordPress</td>
260
+ <td><?php echo get_bloginfo( 'version' ); ?></td>
261
+ <td></td>
262
+ <td></td>
263
+ </tr>
264
+ <tr>
265
+ <td>PHP</td>
266
+ <td><?php echo phpversion(); ?></td>
267
+ <td></td>
268
+ <td></td>
269
+ </tr>
270
+ <tr <?php if( cau_incorrectDatabaseVersion() ) { echo "class='inactive'"; } ?>>
271
+ <td>Database</td>
272
+ <td><?php echo get_option( "cau_db_version" ); ?> <code>(Latest: <?php echo cau_db_version(); ?>)</code></td>
273
+ <td></td>
274
+ <td></td>
275
+ </tr>
276
+ <tr>
277
+ <td class="cau_status_name"><?php _e( 'Timezone' ); ?></td>
278
+ <td class="cau_status_active_state"><?php echo cau_get_proper_timezone(); ?> (GMT <?php echo get_option('gmt_offset'); ?>) - <?php echo date_default_timezone_get(); ?></td>
279
+ <td></td>
280
+ <td></td>
281
+ </tr>
282
+ </tbody>
283
+
284
+ </table>
285
+
286
+ <?php
287
+ // If has incomptable plugins
288
+ if( cau_incompatiblePlugins() ) { ?>
289
+
290
+ <table class="cau_status_list no_column_width widefat striped cau_status_warnings">
291
+
292
+ <thead>
293
+ <tr>
294
+ <th class="cau_plugin_issue_name" colspan="4"><strong><?php _e( 'Possible plugin issues', 'companion-auto-update' ); ?></strong></th>
295
+ </tr>
296
+ </thead>
297
+
298
+ <tbody id="the-list">
299
+ <?php
300
+ foreach ( cau_incompatiblePluginlist() as $key => $value ) {
301
+ if( is_plugin_active( $key ) ) {
302
+ echo '<tr>
303
+ <td class="cau_plugin_issue_name"><strong>'.$key.'</strong></td>
304
+ <td colspan="2" class="cau_plugin_issue_explain">'.$value.'</td>
305
+ <td class="cau_plugin_issue_fixit"><a href="https://codeermeneer.nl/documentation/known-issues-fixes/#plugins" target="_blank" class="button">'.__( 'How to fix this', 'companion-auto-update' ).'</a></td>
306
+ </tr>';
307
+ }
308
+ }
309
+ ?>
310
+ </tbody>
311
+
312
+ </table>
313
+
314
+ <?php } ?>
315
+
316
+ <table class="autoupdate cau_status_list widefat striped cau_status_warnings">
317
+
318
+ <thead>
319
+ <tr>
320
+ <th><strong><?php _e( 'Advanced info', 'companion-auto-update' ); ?></strong> &dash; <?php _e( 'For when you need our help fixing an issue.', 'companion-auto-update' ); ?></th>
321
+ </tr>
322
+ </thead>
323
+ <tbody id="the-list">
324
+ <tr>
325
+ <td>
326
+ <div class='button button-primary toggle_advanced_button'><?php _e( 'Toggle', 'companion-auto-update' ); ?></div>
327
+
328
+ <div class='toggle_advanced_content' style='display: none;'>
329
+ <?php
330
+ global $wpdb;
331
+ $autoupdates = $wpdb->prefix."auto_updates";
332
+ $cau_configs = $wpdb->get_results( "SELECT * FROM $autoupdates" );
333
+ array_push( $cau_configs, "WordPress: ".get_bloginfo( 'version' ) );
334
+ array_push( $cau_configs, "PHP: ".phpversion() );
335
+ array_push( $cau_configs, "DB: ".get_option( "cau_db_version" ).' / '.cau_db_version() );
336
+
337
+ echo "<textarea style='width: 100%; height: 750px;'>";
338
+ print_r( $cau_configs );
339
+ echo "</textarea>";
340
+ ?>
341
+ </div>
342
+ </td>
343
+ </tr>
344
+ </tbody>
345
+ </table>
346
+
347
+ <script>jQuery( '.toggle_advanced_button' ).click( function() { jQuery( '.toggle_advanced_content' ).toggle(); });</script>
348
+
349
+ </div>
350
+
351
+ <?php
352
+
353
+ // Remove the line
354
+ if( isset( $_POST['fixit'] ) ) {
355
+ check_admin_referer( 'cau_fixit' );
356
+ cau_removeErrorLine();
357
+ }
358
+
359
+ // Get wp-config location
360
+ function cau_configFile() {
361
+
362
+ // Config file
363
+ if ( file_exists( ABSPATH . 'wp-config.php') ) {
364
+ $conFile = ABSPATH . 'wp-config.php';
365
+ } else {
366
+ $conFile = dirname(ABSPATH) . '/wp-config.php';
367
+ }
368
+
369
+ return $conFile;
370
+
371
+ }
372
+
373
+ // Change the AUTOMATIC_UPDATER_DISABLED line
374
+ function cau_removeErrorLine() {
375
+
376
+ // Config file
377
+ $conFile = cau_configFile();
378
+
379
+ // Lines to check and replace
380
+ $revLine = "define('AUTOMATIC_UPDATER_DISABLED', false);"; // We could just remove the line, but replacing it will be safer
381
+ $posibleLines = array( "define( 'AUTOMATIC_UPDATER_DISABLED', true );", "define( 'AUTOMATIC_UPDATER_DISABLED', minor );" ); // The two base options
382
+ foreach ( $posibleLines as $value ) array_push( $posibleLines, strtolower( $value ) ); // Support lowercase variants
383
+ foreach ( $posibleLines as $value ) array_push( $posibleLines, str_replace( ' ', '', $value ) ); // For variants without spaces
384
+
385
+ $melding = __( "We couldn't fix the error for you. Please contact us for further support", 'companion-auto-update' ).'.';
386
+ $meldingS = 'error';
387
+
388
+ // Check for each string if it exists
389
+ foreach ( $posibleLines as $key => $string ) {
390
+
391
+ if( strpos( file_get_contents( $conFile ), $string ) !== false) {
392
+ $contents = file_get_contents( $conFile );
393
+ $contents = str_replace( $string, $revLine, $contents );
394
+ file_put_contents( $conFile, $contents );
395
+ $melding = __( "We've fixed the error for you", 'companion-auto-update' ).' :)';
396
+ $meldingS = 'updated';
397
+ }
398
+
399
+ }
400
+
401
+ echo "<div id='message' class='$meldingS'><p><strong>$melding</strong></p></div>";
402
+
403
+ }
404
+
405
  ?>
backend/style.css CHANGED
@@ -1,567 +1,575 @@
1
- /* Default Stylings */
2
- .nowrap {
3
- white-space: nowrap;
4
- }
5
- .cau_spacing {
6
- height: 25px;
7
- }
8
- .cau_support_buttons {
9
- display: inline-block;
10
- }
11
-
12
- /* Welcome screen */
13
- .welcome-to-cau {
14
- background: #FFF;
15
- border: 1px solid #CCD0D4;
16
- margin: 25px 0;
17
- padding: 30px;
18
- background-size: 140px;
19
- background-position: left bottom;
20
- background-repeat: no-repeat;
21
- box-shadow: 0 1px 1px rgba(0,0,0,.04);
22
- }
23
- .welcome-to-cau .welcome-image {
24
- display: inline-block;
25
- vertical-align: middle;
26
- width: 100px;
27
- height: 100px;
28
- background-image: url('images/welcome.svg');
29
- background-size: contain;
30
- background-position: center;
31
- box-sizing: border-box;
32
- }
33
- .welcome-to-cau .welcome-content {
34
- display: inline-block;
35
- vertical-align: middle;
36
- width: calc(100% - 100px);
37
- padding-left: 25px;
38
- box-sizing: border-box;
39
- }
40
- .welcome-to-cau .welcome-content strong {
41
- color: #000;
42
- }
43
- .welcome-to-cau .welcome-content p {
44
- margin: 2px 0;
45
- }
46
- .welcome-to-cau.help-bg {
47
- background-image: url('images/help.svg');
48
- }
49
- .welcome-to-cau.support-bg {
50
- background-image: url('images/support.svg');
51
- }
52
- .welcome-to-cau.love-bg {
53
- background-image: url('images/love.svg');
54
- }
55
- .welcome-to-cau.update-bg {
56
- background-image: url('images/update.svg');
57
- }
58
- .welcome-to-cau.email-bg {
59
- background-image: url('images/email.svg');
60
- }
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;
70
- font-size: 21px;
71
- font-weight: 400;
72
- line-height: 1.2;
73
- }
74
- .welcome-to-cau h2.title {
75
- margin-bottom: 10px;
76
- }
77
- .welcome-to-cau h3 {
78
- font-size: 16px;
79
- margin-top: 0;
80
- }
81
- .welcome-to-cau a {
82
- text-decoration: none;
83
- }
84
- .welcome-to-cau .welcome-column {
85
- display: inline-block;
86
- vertical-align: top;
87
- box-sizing: border-box;
88
- }
89
- .welcome-to-cau.cau-show-love .welcome-column {
90
- vertical-align: middle;
91
- }
92
- .welcome-to-cau .welcome-column.welcome-column-first {
93
- display: block;
94
- width: 100%;
95
- }
96
- .first-column {
97
- padding-left: 140px;
98
- }
99
- .welcome-to-cau .welcome-column.welcome-column-half {
100
- width: 50%;
101
- }
102
- .welcome-to-cau .welcome-column.welcome-column-third {
103
- width: 33%;
104
- }
105
- .welcome-to-cau .welcome-column.welcome-column-quarter {
106
- width: 25%;
107
- }
108
- .welcome-to-cau a.minimal-button {
109
- display: inline-block;
110
- padding: 5px;
111
- }
112
- select.schedule_interval {
113
- max-width: 90%;
114
- width: 225px;
115
- }
116
- .cau_save_button {
117
- background: #FFF;
118
- box-sizing: border-box;
119
- padding: 0 25px;
120
- position: fixed;
121
- width: 100%;
122
- right: 0;
123
- bottom: 0;
124
- margin-left: -25px;
125
- z-index: 1001;
126
- box-shadow: 0 -8px 16px 0 rgb(85 93 102 / 30%);
127
- }
128
- .cau_save_button p.submit {
129
- display: block;
130
- text-align: right;
131
- font-weight: bold;
132
- }
133
- .cau_save_button__space {
134
- height: 75px;
135
- }
136
-
137
- /* Overwrite core UI */
138
- /*.cau_content input[type="checkbox"]:checked::before {
139
- content: "";
140
- background: url( 'images/check.svg' );
141
- background-size: contain;
142
- background-position: center center;
143
- }*/
144
- .cau_content a {
145
- color: #9178B7;
146
- }
147
- .cau_content a.nav-tab {
148
- color: #23282D;
149
- }
150
- .cau_content .button-primary {
151
- background-color: #9178B7!important;
152
- border-color: #9178B7!important;
153
- }
154
- .cau_content .button-alt {
155
- color: #9178B7!important;
156
- border-color: #9178B7!important;
157
- }
158
- .cau_content .button-hero {
159
- font-weight: 500;
160
- padding: 15px 30px!important;
161
- }
162
- #message.cau {
163
- background: #FFF;
164
- border: 1px solid #CCD0D4;
165
- border-left-width: 4px;
166
- border-left-color: #9178B7;
167
- box-shadow: 0 1px 1px rgba(0,0,0,.04);
168
- margin: 25px 0px 5px 0;
169
- padding: 15px;
170
- }
171
- #message.cau a, #message.cau strong {
172
- color: #9178B7;
173
- }
174
-
175
- /* Dashboard */
176
- .cau-column-wide {
177
- box-sizing: border-box;
178
- display: inline-block;
179
- vertical-align: top;
180
- width: calc(100% - 450px);
181
- padding-right: 25px;
182
- }
183
- .cau-column-small {
184
- display: inline-block;
185
- vertical-align: top;
186
- width: 450px;
187
- }
188
- .cau-dashboard-box {
189
- background-position: right bottom;
190
- }
191
- .cau-column-wide .cau-dashboard-box {
192
- padding-right: 125px;
193
- }
194
- .cau-dashboard-box a {
195
- margin-left: 0px;
196
- margin-top: 10px;
197
- }
198
- .cau-dashboard-box .welcome-column {
199
- padding-right: 25px;
200
- }
201
- .support-sidebar-list {
202
- margin-bottom: 25px;
203
- }
204
- .cau_content .nav-tab {
205
- position: relative;
206
- }
207
- .cau_content .nav-tab .cau_melding {
208
- display: inline-block;
209
- width: 11px;
210
- height: 11px;
211
- border-radius: 10px;
212
- margin-left: 5px;
213
- position: relative;
214
- bottom: -1px;
215
- }
216
- .cau_content .nav-tab .cau_melding.level-okay {
217
- background: #7AD03A;
218
- }
219
- .cau_content .nav-tab .cau_melding.level-low {
220
- background: #FFBA00;
221
- }
222
- .cau_content .nav-tab .cau_melding.level-high {
223
- background: #FF0000;
224
- }
225
-
226
- /* Table Styling */
227
- .cau_content .widefat td {
228
- vertical-align: middle!important;
229
- }
230
- table.autoupdate th.head-plugin {
231
- min-width: 250px;
232
- }
233
- table.autoupdate th.head-status {
234
- min-width: 150px;
235
- }
236
- table.autoupdate th.check-column {
237
- position: relative;
238
- min-width: 55px;
239
- }
240
- table.autoupdate tr.inactive {
241
- background: #FEF7F1;
242
- }
243
- table.autoupdate tr.active .check-column {
244
- border-left: 3px solid transparent;
245
- }
246
- table.autoupdate tr.inactive .check-column {
247
- border-left: 3px solid #D54E21;
248
- }
249
- table.autoupdate tr.inactive td.column-status p {
250
- color: #BF3D3C;
251
- }
252
- table.autoupdate tr.active td.column-status p {
253
- color: #000;
254
- }
255
- table.autoupdate tr td.column-description p {
256
- overflow: hidden;
257
- max-height: 18px;
258
- }
259
-
260
- /* Update Log */
261
- table.autoupdatelog {
262
- margin-top: 25px;
263
- }
264
- table.autoupdatelog strong {
265
- color: #000;
266
- }
267
- table.autoupdatelog .dashicons {
268
- color: #00A0D2;
269
- }
270
-
271
- /* Status */
272
- table.cau_status_list {
273
- margin-top: 25px;
274
- }
275
- table.cau_status_list:not(.no_column_width) th, table.cau_status_list:not(.no_column_width) td {
276
- width: 25%;
277
- }
278
- .cau_enabled {
279
- color: #7AD03A;
280
- }
281
- .cau_disabled {
282
- color: #FF0000;
283
- }
284
- .cau_warning {
285
- color: #FFBA00;
286
- }
287
- .cau_mobile_prefix {
288
- display: none;
289
- }
290
-
291
- /* Rollback list */
292
- table.rollbacklist {
293
- max-width: 650px;
294
- }
295
- table.rollbacklist td {
296
- vertical-align: middle;
297
- }
298
- table.rollbacklist td a.versionselectbutton {
299
- display: inline-block;
300
- width: 100px;
301
- text-align: center;
302
- }
303
-
304
- /* Plugin list */
305
- .pluginListButtons {
306
- display: block;
307
- padding: 15px 0;
308
- }
309
- .pluginListButtons p.submit {
310
- display: inline-block;
311
- margin: 0!important;
312
- padding: 0!important;
313
- }
314
- .cau_content #the-list input[type="checkbox"]:not(:checked), .cau_content #the-list input[type="checkbox"]:checked {
315
- width: 45px;
316
- height: 45px;
317
- position: absolute;
318
- top: 0;
319
- bottom: 0;
320
- z-index: 100;
321
- display: block;
322
- opacity: 0;
323
- }
324
- .cau_content #the-list input[type="checkbox"]:not(:checked) + label, .cau_content #the-list input[type="checkbox"]:checked + label {
325
- position: absolute;
326
- top: 15px;
327
- left: 12px;
328
- cursor: pointer;
329
- }
330
- .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 {
331
- content: '';
332
- position: absolute;
333
- }
334
- .cau_content #the-list input[type="checkbox"]:not(:checked) + label:before, .cau_content #the-list input[type="checkbox"]:checked + label:before {
335
- left: 0;
336
- top: -3px;
337
- width: 30px;
338
- height: 16px;
339
- background: transparent;
340
- border: 2px solid #9178B7;
341
- border-radius: 15px;
342
- transition: background-color .2s;
343
- }
344
- .cau_content #the-list input[type="checkbox"]:not(:checked) + label:after, .cau_content #the-list input[type="checkbox"]:checked + label:after {
345
- width: 8px;
346
- height: 8px;
347
- transition: all .2s;
348
- border-radius: 500px;
349
- background: transparent;
350
- border: 2px solid #9178B7;
351
- top: 1px;
352
- left: 5px;
353
- }
354
- .cau_content #the-list input[type="checkbox"]:not(:checked) + label:before {
355
- background: #9178B7;
356
- border: 2px solid #9178B7;
357
- }
358
- .cau_content #the-list input[type="checkbox"]:not(:checked) + label:after {
359
- background: #9178B7;
360
- border-color: #FFF;
361
- left: 18px;
362
- }
363
-
364
- /* Scheduling */
365
- .cau_schedule_input {
366
- display: inline-block;
367
- vertical-align: middle;
368
- width: 50px;
369
- padding-top: 5px;
370
- }
371
- .cau_schedule_input input {
372
- max-width: 100%;
373
- text-align: center;
374
- }
375
- .cau_schedule_input_div {
376
- display: inline-block;
377
- vertical-align: middle;
378
- padding: 0 6px;
379
- font-weight: bold;
380
- }
381
- .cau_shedule_notation {
382
- display: inline-block;
383
- vertical-align: middle;
384
- width: 125px;
385
- padding-left: 5px;
386
- }
387
- .cau_shedule_notation .dashicons {
388
- position: relative;
389
- bottom: -5px;
390
- }
391
-
392
- /* Tooltip */
393
- .cau_tooltip {
394
- position: relative;
395
- }
396
- .cau_tooltip .cau_tooltip_text {
397
- visibility: hidden;
398
- background-color: rgba(0,0,0,0.7);
399
- color: #FFF;
400
- text-align: left;
401
- font-size: 14px;
402
- padding: 15px;
403
- border-radius: 6px;
404
- position: absolute;
405
- z-index: 1;
406
- width: 240px;
407
- bottom: 100%;
408
- left: 50%;
409
- margin-left: -60px;
410
- margin-bottom: 10px;
411
- opacity: 0;
412
- transition: .3s;
413
- font-weight: normal;
414
- }
415
- .cau_tooltip:hover .cau_tooltip_text {
416
- visibility: visible;
417
- opacity: 1;
418
- }
419
- .cau_tooltip .cau_tooltip_text::after {
420
- content: " ";
421
- position: absolute;
422
- top: 100%;
423
- left: 50%;
424
- margin-left: -75px;
425
- border-width: 5px;
426
- border-style: solid;
427
- border-color: rgba(0,0,0,0.7) transparent transparent transparent;
428
- }
429
-
430
- /* Responsive */
431
- @media screen and (max-width: 1400px) {
432
-
433
- .cau-column-wide {
434
- width: calc(100% - 350px);
435
- }
436
- .cau-column-small {
437
- width: 350px;
438
- }
439
- .welcome-to-cau .welcome-column.welcome-column-quarter {
440
- width: 50%;
441
- padding-bottom: 35px;
442
- }
443
- .cau-column-small .welcome-to-cau {
444
- background-image: none;
445
- }
446
-
447
- }
448
- @media screen and (max-width: 1150px) {
449
-
450
- .cau-column-wide, .cau-column-small {
451
- width: 100%;
452
- padding: 0;
453
- }
454
-
455
- }
456
- @media screen and (max-width: 1000px) {
457
-
458
- /* Basics */
459
- .cau_hide_on_mobile, table.autoupdate thead {
460
- display: none!important;
461
- }
462
- .form-table td fieldset p {
463
- display: block;
464
- padding: 5px 0;
465
- }
466
- .form-table td fieldset input[type="checkbox"] {
467
- display: inline-block;
468
- vertical-align: middle;
469
- width: 25px;
470
- }
471
- .form-table td fieldset label {
472
- display: inline-block;
473
- vertical-align: middle;
474
- width: calc(100% - 40px);
475
- box-sizing: border-box;
476
- padding-left: 5px;
477
- }
478
- .cau_content .nav-tab-wrapper {
479
- position: relative;
480
- top: -20px;
481
- border-bottom: 1px solid #CCC!important;
482
- padding-bottom: 15px!important;
483
- margin-bottom: 0px!important;
484
- }
485
- .cau_content .nav-tab {
486
- font-size: 12px;
487
- margin: 5px 5px 0 0!important;
488
- box-sizing: border-box;
489
- text-align: center;
490
- }
491
-
492
- /* Scheduling */
493
- .cau_schedule_input {
494
- width: 75px;
495
- }
496
-
497
- /* Custom buttons */
498
- .cau-button {
499
- display: block;
500
- text-align: center;
501
- margin: 5px 0;
502
- }
503
- .cau-button .dashicons {
504
- float: left;
505
- }
506
-
507
- /* Dashboard */
508
- .welcome-to-cau {
509
- background-position: right bottom;
510
- }
511
- .welcome-to-cau.love-bg {
512
- background-image: none;
513
- }
514
- .welcome-to-cau .welcome-column {
515
- min-width: 100%;
516
- }
517
- .welcome-to-cau .welcome-column.welcome-column-first {
518
- padding-left: 0px;
519
- }
520
- .cau-column-wide .cau-dashboard-box {
521
- padding-right: 30px;
522
- padding-bottom: 125px
523
- }
524
- .majorMinorExplain {
525
- display: none;
526
- }
527
-
528
- /* Status */
529
- table.cau_status_list .cau_status_name {
530
- display: inline-block;
531
- width: 50%;
532
- box-sizing: border-box;
533
- font-weight: 500;
534
- }
535
- table.cau_status_list .cau_status_interval {
536
- display: none;
537
- }
538
- table.cau_status_list th.cau_status_next {
539
- display: none;
540
- }
541
- table.cau_status_list td.cau_status_next {
542
- display: block;
543
- width: 100%;
544
- }
545
- table.cau_status_list .cau_status_active_state {
546
- display: inline-block;
547
- width: 50%;
548
- box-sizing: border-box;
549
- text-align: right;
550
- }
551
- .cau_mobile_prefix {
552
- display: inline-block;
553
- padding-right: 5px;
554
- }
555
- table.cau_status_list.cau_status_warnings td {
556
- display: block;
557
- width: 100%;
558
- box-sizing: border-box;
559
- }
560
- table.cau_status_list.cau_status_warnings th.cau_plugin_issue_explain, table.cau_status_list.cau_status_warnings th.cau_plugin_issue_fixit {
561
- display: none;
562
- }
563
- table.cau_status_list.cau_status_warnings td.cau_plugin_issue_name {
564
- font-weight: 500;
565
- }
566
-
 
 
 
 
 
 
 
 
567
  }
1
+ /* Default Stylings */
2
+ .nowrap {
3
+ white-space: nowrap;
4
+ }
5
+ .cau_spacing {
6
+ height: 25px;
7
+ }
8
+ .cau_support_buttons {
9
+ display: inline-block;
10
+ }
11
+
12
+ /* Welcome screen */
13
+ .welcome-to-cau {
14
+ background: #FFF;
15
+ border: 1px solid #CCD0D4;
16
+ margin: 25px 0;
17
+ padding: 30px;
18
+ background-size: 140px;
19
+ background-position: left bottom;
20
+ background-repeat: no-repeat;
21
+ box-shadow: 0 1px 1px rgba(0,0,0,.04);
22
+ }
23
+ .welcome-to-cau .welcome-image {
24
+ display: inline-block;
25
+ vertical-align: middle;
26
+ width: 100px;
27
+ height: 100px;
28
+ background-image: url('images/welcome.svg');
29
+ background-size: contain;
30
+ background-position: center;
31
+ box-sizing: border-box;
32
+ }
33
+ .welcome-to-cau .welcome-content {
34
+ display: inline-block;
35
+ vertical-align: middle;
36
+ width: calc(100% - 100px);
37
+ padding-left: 25px;
38
+ box-sizing: border-box;
39
+ }
40
+ .welcome-to-cau .welcome-content strong {
41
+ color: #000;
42
+ }
43
+ .welcome-to-cau .welcome-content p {
44
+ margin: 2px 0;
45
+ }
46
+ .welcome-to-cau.help-bg {
47
+ background-image: url('images/help.svg');
48
+ }
49
+ .welcome-to-cau.support-bg {
50
+ background-image: url('images/support.svg');
51
+ }
52
+ .welcome-to-cau.love-bg {
53
+ background-image: url('images/love.svg');
54
+ }
55
+ .welcome-to-cau.update-bg {
56
+ background-image: url('images/update.svg');
57
+ }
58
+ .welcome-to-cau.email-bg {
59
+ background-image: url('images/email.svg');
60
+ }
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;
70
+ font-size: 21px;
71
+ font-weight: 400;
72
+ line-height: 1.2;
73
+ }
74
+ .welcome-to-cau h2.title {
75
+ margin-bottom: 10px;
76
+ }
77
+ .welcome-to-cau h3 {
78
+ font-size: 16px;
79
+ margin-top: 0;
80
+ }
81
+ .welcome-to-cau a {
82
+ text-decoration: none;
83
+ }
84
+ .welcome-to-cau .welcome-column {
85
+ display: inline-block;
86
+ vertical-align: top;
87
+ box-sizing: border-box;
88
+ }
89
+ .welcome-to-cau.cau-show-love .welcome-column {
90
+ vertical-align: middle;
91
+ }
92
+ .welcome-to-cau .welcome-column.welcome-column-first {
93
+ display: block;
94
+ width: 100%;
95
+ }
96
+ .first-column {
97
+ padding-left: 140px;
98
+ }
99
+ .welcome-to-cau .welcome-column.welcome-column-half {
100
+ width: 50%;
101
+ }
102
+ .welcome-to-cau .welcome-column.welcome-column-third {
103
+ width: 33%;
104
+ }
105
+ .welcome-to-cau .welcome-column.welcome-column-quarter {
106
+ width: 25%;
107
+ }
108
+ .welcome-to-cau a.minimal-button {
109
+ display: inline-block;
110
+ padding: 5px;
111
+ }
112
+ select.schedule_interval {
113
+ max-width: 90%;
114
+ width: 225px;
115
+ }
116
+ .cau_save_button.fixed_button {
117
+ background: #FFF;
118
+ box-sizing: border-box;
119
+ position: fixed;
120
+ width: 100%;
121
+ right: 0;
122
+ bottom: 0;
123
+ margin-left: -25px;
124
+ z-index: 1001;
125
+ padding: 5px;
126
+ box-shadow: 0 -8px 16px 0 rgb(85 93 102 / 30%);
127
+ }
128
+ .cau_save_button.fixed_button p.submit {
129
+ display: block;
130
+ text-align: center;
131
+ font-weight: bold;
132
+ margin: 0;
133
+ padding: 0;
134
+ }
135
+ .cau_save_button.fixed_button p.submit input {
136
+ width: 100%;
137
+ max-width: 250px;
138
+ height: 100%;
139
+ padding: 5px;
140
+ }
141
+ .cau_save_button__space {
142
+ height: 75px;
143
+ }
144
+
145
+ /* Overwrite core UI */
146
+ /*.cau_content input[type="checkbox"]:checked::before {
147
+ content: "";
148
+ background: url( 'images/check.svg' );
149
+ background-size: contain;
150
+ background-position: center center;
151
+ }*/
152
+ .cau_content a {
153
+ color: #9178B7;
154
+ }
155
+ .cau_content a.nav-tab {
156
+ color: #23282D;
157
+ }
158
+ .cau_content .button-primary {
159
+ background-color: #9178B7!important;
160
+ border-color: #9178B7!important;
161
+ }
162
+ .cau_content .button-alt {
163
+ color: #9178B7!important;
164
+ border-color: #9178B7!important;
165
+ }
166
+ .cau_content .button-hero {
167
+ font-weight: 500;
168
+ padding: 15px 30px!important;
169
+ }
170
+ #message.cau {
171
+ background: #FFF;
172
+ border: 1px solid #CCD0D4;
173
+ border-left-width: 4px;
174
+ border-left-color: #9178B7;
175
+ box-shadow: 0 1px 1px rgba(0,0,0,.04);
176
+ margin: 25px 0px 5px 0;
177
+ padding: 15px;
178
+ }
179
+ #message.cau a, #message.cau strong {
180
+ color: #9178B7;
181
+ }
182
+
183
+ /* Dashboard */
184
+ .cau-column-wide {
185
+ box-sizing: border-box;
186
+ display: inline-block;
187
+ vertical-align: top;
188
+ width: calc(100% - 450px);
189
+ padding-right: 25px;
190
+ }
191
+ .cau-column-small {
192
+ display: inline-block;
193
+ vertical-align: top;
194
+ width: 450px;
195
+ }
196
+ .cau-dashboard-box {
197
+ background-position: right bottom;
198
+ }
199
+ .cau-column-wide .cau-dashboard-box {
200
+ padding-right: 125px;
201
+ }
202
+ .cau-dashboard-box a {
203
+ margin-left: 0px;
204
+ margin-top: 10px;
205
+ }
206
+ .cau-dashboard-box .welcome-column {
207
+ padding-right: 25px;
208
+ }
209
+ .support-sidebar-list {
210
+ margin-bottom: 25px;
211
+ }
212
+ .cau_content .nav-tab {
213
+ position: relative;
214
+ }
215
+ .cau_content .nav-tab .cau_melding {
216
+ display: inline-block;
217
+ width: 11px;
218
+ height: 11px;
219
+ border-radius: 10px;
220
+ margin-left: 5px;
221
+ position: relative;
222
+ bottom: -1px;
223
+ }
224
+ .cau_content .nav-tab .cau_melding.level-okay {
225
+ background: #7AD03A;
226
+ }
227
+ .cau_content .nav-tab .cau_melding.level-low {
228
+ background: #FFBA00;
229
+ }
230
+ .cau_content .nav-tab .cau_melding.level-high {
231
+ background: #FF0000;
232
+ }
233
+
234
+ /* Table Styling */
235
+ .cau_content .widefat td {
236
+ vertical-align: middle!important;
237
+ }
238
+ table.autoupdate th.head-plugin {
239
+ min-width: 250px;
240
+ }
241
+ table.autoupdate th.head-status {
242
+ min-width: 150px;
243
+ }
244
+ table.autoupdate th.check-column {
245
+ position: relative;
246
+ min-width: 55px;
247
+ }
248
+ table.autoupdate tr.inactive {
249
+ background: #FEF7F1;
250
+ }
251
+ table.autoupdate tr.active .check-column {
252
+ border-left: 3px solid transparent;
253
+ }
254
+ table.autoupdate tr.inactive .check-column {
255
+ border-left: 3px solid #D54E21;
256
+ }
257
+ table.autoupdate tr.inactive td.column-status p {
258
+ color: #BF3D3C;
259
+ }
260
+ table.autoupdate tr.active td.column-status p {
261
+ color: #000;
262
+ }
263
+ table.autoupdate tr td.column-description p {
264
+ overflow: hidden;
265
+ max-height: 18px;
266
+ }
267
+
268
+ /* Update Log */
269
+ table.autoupdatelog {
270
+ margin-top: 25px;
271
+ }
272
+ table.autoupdatelog strong {
273
+ color: #000;
274
+ }
275
+ table.autoupdatelog .dashicons {
276
+ color: #00A0D2;
277
+ }
278
+
279
+ /* Status */
280
+ table.cau_status_list {
281
+ margin-top: 25px;
282
+ }
283
+ table.cau_status_list:not(.no_column_width) th, table.cau_status_list:not(.no_column_width) td {
284
+ width: 25%;
285
+ }
286
+ .cau_enabled {
287
+ color: #7AD03A;
288
+ }
289
+ .cau_disabled {
290
+ color: #FF0000;
291
+ }
292
+ .cau_warning {
293
+ color: #FFBA00;
294
+ }
295
+ .cau_mobile_prefix {
296
+ display: none;
297
+ }
298
+
299
+ /* Rollback list */
300
+ table.rollbacklist {
301
+ max-width: 650px;
302
+ }
303
+ table.rollbacklist td {
304
+ vertical-align: middle;
305
+ }
306
+ table.rollbacklist td a.versionselectbutton {
307
+ display: inline-block;
308
+ width: 100px;
309
+ text-align: center;
310
+ }
311
+
312
+ /* Plugin list */
313
+ .pluginListButtons {
314
+ display: block;
315
+ padding: 15px 0;
316
+ }
317
+ .pluginListButtons p.submit {
318
+ display: inline-block;
319
+ margin: 0!important;
320
+ padding: 0!important;
321
+ }
322
+ .cau_content #the-list input[type="checkbox"]:not(:checked), .cau_content #the-list input[type="checkbox"]:checked {
323
+ width: 45px;
324
+ height: 45px;
325
+ position: absolute;
326
+ top: 0;
327
+ bottom: 0;
328
+ z-index: 100;
329
+ display: block;
330
+ opacity: 0;
331
+ }
332
+ .cau_content #the-list input[type="checkbox"]:not(:checked) + label, .cau_content #the-list input[type="checkbox"]:checked + label {
333
+ position: absolute;
334
+ top: 15px;
335
+ left: 12px;
336
+ cursor: pointer;
337
+ }
338
+ .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 {
339
+ content: '';
340
+ position: absolute;
341
+ }
342
+ .cau_content #the-list input[type="checkbox"]:not(:checked) + label:before, .cau_content #the-list input[type="checkbox"]:checked + label:before {
343
+ left: 0;
344
+ top: -3px;
345
+ width: 30px;
346
+ height: 16px;
347
+ background: transparent;
348
+ border: 2px solid #9178B7;
349
+ border-radius: 15px;
350
+ transition: background-color .2s;
351
+ }
352
+ .cau_content #the-list input[type="checkbox"]:not(:checked) + label:after, .cau_content #the-list input[type="checkbox"]:checked + label:after {
353
+ width: 8px;
354
+ height: 8px;
355
+ transition: all .2s;
356
+ border-radius: 500px;
357
+ background: transparent;
358
+ border: 2px solid #9178B7;
359
+ top: 1px;
360
+ left: 5px;
361
+ }
362
+ .cau_content #the-list input[type="checkbox"]:not(:checked) + label:before {
363
+ background: #9178B7;
364
+ border: 2px solid #9178B7;
365
+ }
366
+ .cau_content #the-list input[type="checkbox"]:not(:checked) + label:after {
367
+ background: #9178B7;
368
+ border-color: #FFF;
369
+ left: 18px;
370
+ }
371
+
372
+ /* Scheduling */
373
+ .cau_schedule_input {
374
+ display: inline-block;
375
+ vertical-align: middle;
376
+ width: 50px;
377
+ padding-top: 5px;
378
+ }
379
+ .cau_schedule_input input {
380
+ max-width: 100%;
381
+ text-align: center;
382
+ }
383
+ .cau_schedule_input_div {
384
+ display: inline-block;
385
+ vertical-align: middle;
386
+ padding: 0 6px;
387
+ font-weight: bold;
388
+ }
389
+ .cau_shedule_notation {
390
+ display: inline-block;
391
+ vertical-align: middle;
392
+ width: 125px;
393
+ padding-left: 5px;
394
+ }
395
+ .cau_shedule_notation .dashicons {
396
+ position: relative;
397
+ bottom: -5px;
398
+ }
399
+
400
+ /* Tooltip */
401
+ .cau_tooltip {
402
+ position: relative;
403
+ }
404
+ .cau_tooltip .cau_tooltip_text {
405
+ visibility: hidden;
406
+ background-color: rgba(0,0,0,0.7);
407
+ color: #FFF;
408
+ text-align: left;
409
+ font-size: 14px;
410
+ padding: 15px;
411
+ border-radius: 6px;
412
+ position: absolute;
413
+ z-index: 1;
414
+ width: 240px;
415
+ bottom: 100%;
416
+ left: 50%;
417
+ margin-left: -60px;
418
+ margin-bottom: 10px;
419
+ opacity: 0;
420
+ transition: .3s;
421
+ font-weight: normal;
422
+ }
423
+ .cau_tooltip:hover .cau_tooltip_text {
424
+ visibility: visible;
425
+ opacity: 1;
426
+ }
427
+ .cau_tooltip .cau_tooltip_text::after {
428
+ content: " ";
429
+ position: absolute;
430
+ top: 100%;
431
+ left: 50%;
432
+ margin-left: -75px;
433
+ border-width: 5px;
434
+ border-style: solid;
435
+ border-color: rgba(0,0,0,0.7) transparent transparent transparent;
436
+ }
437
+
438
+ /* Responsive */
439
+ @media screen and (max-width: 1400px) {
440
+
441
+ .cau-column-wide {
442
+ width: calc(100% - 350px);
443
+ }
444
+ .cau-column-small {
445
+ width: 350px;
446
+ }
447
+ .welcome-to-cau .welcome-column.welcome-column-quarter {
448
+ width: 50%;
449
+ padding-bottom: 35px;
450
+ }
451
+ .cau-column-small .welcome-to-cau {
452
+ background-image: none;
453
+ }
454
+
455
+ }
456
+ @media screen and (max-width: 1150px) {
457
+
458
+ .cau-column-wide, .cau-column-small {
459
+ width: 100%;
460
+ padding: 0;
461
+ }
462
+
463
+ }
464
+ @media screen and (max-width: 1000px) {
465
+
466
+ /* Basics */
467
+ .cau_hide_on_mobile, table.autoupdate thead {
468
+ display: none!important;
469
+ }
470
+ .form-table td fieldset p {
471
+ display: block;
472
+ padding: 5px 0;
473
+ }
474
+ .form-table td fieldset input[type="checkbox"] {
475
+ display: inline-block;
476
+ vertical-align: middle;
477
+ width: 25px;
478
+ }
479
+ .form-table td fieldset label {
480
+ display: inline-block;
481
+ vertical-align: middle;
482
+ width: calc(100% - 40px);
483
+ box-sizing: border-box;
484
+ padding-left: 5px;
485
+ }
486
+ .cau_content .nav-tab-wrapper {
487
+ position: relative;
488
+ top: -20px;
489
+ border-bottom: 1px solid #CCC!important;
490
+ padding-bottom: 15px!important;
491
+ margin-bottom: 0px!important;
492
+ }
493
+ .cau_content .nav-tab {
494
+ font-size: 12px;
495
+ margin: 5px 5px 0 0!important;
496
+ box-sizing: border-box;
497
+ text-align: center;
498
+ }
499
+
500
+ /* Scheduling */
501
+ .cau_schedule_input {
502
+ width: 75px;
503
+ }
504
+
505
+ /* Custom buttons */
506
+ .cau-button {
507
+ display: block;
508
+ text-align: center;
509
+ margin: 5px 0;
510
+ }
511
+ .cau-button .dashicons {
512
+ float: left;
513
+ }
514
+
515
+ /* Dashboard */
516
+ .welcome-to-cau {
517
+ background-position: right bottom;
518
+ }
519
+ .welcome-to-cau.love-bg {
520
+ background-image: none;
521
+ }
522
+ .welcome-to-cau .welcome-column {
523
+ min-width: 100%;
524
+ }
525
+ .welcome-to-cau .welcome-column.welcome-column-first {
526
+ padding-left: 0px;
527
+ }
528
+ .cau-column-wide .cau-dashboard-box {
529
+ padding-right: 30px;
530
+ padding-bottom: 125px
531
+ }
532
+ .majorMinorExplain {
533
+ display: none;
534
+ }
535
+
536
+ /* Status */
537
+ table.cau_status_list .cau_status_name {
538
+ display: inline-block;
539
+ width: 50%;
540
+ box-sizing: border-box;
541
+ font-weight: 500;
542
+ }
543
+ table.cau_status_list .cau_status_interval {
544
+ display: none;
545
+ }
546
+ table.cau_status_list th.cau_status_next {
547
+ display: none;
548
+ }
549
+ table.cau_status_list td.cau_status_next {
550
+ display: block;
551
+ width: 100%;
552
+ }
553
+ table.cau_status_list .cau_status_active_state {
554
+ display: inline-block;
555
+ width: 50%;
556
+ box-sizing: border-box;
557
+ text-align: right;
558
+ }
559
+ .cau_mobile_prefix {
560
+ display: inline-block;
561
+ padding-right: 5px;
562
+ }
563
+ table.cau_status_list.cau_status_warnings td {
564
+ display: block;
565
+ width: 100%;
566
+ box-sizing: border-box;
567
+ }
568
+ table.cau_status_list.cau_status_warnings th.cau_plugin_issue_explain, table.cau_status_list.cau_status_warnings th.cau_plugin_issue_fixit {
569
+ display: none;
570
+ }
571
+ table.cau_status_list.cau_status_warnings td.cau_plugin_issue_name {
572
+ font-weight: 500;
573
+ }
574
+
575
  }
cau_emails.php CHANGED
@@ -1,512 +1,525 @@
1
- <?php
2
-
3
- // Check if emails should be send or not
4
- function cau_check_updates_mail() {
5
-
6
- // Notify of pending updates
7
- if( cau_get_db_value( 'send' ) == 'on' ) {
8
- cau_list_theme_updates(); // Check for theme updates
9
- cau_list_plugin_updates(); // Check for plugin updates
10
- }
11
-
12
- // Notify of completed updates
13
- if( cau_get_db_value( 'sendupdate' ) == 'on' && cau_get_db_value( 'plugins' ) == 'on' ) {
14
- cau_plugin_updated(); // Check for updated plugins
15
- }
16
-
17
- // Notify of required db update
18
- if( cau_get_db_value( 'dbupdateemails' ) == 'on' ) {
19
- cau_notify_outofdate_db();
20
- }
21
-
22
- }
23
-
24
- // Notify of out of date software
25
- function cau_outdated_notifier_mail() {
26
- if( cau_get_db_value( 'sendoutdated' ) == 'on' ) {
27
- cau_list_outdated_software(); // Check for oudated plugins
28
- }
29
- }
30
-
31
- // Ge the emailadresses it should be send to
32
- function cau_set_email() {
33
-
34
- $emailArray = array();
35
-
36
- if( cau_get_db_value( 'email' ) == '' ) {
37
- array_push( $emailArray, get_option('admin_email') );
38
- } else {
39
- $emailAdresses = cau_get_db_value( 'email' );
40
- $list = explode( ", ", $emailAdresses );
41
- foreach ( $list as $key ) {
42
- array_push( $emailArray, $list );
43
- }
44
- }
45
-
46
- return $emailArray;
47
-
48
- }
49
-
50
- // Mail format
51
- function cau_is_html() {
52
-
53
- // Check if cau_get_db_value() function exists.
54
- if ( !function_exists( 'cau_get_db_value' ) ) require_once( plugin_dir_path( __FILE__ ) . 'cau_function.php' );
55
-
56
- // Check if html
57
- if( cau_get_db_value( 'html_or_text' ) == 'html' ) {
58
- $html = true;
59
- } else {
60
- $html = false;
61
- }
62
-
63
- }
64
-
65
- // Set the content for the emails about pending updates
66
- function cau_outdated_message( $single, $plural, $list ) {
67
-
68
- // WP version
69
- $wpversion = get_bloginfo( 'version' );
70
-
71
- // Base text
72
- $text = sprintf( esc_html__( "You have %s on your WordPress site at %s that have not been tested with the latest 3 major releases of WordPress.", "companion-auto-update" ), $plural, get_site_url() );
73
- $text .= "\n";
74
- $text .= "\n";
75
-
76
- // The list
77
- if( !empty( $list ) ) {
78
-
79
- $text .= sprintf( esc_html__( "The following %s have not been tested with WordPress %s:", "companion-auto-update" ), $plural, $wpversion );
80
- $text .= "\n";
81
- $text .= "\n";
82
-
83
- foreach ( $list as $plugin => $version ) {
84
- if( $version == '' ) $version = __( "Unknown", "companion-auto-update" );
85
- $text .= "- ".sprintf( esc_html__( "%s tested up to: %s", "companion-auto-update" ), $plugin, $version )."\n";
86
- }
87
-
88
- }
89
-
90
- return $text;
91
-
92
- }
93
-
94
- // Set the content for the emails about pending updates
95
- function cau_pending_message( $single, $plural, $list ) {
96
-
97
- // What markup to use
98
- if( cau_is_html() ) $break = '<br />';
99
- else $break = "\n";
100
-
101
- // Base text
102
- $text = sprintf( esc_html__( 'You have pending %1$s updates on your WordPress site at %2$s.', 'companion-auto-update' ), $single, get_site_url() );
103
- $text .= $break;
104
-
105
- if( !empty( $list ) ) {
106
-
107
- $text .= $break;
108
- $text .= sprintf( esc_html__( 'The following %1$s have new versions available.', 'companion-auto-update' ), $plural );
109
- $text .= $break;
110
-
111
- if( cau_is_html() ) $text .= "<ol>";
112
- foreach ( $list as $key => $value ) {
113
- if( cau_is_html() ) {
114
- $text .= "<li>$value</li>";
115
- } else {
116
- $text .= "-$value\n";
117
- }
118
- }
119
- if( cau_is_html() ) $text .= "</ol>";
120
-
121
- $text .= $break;
122
- }
123
-
124
- $text .= __( 'Leaving your site outdated is a security risk so please consider manually updating them.', 'companion-auto-update' );
125
- $text .= $break;
126
-
127
- // End
128
- $text .= sprintf( esc_html__( 'Head over to %1$s and check the ones you want to update.', 'companion-auto-update' ), get_admin_url().'update-core.php' );
129
-
130
- return $text;
131
-
132
- }
133
-
134
- // Set the content for the emails about recent updates
135
- function cau_updated_message( $type, $updatedList ) {
136
-
137
- // What markup to use
138
- if( cau_is_html() ) $break = '<br />';
139
- else $break = "\n";
140
-
141
- // The message
142
- $text = sprintf( esc_html__(
143
- 'One or more %1$s on your WordPress site at %2$s have been updated by Companion Auto Update. No further action is needed on your part.
144
- For more info on what is new visit your dashboard and check the changelog.', 'companion-auto-update'
145
- ), $type, get_site_url() );
146
-
147
- $text .= $break;
148
- $text .= $break;
149
- $text .= sprintf( esc_html__(
150
- 'The following %1$s have been updated:', 'companion-auto-update'
151
- ), $type );
152
-
153
- $text .= $break;
154
- $text .= $updatedList;
155
-
156
- $text .= $break;
157
- $text .= __( "(You'll also receive this email if you manually updated a plugin or theme)", "companion-auto-update" );
158
-
159
- return $text;
160
-
161
- }
162
-
163
- // Checks if plugins are out of date
164
- function cau_list_outdated_software() {
165
-
166
- // Check if cau_get_db_value() function exists.
167
- if ( !function_exists( 'cau_get_db_value' ) ) require_once( plugin_dir_path( __FILE__ ) . 'cau_function.php' );
168
-
169
- // Set up mail
170
- $subject = '['.get_bloginfo( 'name' ).'] ' . __( 'You have outdated plugins on your site.', 'companion-auto-update' );
171
- $type = __( 'plugin', 'companion-auto-update' );
172
- $type_plural = __( 'plugins', 'companion-auto-update' );
173
- $message = cau_outdated_message( $type, $type_plural, cau_list_outdated() );
174
-
175
- // Send to all addresses
176
- foreach ( cau_set_email() as $key => $value ) {
177
- foreach ( $value as $k => $v ) {
178
- wp_mail( $v, $subject, $message );
179
- }
180
- break;
181
- }
182
-
183
- }
184
-
185
- // Checks if theme updates are available
186
- function cau_list_theme_updates() {
187
-
188
- global $wpdb;
189
- $table_name = $wpdb->prefix . "auto_updates";
190
-
191
- $configs = $wpdb->get_results( "SELECT * FROM $table_name WHERE name = 'themes'");
192
- foreach ( $configs as $config ) {
193
-
194
- if( $config->onoroff != 'on' ) {
195
-
196
- require_once ABSPATH . '/wp-admin/includes/update.php';
197
- $themes = get_theme_updates();
198
- $list = array();
199
-
200
- if ( !empty( $themes ) ) {
201
-
202
- foreach ( $themes as $stylesheet => $theme ) {
203
- array_push( $list, $theme->get( 'Name' ) );
204
- }
205
-
206
- $subject = '[' . get_bloginfo( 'name' ) . '] ' . __( 'Theme update available.', 'companion-auto-update' );
207
- $type = __('theme', 'companion-auto-update');
208
- $type_plural = __('themes', 'companion-auto-update');
209
- $message = cau_pending_message( $type, $type_plural, $list );
210
-
211
- foreach ( cau_set_email() as $key => $value) {
212
- foreach ($value as $k => $v) {
213
- wp_mail( $v, $subject, $message );
214
- }
215
- break;
216
- }
217
- }
218
-
219
- }
220
-
221
- }
222
-
223
- }
224
-
225
- // Checks if plugin updates are available
226
- function cau_list_plugin_updates() {
227
-
228
- global $wpdb;
229
- $table_name = $wpdb->prefix . "auto_updates";
230
-
231
- $configs = $wpdb->get_results( "SELECT * FROM $table_name WHERE name = 'plugins'");
232
- foreach ( $configs as $config ) {
233
-
234
- if( $config->onoroff != 'on' ) {
235
-
236
- require_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
237
-
238
- if ( !function_exists( 'get_plugin_updates' ) ) require_once ABSPATH . 'wp-admin/includes/update.php';
239
- $plugins = get_plugin_updates();
240
-
241
- if ( !empty( $plugins ) ) {
242
-
243
- $list = array();
244
- foreach ( (array) $plugins as $plugin_file => $plugin_data ) {
245
- $plugin_data = (object) _get_plugin_data_markup_translate( $plugin_file, (array) $plugin_data, false, true );
246
- $name = $plugin_data->Name;
247
- array_push( $list, $name );
248
- }
249
-
250
- $subject = '[' . get_bloginfo( 'name' ) . '] ' . __( 'Plugin update available.', 'companion-auto-update' );
251
- $type = __( 'plugin', 'companion-auto-update' );
252
- $type_plural = __( 'plugins', 'companion-auto-update' );
253
- $message = cau_pending_message( $type, $type_plural, $list );
254
-
255
- foreach ( cau_set_email() as $key => $value) {
256
- foreach ($value as $k => $v) {
257
- wp_mail( $v, $subject, $message );
258
- }
259
- break;
260
- }
261
- }
262
-
263
- }
264
-
265
- }
266
- }
267
-
268
- // Alerts when plugin has been updated
269
- function cau_plugin_updated() {
270
-
271
- // Check if cau_get_db_value() function exists.
272
- if ( !function_exists( 'cau_get_db_value' ) ) require_once( plugin_dir_path( __FILE__ ) . 'cau_function.php' );
273
-
274
- // Set the correct timezone for emails
275
- date_default_timezone_set( cau_get_proper_timezone() );
276
-
277
- // Create arrays
278
- $pluginNames = array();
279
- $pluginDates = array();
280
- $pluginVersion = array();
281
- $pluginSlug = array();
282
- $pluginTimes = array();
283
- $themeNames = array();
284
- $themeDates = array();
285
- $themeTimes = array();
286
-
287
- // Where to look for plugins
288
- $plugdir = plugin_dir_path( __DIR__ );
289
- if ( !function_exists( 'get_plugins' ) ) require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); // Check if get_plugins() function exists.
290
- $allPlugins = get_plugins();
291
-
292
- // Where to look for themes
293
- $themedir = get_theme_root();
294
- $allThemes = wp_get_themes();
295
-
296
- // Mail schedule
297
- $schedule_mail = wp_get_schedule( 'cau_set_schedule_mail' );
298
-
299
- // Loop trough all plugins
300
- foreach ( $allPlugins as $key => $value ) {
301
-
302
- // Get plugin data
303
- $fullPath = $plugdir.'/'.$key;
304
- $getFile = $path_parts = pathinfo( $fullPath );
305
- $pluginData = get_plugin_data( $fullPath );
306
-
307
- // Get the slug
308
- $explosion = explode( '/', $key );
309
- $actualSlug = array_shift( $explosion );
310
-
311
- // Get last update date
312
- $fileDate = date ( 'YmdHi', filemtime( $fullPath ) );
313
-
314
- switch ( $schedule_mail ) {
315
- case 'hourly':
316
- $lastday = date( 'YmdHi', strtotime( '-1 hour', time() ) );
317
- break;
318
- case 'twicedaily':
319
- $lastday = date( 'YmdHi', strtotime( '-12 hours', time() ) );
320
- break;
321
- default:
322
- $lastday = date( 'YmdHi', strtotime( '-1 day', time() ) );
323
- break;
324
- }
325
-
326
- $dateFormat = get_option( 'date_format' );
327
- $timestamp = date_i18n( $dateFormat, filemtime( $fullPath ) );
328
- $timestamp .= ' - '.date( 'H:i', filemtime( $fullPath ) );
329
-
330
- if( $fileDate >= $lastday ) {
331
-
332
- // Get plugin name
333
- foreach ( $pluginData as $dataKey => $dataValue ) {
334
- if( $dataKey == 'Name') {
335
- array_push( $pluginNames , $dataValue );
336
- }
337
- if( $dataKey == 'Version') {
338
- array_push( $pluginVersion , $dataValue );
339
- }
340
- }
341
-
342
- array_push( $pluginDates, $fileDate );
343
- array_push( $pluginSlug, $actualSlug );
344
- array_push( $pluginTimes, $timestamp );
345
- }
346
-
347
- }
348
-
349
- // Loop trough all themes
350
- foreach ( $allThemes as $key => $value ) {
351
-
352
- // Get theme data
353
- $fullPath = $themedir.'/'.$key;
354
- $getFile = $path_parts = pathinfo( $fullPath );
355
-
356
- // Get last update date
357
- $dateFormat = get_option( 'date_format' );
358
- $fileDate = date ( 'YmdHi', filemtime( $fullPath ) );
359
-
360
- if( $schedule_mail == 'hourly' ) {
361
- $lastday = date( 'YmdHi', strtotime( '-1 hour', time() ) );
362
- } elseif( $schedule_mail == 'twicedaily' ) {
363
- $lastday = date( 'YmdHi', strtotime( '-12 hours', time() ) );
364
- } elseif( $schedule_mail == 'daily' ) {
365
- $lastday = date( 'YmdHi', strtotime( '-1 day', time() ) );
366
- }
367
-
368
- $dateFormat = get_option( 'date_format' );
369
- $timestamp = date_i18n( $dateFormat, filemtime( $fullPath ) );
370
- $timestamp .= ' - '.date( 'H:i', filemtime( $fullPath ) );
371
-
372
- if( $fileDate >= $lastday ) {
373
- array_push( $themeNames, $path_parts['filename'] );
374
- array_push( $themeDates, $fileDate );
375
- array_push( $themeTimes, $timestamp );
376
- }
377
-
378
- }
379
-
380
- $totalNumP = 0;
381
- $totalNumT = 0;
382
- $updatedListP = '';
383
- $updatedListT = '';
384
-
385
- if( cau_get_db_value( 'html_or_text' ) == 'html' ) {
386
- $updatedListP .= '<ol>';
387
- $updatedListT .= '<ol>';
388
- }
389
-
390
- foreach ( $pluginDates as $key => $value ) {
391
-
392
- if( cau_get_db_value( 'html_or_text' ) == 'html' ) {
393
-
394
- $more_info = '';
395
- if( cau_get_db_value( 'advanced_info_emails' ) == 'on' ) $more_info = "<br /><span style='opacity: 0.5;'>".__( "Time of update", "companion-auto-update" ).": ".$pluginTimes[$key]."</span>";
396
-
397
- $updatedListP .= "<li>
398
- <strong>".$pluginNames[$key]." </strong><br />
399
- ".__( "to version", "companion-auto-update" )." ".$pluginVersion[$key]." <a href='https://wordpress.org/plugins/".$pluginSlug[$key]."/#developers'>".__( "Release notes", "companion-auto-update" )."</a>
400
- ".$more_info."
401
- </li>";
402
-
403
- } else {
404
-
405
- $updatedListP .= "- ".$pluginNames[$key]." ".__( "to version", "companion-auto-update" )." ".$pluginVersion[$key]."\n";
406
- $updatedListP .= " ".__( "Release notes", "companion-auto-update" ).": https://wordpress.org/plugins/".$pluginSlug[$key]."/#developers\n";
407
-
408
- }
409
-
410
- $totalNumP++;
411
- }
412
-
413
- foreach ( $themeNames as $key => $value ) {
414
-
415
- if( cau_get_db_value( 'html_or_text' ) == 'html' ) {
416
-
417
- $more_info = '';
418
- if( cau_get_db_value( 'advanced_info_emails' ) == 'on' ) $more_info = "<br /><span style='opacity: 0.5;'>".__( "Time of update", "companion-auto-update" ).": ".$themeTimes[$key]."</span>";
419
- $updatedListT .= "<li><strong>".$themeNames[$key]."</strong>".$more_info."</li>";
420
-
421
- } else {
422
- $updatedListT .= "- ".$themeNames[$key]."\n";
423
- }
424
-
425
- $totalNumT++;
426
- }
427
-
428
- if( cau_get_db_value( 'html_or_text' ) == 'html' ) {
429
- $updatedListP .= '</ol>';
430
- $updatedListT .= '</ol>';
431
- }
432
-
433
- // Set the email content type
434
- if( cau_get_db_value( 'html_or_text' ) == 'html' ) {
435
- function cau_mail_content_type() {
436
- return 'text/html';
437
- }
438
- add_filter( 'wp_mail_content_type', 'cau_mail_content_type' );
439
- }
440
-
441
- // If plugins have been updated, send email
442
- if( $totalNumP > 0 ) {
443
-
444
- // E-mail content
445
- $subject = '[' . get_bloginfo( 'name' ) . '] ' . __('One or more plugins have been updated.', 'companion-auto-update');
446
- $type = __('plugins', 'companion-auto-update');
447
- $message = cau_updated_message( $type, $updatedListP );
448
-
449
- // Send to all addresses
450
- foreach ( cau_set_email() as $key => $value) {
451
- foreach ($value as $k => $v) {
452
- wp_mail( $v, $subject, $message );
453
- }
454
- break;
455
- }
456
-
457
- }
458
-
459
- // If themes have been updated, send email
460
- if( $totalNumT > 0 ) {
461
-
462
- // E-mail content
463
- $subject = '[' . get_bloginfo( 'name' ) . '] ' . __('One or more themes have been updated.', 'companion-auto-update');
464
- $type = __('themes', 'companion-auto-update');
465
- $message = cau_updated_message( $type, $updatedListT );
466
-
467
- // Send to all addresses
468
- foreach ( cau_set_email() as $key => $value) {
469
- foreach ($value as $k => $v) {
470
- wp_mail( $v, $subject, $message );
471
- }
472
- break;
473
- }
474
-
475
- }
476
-
477
- if( cau_get_db_value( 'html_or_text' ) == 'html' ) remove_filter( 'wp_mail_content_type', 'cau_mail_content_type' );
478
-
479
- // Prevent duplicate emails by setting the event again
480
- if( $totalNumT > 0 OR $totalNumP > 0 ) {
481
- if( $schedule_mail == 'hourly' ) {
482
- wp_clear_scheduled_hook('cau_set_schedule_mail');
483
- wp_schedule_event( strtotime( '+1 hour', time() ) , 'hourly', 'cau_set_schedule_mail' );
484
- }
485
- }
486
-
487
- }
488
-
489
- function cau_notify_outofdate_db() {
490
-
491
- // Check if cau_get_db_value() function exists.
492
- if ( !function_exists( 'cau_get_db_value' ) ) require_once( plugin_dir_path( __FILE__ ) . 'cau_function.php' );
493
-
494
- // Database requires an update
495
- if ( cau_incorrectDatabaseVersion() ) {
496
-
497
- // Set up mail
498
- $subject = '[' . get_bloginfo( 'name' ) . '] ' . __( 'We need your help with something', 'companion-auto-update' );
499
- $message = __( 'Hi there! We need your help updating the database of Companion Auto Update to the latest version. No rush, old features will continue to work but some new features might not work until you update the database.', 'companion-auto-update' );
500
-
501
- // Send to all addresses
502
- foreach ( cau_set_email() as $key => $value ) {
503
- foreach ( $value as $k => $v ) {
504
- wp_mail( $v, $subject, $message );
505
- }
506
- break;
507
- }
508
-
509
- }
510
-
511
- }
512
-
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Check if emails should be send or not
4
+ function cau_check_updates_mail() {
5
+
6
+ // Notify of pending updates
7
+ if( cau_get_db_value( 'send' ) == 'on' ) {
8
+ cau_list_theme_updates(); // Check for theme updates
9
+ cau_list_plugin_updates(); // Check for plugin updates
10
+ }
11
+
12
+ // Notify of completed updates
13
+ if( cau_get_db_value( 'sendupdate' ) == 'on' && cau_get_db_value( 'plugins' ) == 'on' ) {
14
+ cau_plugin_updated(); // Check for updated plugins
15
+ }
16
+
17
+ // Notify of required db update
18
+ if( cau_get_db_value( 'dbupdateemails' ) == 'on' ) {
19
+ cau_notify_outofdate_db();
20
+ }
21
+
22
+ }
23
+
24
+ // Notify of out of date software
25
+ function cau_outdated_notifier_mail() {
26
+ if( cau_get_db_value( 'sendoutdated' ) == 'on' ) {
27
+ cau_list_outdated_software(); // Check for oudated plugins
28
+ }
29
+ }
30
+
31
+ // Ge the emailadresses it should be send to
32
+ function cau_set_email() {
33
+
34
+ $emailArray = array();
35
+
36
+ if( cau_get_db_value( 'email' ) == '' ) {
37
+ array_push( $emailArray, get_option('admin_email') );
38
+ } else {
39
+ $emailAdresses = cau_get_db_value( 'email' );
40
+ $list = explode( ", ", $emailAdresses );
41
+ foreach ( $list as $key ) {
42
+ array_push( $emailArray, $list );
43
+ }
44
+ }
45
+
46
+ return $emailArray;
47
+
48
+ }
49
+
50
+ // Mail format
51
+ function cau_is_html() {
52
+
53
+ // Check if cau_get_db_value() function exists.
54
+ if ( !function_exists( 'cau_get_db_value' ) ) require_once( plugin_dir_path( __FILE__ ) . 'cau_function.php' );
55
+
56
+ // Check if html
57
+ if( cau_get_db_value( 'html_or_text' ) == 'html' ) {
58
+ $html = true;
59
+ } else {
60
+ $html = false;
61
+ }
62
+
63
+ }
64
+
65
+ // Set the content for the emails about pending updates
66
+ function cau_outdated_message( $single, $plural, $list ) {
67
+
68
+ // WP version
69
+ $wpversion = get_bloginfo( 'version' );
70
+
71
+ // Base text
72
+ $text = sprintf( esc_html__( "You have %s on your WordPress site at %s that have not been tested with the latest 3 major releases of WordPress.", "companion-auto-update" ), $plural, get_site_url() );
73
+ $text .= "\n";
74
+ $text .= "\n";
75
+
76
+ // The list
77
+ if( !empty( $list ) ) {
78
+
79
+ $text .= sprintf( esc_html__( "The following %s have not been tested with WordPress %s:", "companion-auto-update" ), $plural, $wpversion );
80
+ $text .= "\n";
81
+ $text .= "\n";
82
+
83
+ foreach ( $list as $plugin => $version ) {
84
+ if( $version == '' ) $version = __( "Unknown", "companion-auto-update" );
85
+ $text .= "- ".sprintf( esc_html__( "%s tested up to: %s", "companion-auto-update" ), $plugin, $version )."\n";
86
+ }
87
+
88
+ }
89
+
90
+ return $text;
91
+
92
+ }
93
+
94
+ // Set the content for the emails about pending updates
95
+ function cau_pending_message( $single, $plural, $list ) {
96
+
97
+ // What markup to use
98
+ if( cau_is_html() ) $break = '<br />';
99
+ else $break = "\n";
100
+
101
+ // Base text
102
+ $text = sprintf( esc_html__( 'You have pending %1$s updates on your WordPress site at %2$s.', 'companion-auto-update' ), $single, get_site_url() );
103
+ $text .= $break;
104
+
105
+ if( !empty( $list ) ) {
106
+
107
+ $text .= $break;
108
+ $text .= sprintf( esc_html__( 'The following %1$s have new versions available.', 'companion-auto-update' ), $plural );
109
+ $text .= $break;
110
+
111
+ if( cau_is_html() ) $text .= "<ol>";
112
+ foreach ( $list as $key => $value ) {
113
+ if( cau_is_html() ) {
114
+ $text .= "<li>$value</li>";
115
+ } else {
116
+ $text .= "-$value\n";
117
+ }
118
+ }
119
+ if( cau_is_html() ) $text .= "</ol>";
120
+
121
+ $text .= $break;
122
+ }
123
+
124
+ $text .= __( 'Leaving your site outdated is a security risk so please consider manually updating them.', 'companion-auto-update' );
125
+ $text .= $break;
126
+
127
+ // End
128
+ $text .= sprintf( esc_html__( 'Head over to %1$s and check the ones you want to update.', 'companion-auto-update' ), get_admin_url().'update-core.php' );
129
+
130
+ return $text;
131
+
132
+ }
133
+
134
+ // Set the content for the emails about recent updates
135
+ function cau_updated_message( $type, $updatedList ) {
136
+
137
+ // What markup to use
138
+ if( cau_is_html() ) $break = '<br />';
139
+ else $break = "\n";
140
+
141
+ // The message
142
+ $text = sprintf( esc_html__(
143
+ 'One or more %1$s on your WordPress site at %2$s have been updated by Companion Auto Update. No further action is needed on your part.
144
+ For more info on what is new visit your dashboard and check the changelog.', 'companion-auto-update'
145
+ ), $type, get_site_url() );
146
+
147
+ $text .= $break;
148
+ $text .= $break;
149
+ $text .= sprintf( esc_html__(
150
+ 'The following %1$s have been updated:', 'companion-auto-update'
151
+ ), $type );
152
+
153
+ $text .= $break;
154
+ $text .= $updatedList;
155
+
156
+ $text .= $break;
157
+ $text .= __( "(You'll also receive this email if you manually updated a plugin or theme)", "companion-auto-update" );
158
+
159
+ return $text;
160
+
161
+ }
162
+
163
+ // Checks if plugins are out of date
164
+ function cau_list_outdated_software() {
165
+
166
+ // Check if cau_get_db_value() function exists.
167
+ if ( !function_exists( 'cau_get_db_value' ) ) require_once( plugin_dir_path( __FILE__ ) . 'cau_function.php' );
168
+
169
+ // Set up mail
170
+ $subject = '['.get_bloginfo( 'name' ).'] ' . __( 'You have outdated plugins on your site.', 'companion-auto-update' );
171
+ $type = __( 'plugin', 'companion-auto-update' );
172
+ $type_plural = __( 'plugins', 'companion-auto-update' );
173
+ $message = cau_outdated_message( $type, $type_plural, cau_list_outdated() );
174
+
175
+ // Send to all addresses
176
+ foreach ( cau_set_email() as $key => $value ) {
177
+ foreach ( $value as $k => $v ) {
178
+ wp_mail( $v, $subject, $message );
179
+ }
180
+ break;
181
+ }
182
+
183
+ }
184
+
185
+ // Checks if theme updates are available
186
+ function cau_list_theme_updates() {
187
+
188
+ global $wpdb;
189
+ $table_name = $wpdb->prefix . "auto_updates";
190
+
191
+ $configs = $wpdb->get_results( "SELECT * FROM $table_name WHERE name = 'themes'");
192
+ foreach ( $configs as $config ) {
193
+
194
+ if( $config->onoroff != 'on' ) {
195
+
196
+ require_once ABSPATH . '/wp-admin/includes/update.php';
197
+ $themes = get_theme_updates();
198
+ $list = array();
199
+
200
+ if ( !empty( $themes ) ) {
201
+
202
+ foreach ( $themes as $stylesheet => $theme ) {
203
+ array_push( $list, $theme->get( 'Name' ) );
204
+ }
205
+
206
+ $subject = '[' . get_bloginfo( 'name' ) . '] ' . __( 'Theme update available.', 'companion-auto-update' );
207
+ $type = __('theme', 'companion-auto-update');
208
+ $type_plural = __('themes', 'companion-auto-update');
209
+ $message = cau_pending_message( $type, $type_plural, $list );
210
+
211
+ foreach ( cau_set_email() as $key => $value) {
212
+ foreach ($value as $k => $v) {
213
+ wp_mail( $v, $subject, $message );
214
+ }
215
+ break;
216
+ }
217
+ }
218
+
219
+ }
220
+
221
+ }
222
+
223
+ }
224
+
225
+ // Checks if plugin updates are available
226
+ function cau_list_plugin_updates() {
227
+
228
+ global $wpdb;
229
+ $table_name = $wpdb->prefix . "auto_updates";
230
+
231
+ $configs = $wpdb->get_results( "SELECT * FROM $table_name WHERE name = 'plugins'");
232
+ foreach ( $configs as $config ) {
233
+
234
+ if( $config->onoroff != 'on' ) {
235
+
236
+ require_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
237
+
238
+ if ( !function_exists( 'get_plugin_updates' ) ) require_once ABSPATH . 'wp-admin/includes/update.php';
239
+ $plugins = get_plugin_updates();
240
+
241
+ if ( !empty( $plugins ) ) {
242
+
243
+ $list = array();
244
+ foreach ( (array) $plugins as $plugin_file => $plugin_data ) {
245
+ $plugin_data = (object) _get_plugin_data_markup_translate( $plugin_file, (array) $plugin_data, false, true );
246
+ $name = $plugin_data->Name;
247
+ array_push( $list, $name );
248
+ }
249
+
250
+ $subject = '[' . get_bloginfo( 'name' ) . '] ' . __( 'Plugin update available.', 'companion-auto-update' );
251
+ $type = __( 'plugin', 'companion-auto-update' );
252
+ $type_plural = __( 'plugins', 'companion-auto-update' );
253
+ $message = cau_pending_message( $type, $type_plural, $list );
254
+
255
+ foreach ( cau_set_email() as $key => $value) {
256
+ foreach ($value as $k => $v) {
257
+ wp_mail( $v, $subject, $message );
258
+ }
259
+ break;
260
+ }
261
+ }
262
+
263
+ }
264
+
265
+ }
266
+ }
267
+
268
+ // Alerts when plugin has been updated
269
+ function cau_plugin_updated() {
270
+
271
+ // Check if cau_get_db_value() function exists.
272
+ if ( !function_exists( 'cau_get_db_value' ) ) require_once( plugin_dir_path( __FILE__ ) . 'cau_function.php' );
273
+
274
+ // Set the correct timezone for emails
275
+ date_default_timezone_set( cau_get_proper_timezone() );
276
+
277
+ // Create arrays
278
+ $pluginNames = array();
279
+ $pluginDates = array();
280
+ $pluginVersion = array();
281
+ $pluginSlug = array();
282
+ $pluginTimes = array();
283
+ $themeNames = array();
284
+ $themeDates = array();
285
+ $themeTimes = array();
286
+
287
+ // Where to look for plugins
288
+ $plugdir = plugin_dir_path( __DIR__ );
289
+ if ( !function_exists( 'get_plugins' ) ) require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); // Check if get_plugins() function exists.
290
+ $allPlugins = get_plugins();
291
+
292
+ // Where to look for themes
293
+ $themedir = get_theme_root();
294
+ $allThemes = wp_get_themes();
295
+
296
+ // Mail schedule
297
+ $schedule_mail = wp_get_schedule( 'cau_set_schedule_mail' );
298
+
299
+ // Loop trough all plugins
300
+ foreach ( $allPlugins as $key => $value ) {
301
+
302
+ // Get plugin data
303
+ $fullPath = $plugdir.'/'.$key;
304
+ $getFile = $path_parts = pathinfo( $fullPath );
305
+ $pluginData = get_plugin_data( $fullPath );
306
+
307
+ // Get the slug
308
+ $explosion = explode( '/', $key );
309
+ $actualSlug = array_shift( $explosion );
310
+
311
+ // Get last update date
312
+ $fileDate = date ( 'YmdHi', filemtime( $fullPath ) );
313
+
314
+ switch ( $schedule_mail ) {
315
+ case 'hourly':
316
+ $lastday = date( 'YmdHi', strtotime( '-1 hour', time() ) );
317
+ break;
318
+ case 'twicedaily':
319
+ $lastday = date( 'YmdHi', strtotime( '-12 hours', time() ) );
320
+ break;
321
+ default:
322
+ $lastday = date( 'YmdHi', strtotime( '-1 day', time() ) );
323
+ break;
324
+ }
325
+
326
+ $dateFormat = get_option( 'date_format' );
327
+ $timestamp = date_i18n( $dateFormat, filemtime( $fullPath ) );
328
+ $timestamp .= ' - '.date( 'H:i', filemtime( $fullPath ) );
329
+
330
+ if( $fileDate >= $lastday ) {
331
+
332
+ // Get plugin name
333
+ foreach ( $pluginData as $dataKey => $dataValue ) {
334
+ if( $dataKey == 'Name') {
335
+ array_push( $pluginNames , $dataValue );
336
+ }
337
+ if( $dataKey == 'Version') {
338
+ array_push( $pluginVersion , $dataValue );
339
+ }
340
+ }
341
+
342
+ array_push( $pluginDates, $fileDate );
343
+ array_push( $pluginSlug, $actualSlug );
344
+ array_push( $pluginTimes, $timestamp );
345
+ }
346
+
347
+ }
348
+
349
+ // Loop trough all themes
350
+ foreach ( $allThemes as $key => $value ) {
351
+
352
+ // Get theme data
353
+ $fullPath = $themedir.'/'.$key;
354
+ $getFile = $path_parts = pathinfo( $fullPath );
355
+
356
+ // Get last update date
357
+ $dateFormat = get_option( 'date_format' );
358
+ $fileDate = date ( 'YmdHi', filemtime( $fullPath ) );
359
+
360
+ if( $schedule_mail == 'hourly' ) {
361
+ $lastday = date( 'YmdHi', strtotime( '-1 hour', time() ) );
362
+ } elseif( $schedule_mail == 'twicedaily' ) {
363
+ $lastday = date( 'YmdHi', strtotime( '-12 hours', time() ) );
364
+ } elseif( $schedule_mail == 'daily' ) {
365
+ $lastday = date( 'YmdHi', strtotime( '-1 day', time() ) );
366
+ }
367
+
368
+ $dateFormat = get_option( 'date_format' );
369
+ $timestamp = date_i18n( $dateFormat, filemtime( $fullPath ) );
370
+ $timestamp .= ' - '.date( 'H:i', filemtime( $fullPath ) );
371
+
372
+ if( $fileDate >= $lastday ) {
373
+ array_push( $themeNames, $path_parts['filename'] );
374
+ array_push( $themeDates, $fileDate );
375
+ array_push( $themeTimes, $timestamp );
376
+ }
377
+
378
+ }
379
+
380
+ $totalNumP = 0;
381
+ $totalNumT = 0;
382
+ $updatedListP = '';
383
+ $updatedListT = '';
384
+
385
+ if( cau_get_db_value( 'html_or_text' ) == 'html' ) {
386
+ $updatedListP .= '<ol>';
387
+ $updatedListT .= '<ol>';
388
+ }
389
+
390
+ foreach ( $pluginDates as $key => $value ) {
391
+
392
+ // Set up some var
393
+ $plugin_name = $pluginNames[$key];
394
+ $plugin_slug = $pluginSlug[$key];
395
+ $to_version = __( "to version", "companion-auto-update" ).' '.$pluginVersion[$key];
396
+ $more_info_arr = array( __( "Time of update", "companion-auto-update" ) => $pluginTimes[$key] );
397
+
398
+ // Plugin links
399
+ if( cau_get_db_value( 'plugin_links_emails' ) == 'on' ) {
400
+ $more_info_arr[__( "Plugin details", "companion-auto-update" )] = "<a href='https://wordpress.org/plugins/{$plugin_slug}/'>".__( "Visit", "companion-auto-update" )."</a>";
401
+ $more_info_arr[__( "Release notes", "companion-auto-update" )] = "<a href='https://wordpress.org/plugins/{$plugin_slug}/#developers'>".__( "Visit", "companion-auto-update" )."</a>";
402
+ $more_info_arr[__( "Support", "companion-auto-update" )] = "<a href='https://wordpress.org/support/plugin/{$plugin_slug}/'>".__( "Visit", "companion-auto-update" )."</a>";
403
+ }
404
+
405
+ // Email format
406
+ $use_html = ( cau_get_db_value( 'html_or_text' ) == 'html' ) ? true : false;
407
+
408
+ // Email content
409
+ $updatedListP .= $use_html ? "<li>" : "-"; // Start row
410
+
411
+ $updatedListP .= $use_html ? "<strong>{$plugin_name}</strong> " : "{$plugin_name} "; // Show plugin name
412
+ $updatedListP .= $to_version; // To version
413
+
414
+ // Get advanced info
415
+ if( cau_get_db_value( 'advanced_info_emails' ) == 'on' ) {
416
+ foreach( $more_info_arr as $label => $value ) {
417
+ $updatedListP .= $use_html ? "<br />{$label}: {$value}" : "\n{$label}: {$value}";
418
+ }
419
+ }
420
+
421
+ $updatedListP .= $use_html ? "</li>" : "\n"; // End row
422
+
423
+ $totalNumP++;
424
+ }
425
+
426
+ foreach ( $themeNames as $key => $value ) {
427
+
428
+ if( cau_get_db_value( 'html_or_text' ) == 'html' ) {
429
+
430
+ $more_info = '';
431
+ if( cau_get_db_value( 'advanced_info_emails' ) == 'on' ) $more_info = "<br /><span style='opacity: 0.5;'>".__( "Time of update", "companion-auto-update" ).": ".$themeTimes[$key]."</span>";
432
+ $updatedListT .= "<li><strong>".$themeNames[$key]."</strong>".$more_info."</li>";
433
+
434
+ } else {
435
+ $updatedListT .= "- ".$themeNames[$key]."\n";
436
+ }
437
+
438
+ $totalNumT++;
439
+ }
440
+
441
+ if( cau_get_db_value( 'html_or_text' ) == 'html' ) {
442
+ $updatedListP .= '</ol>';
443
+ $updatedListT .= '</ol>';
444
+ }
445
+
446
+ // Set the email content type
447
+ if( cau_get_db_value( 'html_or_text' ) == 'html' ) {
448
+ function cau_mail_content_type() {
449
+ return 'text/html';
450
+ }
451
+ add_filter( 'wp_mail_content_type', 'cau_mail_content_type' );
452
+ }
453
+
454
+ // If plugins have been updated, send email
455
+ if( $totalNumP > 0 ) {
456
+
457
+ // E-mail content
458
+ $subject = '[' . get_bloginfo( 'name' ) . '] ' . __('One or more plugins have been updated.', 'companion-auto-update');
459
+ $type = __('plugins', 'companion-auto-update');
460
+ $message = cau_updated_message( $type, $updatedListP );
461
+
462
+ // Send to all addresses
463
+ foreach ( cau_set_email() as $key => $value) {
464
+ foreach ($value as $k => $v) {
465
+ wp_mail( $v, $subject, $message );
466
+ }
467
+ break;
468
+ }
469
+
470
+ }
471
+
472
+ // If themes have been updated, send email
473
+ if( $totalNumT > 0 ) {
474
+
475
+ // E-mail content
476
+ $subject = '[' . get_bloginfo( 'name' ) . '] ' . __('One or more themes have been updated.', 'companion-auto-update');
477
+ $type = __('themes', 'companion-auto-update');
478
+ $message = cau_updated_message( $type, $updatedListT );
479
+
480
+ // Send to all addresses
481
+ foreach ( cau_set_email() as $key => $value) {
482
+ foreach ($value as $k => $v) {
483
+ wp_mail( $v, $subject, $message );
484
+ }
485
+ break;
486
+ }
487
+
488
+ }
489
+
490
+ if( cau_get_db_value( 'html_or_text' ) == 'html' ) remove_filter( 'wp_mail_content_type', 'cau_mail_content_type' );
491
+
492
+ // Prevent duplicate emails by setting the event again
493
+ if( $totalNumT > 0 OR $totalNumP > 0 ) {
494
+ if( $schedule_mail == 'hourly' ) {
495
+ wp_clear_scheduled_hook('cau_set_schedule_mail');
496
+ wp_schedule_event( strtotime( '+1 hour', time() ) , 'hourly', 'cau_set_schedule_mail' );
497
+ }
498
+ }
499
+
500
+ }
501
+
502
+ function cau_notify_outofdate_db() {
503
+
504
+ // Check if cau_get_db_value() function exists.
505
+ if ( !function_exists( 'cau_get_db_value' ) ) require_once( plugin_dir_path( __FILE__ ) . 'cau_function.php' );
506
+
507
+ // Database requires an update
508
+ if ( cau_incorrectDatabaseVersion() ) {
509
+
510
+ // Set up mail
511
+ $subject = '[' . get_bloginfo( 'name' ) . '] ' . __( 'We need your help with something', 'companion-auto-update' );
512
+ $message = __( 'Hi there! We need your help updating the database of Companion Auto Update to the latest version. No rush, old features will continue to work but some new features might not work until you update the database.', 'companion-auto-update' );
513
+
514
+ // Send to all addresses
515
+ foreach ( cau_set_email() as $key => $value ) {
516
+ foreach ( $value as $k => $v ) {
517
+ wp_mail( $v, $subject, $message );
518
+ }
519
+ break;
520
+ }
521
+
522
+ }
523
+
524
+ }
525
+
cau_functions.php CHANGED
@@ -1026,6 +1026,10 @@ function cau_list_outdated() {
1026
  if ( ! function_exists( 'get_plugins' ) ) {
1027
  require_once ABSPATH . 'wp-admin/includes/plugin.php';
1028
  }
 
 
 
 
1029
 
1030
  foreach ( get_plugins() as $key => $value) {
1031
 
@@ -1037,17 +1041,24 @@ function cau_list_outdated() {
1037
  foreach ( $value as $k => $v ) if( $k == "Name" ) $name = $v;
1038
 
1039
  // Get plugins tested up to version
1040
- if( !function_exists( 'plugins_api' ) ) require_once( ABSPATH.'wp-admin/includes/plugin-install.php' );
1041
- $api = plugins_api( 'plugin_information', array( 'slug' => wp_unslash( $actualSlug ) ) );
1042
 
1043
  // Version compare
1044
  $tested_version = substr( $api->tested, 0, 3 ); // Format version number
1045
- $current_version = substr( get_bloginfo( 'version' ), 0, 3 ); // Format version number
1046
- $version_difference = ($current_version - $tested_version); // Get the difference
1047
- // $tested_wp = ( empty( $api->tested ) || cau_version_compare( get_bloginfo( 'version' ), $api->tested, '<' ) );
1048
 
1049
- if( $version_difference >= '0.3' ) {
1050
- $outdatedList[$name] = substr( $api->tested, 0, 3 );
 
 
 
 
 
 
 
 
 
 
 
1051
  }
1052
 
1053
  }
1026
  if ( ! function_exists( 'get_plugins' ) ) {
1027
  require_once ABSPATH . 'wp-admin/includes/plugin.php';
1028
  }
1029
+
1030
+ if( !function_exists( 'plugins_api' ) ) {
1031
+ require_once( ABSPATH.'wp-admin/includes/plugin-install.php' );
1032
+ }
1033
 
1034
  foreach ( get_plugins() as $key => $value) {
1035
 
1041
  foreach ( $value as $k => $v ) if( $k == "Name" ) $name = $v;
1042
 
1043
  // Get plugins tested up to version
1044
+ $api = plugins_api( 'plugin_information', array( 'slug' => wp_unslash( $actualSlug ), 'tested' => true ) );
 
1045
 
1046
  // Version compare
1047
  $tested_version = substr( $api->tested, 0, 3 ); // Format version number
 
 
 
1048
 
1049
+ // Check if "tested up to" version number is set
1050
+ if( $tested_version != '' ) {
1051
+
1052
+ $current_version = substr( get_bloginfo( 'version' ), 0, 3 ); // Format version number
1053
+ $version_difference = ( (int)$current_version - (int)$tested_version ); // Get the difference
1054
+ // $tested_wp = ( empty( $api->tested ) || cau_version_compare( get_bloginfo( 'version' ), $api->tested, '<' ) );
1055
+
1056
+ if( $version_difference >= '0.3' ) {
1057
+ $outdatedList[$name] = substr( $api->tested, 0, 3 );
1058
+ }
1059
+
1060
+ } else {
1061
+ $outdatedList[$name] = ''; // We'll catch this when sending the e-mail
1062
  }
1063
 
1064
  }
companion-auto-update.php CHANGED
@@ -1,466 +1,467 @@
1
- <?php
2
- /*
3
- * Plugin Name: Companion Auto Update
4
- * Plugin URI: http://codeermeneer.nl/portfolio/companion-auto-update/
5
- * Description: This plugin auto updates all plugins, all themes and the wordpress core.
6
- * Version: 3.8.2
7
- * Author: Papin Schipper
8
- * Author URI: http://codeermeneer.nl/
9
- * Contributors: papin
10
- * License: GPLv2 or later
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_init() {
21
- load_plugin_textdomain( 'companion-auto-update', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); // Load language files (for backwards compat mostly)
22
- add_filter( 'plugins_auto_update_enabled', '__return_false' ); // Turn off default WP5.5 plugin update features to avoid confusion
23
- add_filter( 'themes_auto_update_enabled', '__return_false' ); // Turn off default WP5.5 theme update features to avoid confusion
24
- }
25
- add_action( 'init', 'cau_init' );
26
-
27
- // Set up the database and required schedules
28
- function cau_install( $network_wide ) {
29
- if ( is_multisite() && $network_wide ) {
30
- global $wpdb;
31
- $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
32
- foreach ( $blog_ids as $blog_id ) {
33
- switch_to_blog( $blog_id );
34
- cau_database_creation();
35
- restore_current_blog();
36
- }
37
- } else {
38
- cau_database_creation();
39
- }
40
- if (! wp_next_scheduled ( 'cau_set_schedule_mail' )) wp_schedule_event( time(), 'daily', 'cau_set_schedule_mail'); // Set schedule for basic notifcations
41
- if (! wp_next_scheduled ( 'cau_custom_hooks_plugins' )) wp_schedule_event( time(), 'daily', 'cau_custom_hooks_plugins'); // Run custom hooks on plugin updates
42
- if (! wp_next_scheduled ( 'cau_custom_hooks_themes' )) wp_schedule_event( time(), 'daily', 'cau_custom_hooks_themes'); // Run custom hooks on theme updates
43
- if (! wp_next_scheduled ( 'cau_log_updater' )) wp_schedule_event( ( time() - 1800 ), 'daily', 'cau_log_updater'); // Keep the log up to date
44
- if (! wp_next_scheduled ( 'cau_outdated_notifier' )) wp_schedule_event( time(), 'daily', 'cau_outdated_notifier'); // Set schedule for basic notifcations
45
- }
46
- add_action( 'cau_set_schedule_mail', 'cau_check_updates_mail' );
47
- add_action( 'cau_outdated_notifier', 'cau_outdated_notifier_mail' );
48
- add_action( 'wp_update_plugins', 'cau_run_custom_hooks_p' );
49
- add_action( 'wp_update_themes', 'cau_run_custom_hooks_t' );
50
- add_action( 'wp_version_check', 'cau_run_custom_hooks_c' );
51
-
52
- // Hourly event to keep the log up to date
53
- function cau_keep_log_uptodate() {
54
- cau_savePluginInformation(); // Check for new plugins and themes
55
- cau_check_delayed(); // Check for plugin delays
56
- }
57
- add_action( 'cau_log_updater', 'cau_keep_log_uptodate' );
58
-
59
- // Redirect to welcome screen on activation of plugin
60
- function cau_pluginActivateWelcome() {
61
- add_option( 'cau_redirectToWelcomeScreen', true );
62
- }
63
- register_activation_hook(__FILE__, 'cau_pluginActivateWelcome');
64
-
65
- function cau_pluginRedirectWelcomeScreen() {
66
- if ( get_option( 'cau_redirectToWelcomeScreen', false ) ) {
67
- delete_option( 'cau_redirectToWelcomeScreen' );
68
- if( !isset( $_GET['activate-multi'] ) ) {
69
- wp_redirect( admin_url( cau_menloc().'?page=cau-settings&welcome=1' ) );
70
- }
71
- }
72
- }
73
- add_action( 'admin_init', 'cau_pluginRedirectWelcomeScreen' );
74
-
75
- // Donate url
76
- function cau_donateUrl() {
77
- return 'https://www.paypal.me/dakel/10/';
78
- }
79
-
80
- // Database version
81
- function cau_db_version() {
82
- return '3.8.1';
83
- }
84
- function cau_database_creation() {
85
-
86
- global $wpdb;
87
-
88
- // Plugin db info
89
- $cau_db_version = cau_db_version();
90
- $autoupdates = $wpdb->prefix."auto_updates";
91
- $updateLog = $wpdb->prefix."update_log";
92
-
93
- // WordPress db info
94
- $charset_collate = $wpdb->get_charset_collate();
95
-
96
- // DB table creation queries
97
- $sql = "CREATE TABLE $autoupdates (
98
- id INT(9) NOT NULL AUTO_INCREMENT,
99
- name VARCHAR(255) NOT NULL,
100
- onoroff TEXT NOT NULL,
101
- UNIQUE KEY id (id)
102
- ) $charset_collate;";
103
-
104
- $sql2 = "CREATE TABLE $updateLog (
105
- id INT(9) NOT NULL AUTO_INCREMENT,
106
- slug VARCHAR(255) NOT NULL,
107
- oldVersion VARCHAR(10) NOT NULL,
108
- newVersion VARCHAR(10) NOT NULL,
109
- method VARCHAR(10) NOT NULL,
110
- put_on_hold VARCHAR(100) DEFAULT '0',
111
- UNIQUE KEY id (id)
112
- ) $charset_collate;";
113
-
114
- // Create DB tables
115
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
116
- dbDelta( $sql );
117
- dbDelta( $sql2 );
118
-
119
- // Database version
120
- add_option( "cau_db_version", "$cau_db_version" );
121
-
122
- // Insert data
123
- cau_install_data();
124
-
125
- }
126
-
127
- // Check if database table exists before creating
128
- function cau_check_if_exists( $whattocheck, $id = 'name', $db_table = 'auto_updates' ) {
129
-
130
- global $wpdb;
131
- $table_name = $wpdb->prefix.$db_table;
132
-
133
- $rows = $wpdb->get_col( "SELECT COUNT(*) as num_rows FROM {$table_name} WHERE {$id} = '{$whattocheck}'" );
134
- $check = $rows[0];
135
-
136
- if( $check > 0 ) {
137
- return true;
138
- } else {
139
- return false;
140
- }
141
-
142
- }
143
-
144
- // Insert date into database
145
- function cau_install_data() {
146
-
147
- global $wpdb;
148
- $table_name = $wpdb->prefix . "auto_updates";
149
- $toemail = get_option('admin_email');
150
-
151
- // Update configs
152
- if( !cau_check_if_exists( 'plugins' ) ) $wpdb->insert( $table_name, array( 'name' => 'plugins', 'onoroff' => 'on' ) );
153
- if( !cau_check_if_exists( 'themes' ) ) $wpdb->insert( $table_name, array( 'name' => 'themes', 'onoroff' => 'on' ) );
154
- if( !cau_check_if_exists( 'minor' ) ) $wpdb->insert( $table_name, array( 'name' => 'minor', 'onoroff' => 'on' ) );
155
- if( !cau_check_if_exists( 'major' ) ) $wpdb->insert( $table_name, array( 'name' => 'major', 'onoroff' => '' ) );
156
-
157
- // Email configs
158
- if( !cau_check_if_exists( 'email' ) ) $wpdb->insert( $table_name, array( 'name' => 'email', 'onoroff' => '' ) );
159
- if( !cau_check_if_exists( 'send' ) ) $wpdb->insert( $table_name, array( 'name' => 'send', 'onoroff' => '' ) );
160
- if( !cau_check_if_exists( 'sendupdate' ) ) $wpdb->insert( $table_name, array( 'name' => 'sendupdate', 'onoroff' => '' ) );
161
- if( !cau_check_if_exists( 'sendoutdated' ) ) $wpdb->insert( $table_name, array( 'name' => 'sendoutdated', 'onoroff' => '' ) );
162
-
163
- // Advanced
164
- if( !cau_check_if_exists( 'notUpdateList' ) ) $wpdb->insert( $table_name, array( 'name' => 'notUpdateList', 'onoroff' => '' ) );
165
- if( !cau_check_if_exists( 'translations' ) ) $wpdb->insert( $table_name, array( 'name' => 'translations', 'onoroff' => 'on' ) );
166
- if( !cau_check_if_exists( 'wpemails' ) ) $wpdb->insert( $table_name, array( 'name' => 'wpemails', 'onoroff' => 'on' ) );
167
- if( !cau_check_if_exists( 'notUpdateListTh' ) ) $wpdb->insert( $table_name, array( 'name' => 'notUpdateListTh', 'onoroff' => '' ) );
168
-
169
- // Stuff
170
- if( !cau_check_if_exists( 'html_or_text' ) ) $wpdb->insert( $table_name, array( 'name' => 'html_or_text', 'onoroff' => 'html' ) );
171
- if( !cau_check_if_exists( 'dbupdateemails' ) ) $wpdb->insert( $table_name, array( 'name' => 'dbupdateemails', 'onoroff' => '' ) );
172
-
173
- // Advanced
174
- if( !cau_check_if_exists( 'allow_administrator' ) ) $wpdb->insert( $table_name, array( 'name' => 'allow_administrator', 'onoroff' => 'on' ) );
175
- if( !cau_check_if_exists( 'allow_editor' ) ) $wpdb->insert( $table_name, array( 'name' => 'allow_editor', 'onoroff' => '' ) );
176
- if( !cau_check_if_exists( 'allow_author' ) ) $wpdb->insert( $table_name, array( 'name' => 'allow_author', 'onoroff' => '' ) );
177
- if( !cau_check_if_exists( 'ignore_seo' ) ) $wpdb->insert( $table_name, array( 'name' => 'ignore_seo', 'onoroff' => '' ) );
178
- if( !cau_check_if_exists( 'ignore_cron' ) ) $wpdb->insert( $table_name, array( 'name' => 'ignore_cron', 'onoroff' => '' ) );
179
- if( !cau_check_if_exists( 'advanced_info_emails' ) ) $wpdb->insert( $table_name, array( 'name' => 'advanced_info_emails', 'onoroff' => '' ) );
180
- if( !cau_check_if_exists( 'update_delay' ) ) $wpdb->insert( $table_name, array( 'name' => 'update_delay', 'onoroff' => '' ) );
181
- if( !cau_check_if_exists( 'update_delay_days' ) ) $wpdb->insert( $table_name, array( 'name' => 'update_delay_days', 'onoroff' => '' ) );
182
-
183
- }
184
- register_activation_hook( __FILE__, 'cau_install' );
185
-
186
- // Clear everything on deactivation
187
- function cau_remove() {
188
-
189
- // Delete tables
190
- global $wpdb;
191
- $autoupdates = $wpdb->prefix."auto_updates";
192
- $updateLog = $wpdb->prefix."update_log";
193
- $wpdb->query( "DROP TABLE IF EXISTS $autoupdates" );
194
- $wpdb->query( "DROP TABLE IF EXISTS $updateLog" );
195
-
196
- // Clear schedules
197
- wp_clear_scheduled_hook( 'cau_set_schedule_mail' );
198
- wp_clear_scheduled_hook( 'cau_custom_hooks_plugins' );
199
- wp_clear_scheduled_hook( 'cau_custom_hooks_themes' );
200
- wp_clear_scheduled_hook( 'cau_log_updater' );
201
-
202
- // Restore WordPress default update functionality
203
- add_filter( 'plugins_auto_update_enabled', '__return_true' );
204
- add_filter( 'themes_auto_update_enabled', '__return_true' );
205
- add_filter( 'auto_plugin_update_send_email', '__return_true' );
206
- add_filter( 'auto_theme_update_send_email', '__return_true' );
207
- }
208
- register_deactivation_hook( __FILE__, 'cau_remove' );
209
-
210
- // Update
211
- function cau_update_db_check() {
212
-
213
- $cau_db_version = cau_db_version();
214
-
215
- if ( get_site_option( 'cau_db_version' ) != $cau_db_version ) {
216
-
217
- cau_database_creation();
218
-
219
- // In 3.7.2 we've added $wpdb->get_charset_collate
220
- if( get_site_option( 'cau_db_version' ) < '3.7.2' ) {
221
-
222
- global $wpdb;
223
- $autoupdates = $wpdb->prefix."auto_updates";
224
- $updateLog = $wpdb->prefix."update_log";
225
- $db_charset = constant( 'DB_CHARSET' );
226
- $wpdb->query( "ALTER TABLE $autoupdates CONVERT TO CHARACTER SET $db_charset" );
227
- $wpdb->query( "ALTER TABLE $updateLog CONVERT TO CHARACTER SET $db_charset" );
228
-
229
- }
230
-
231
- update_option( "cau_db_version", $cau_db_version );
232
- }
233
-
234
- }
235
- add_action( 'upgrader_process_complete', 'cau_update_db_check' );
236
-
237
- // Manual update
238
- function cau_manual_update() {
239
- cau_update_db_check();
240
- }
241
-
242
- // Load custom functions
243
- require_once( plugin_dir_path( __FILE__ ) . 'cau_functions.php' );
244
-
245
- // Add plugin to menu
246
- function register_cau_menu_page() {
247
- 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' );
248
- }
249
- add_action( 'admin_menu', 'register_cau_menu_page' );
250
-
251
- // Settings page
252
- function cau_frontend() { ?>
253
-
254
- <div class='wrap cau_content_wrap cau_content'>
255
-
256
- <h1 class="wp-heading-inline"><?php _e( 'Companion Auto Update', 'companion-auto-update' ); ?></h1>
257
-
258
- <hr class="wp-header-end">
259
-
260
- <?php
261
-
262
- // Make sure the correct timezone is used
263
- date_default_timezone_set( cau_get_proper_timezone() );
264
-
265
- // Allow only access to these pages
266
- $allowedPages = array(
267
- 'dashboard' => __( 'Dashboard' ),
268
- 'pluginlist' => __( 'Update filter', 'companion-auto-update' ),
269
- 'log' => __( 'Update log', 'companion-auto-update' ),
270
- 'status' => __( 'Status', 'companion-auto-update' ),
271
- );
272
-
273
- // Show subtabs
274
- echo "<h2 class='nav-tab-wrapper wp-clearfix'>";
275
- foreach ( $allowedPages as $page => $title ) {
276
- echo "<a href='".cau_url( $page )."' id='tab-".$page."' class='nav-tab "._active_tab( $page )."'>".$title;
277
- if( $page == 'status' ) {
278
- if( cau_pluginHasIssues() ) {
279
- echo "<span class='cau_melding level-".cau_pluginIssueLevels()."'></span>";
280
- } else {
281
- echo "<span class='cau_melding level-okay'></span>";
282
- }
283
- }
284
- echo "</a>";
285
- }
286
- echo "</h2>";
287
-
288
- // Show page content
289
- if( !isset( $_GET['tab'] ) ) {
290
- $requestedPage = 'dashboard';
291
- echo "<script>jQuery('#tab-dashboard').addClass('nav-tab-active');</script>"; // Set active tab class
292
- } else {
293
- $requestedPage = sanitize_key( $_GET['tab'] );
294
- }
295
-
296
- if( array_key_exists( $requestedPage, $allowedPages ) ) {
297
- require_once( plugin_dir_path( __FILE__ ) . 'admin/'.$requestedPage.'.php' );
298
- } else {
299
- wp_die( 'You\'re not allowed to view <strong>'.$requestedPage.'</strong>.' );
300
- }
301
-
302
- ?>
303
-
304
- </div>
305
-
306
- <?php }
307
-
308
- // Add a widget to the dashboard.
309
- function cau_add_widget() {
310
- if ( cau_allowed_user_rights() ) wp_add_dashboard_widget( 'cau-update-log', __('Update log', 'companion-auto-update'), 'cau_widget' );
311
- }
312
- add_action( 'wp_dashboard_setup', 'cau_add_widget' );
313
-
314
- function cau_widget() {
315
-
316
- echo '<style>table.autoupdatewidget { border: 0px solid transparent; border-bottom: 1px solid #EEEEEE; margin: 0 -12px; width: calc(100% + 24px); } table.autoupdatewidget tr td { border-top: 1px solid #EEEEEE; padding: 9px 12px 5px 12px; background: #FAFAFA; } .cau_divide { display: inline-block; color: #E7E0DF; padding: 0 2px; } </style>';
317
- echo '<p>'.__('Below are the last 7 updates ran on this site. Includes plugins and themes, both automatically updated and manually updated.', 'companion-auto-update').'</p>';
318
- cau_fetch_log( '7' );
319
- echo '<p>
320
- <a href="'.cau_url( 'log' ).'">'.__('View full changelog', 'companion-auto-update').'</a>
321
- <span class="cau_divide">|</span>
322
- <a href="'.cau_url( 'dashboard' ).'">'.__( 'Settings' ).'</a>
323
- </p>';
324
-
325
- }
326
-
327
- // Load admin styles
328
- function load_cau_global_styles( $hook ) {
329
-
330
- // Plugin scripts
331
- wp_enqueue_style( 'cau_admin_styles', plugins_url( 'backend/style.css' , __FILE__ ) );
332
-
333
- // Check for issues
334
- wp_enqueue_style( 'cau_warning_styles', plugins_url( 'backend/warningbar.css' , __FILE__ ) );
335
-
336
- }
337
- add_action( 'admin_enqueue_scripts', 'load_cau_global_styles', 99 );
338
-
339
- // Load admin styles
340
- function load_cau_page_styles( $hook ) {
341
-
342
- // Only load on plugins' pages
343
- if( $hook != 'tools_page_cau-settings' && $hook != 'index_page_cau-settings' ) return;
344
-
345
- // WordPress scripts we need
346
- wp_enqueue_style( 'thickbox' );
347
- wp_enqueue_script( 'thickbox' );
348
- wp_enqueue_script( 'plugin-install' );
349
-
350
- }
351
- add_action( 'admin_enqueue_scripts', 'load_cau_page_styles', 100 );
352
-
353
- // Send e-mails
354
- require_once( plugin_dir_path( __FILE__ ) . 'cau_emails.php' );
355
-
356
- // Add settings link on plugin page
357
- function cau_settings_link( $links ) {
358
-
359
- $settings_link = '<a href="'.cau_url( 'dashboard' ).'">'.__( 'Settings' ).'</a>';
360
- $settings_link2 = '<a href="https://translate.wordpress.org/projects/wp-plugins/companion-auto-update">'.__( 'Help us translate', 'companion-auto-update' ).'</a>';
361
- $settings_link3 = '<a href="'.cau_donateUrl().'">'.__( 'Donate to help development', 'companion-auto-update' ).'</a>';
362
-
363
- array_unshift( $links, $settings_link2 );
364
- array_unshift( $links, $settings_link3 );
365
- if( cau_allowed_user_rights() ) array_unshift( $links, $settings_link );
366
-
367
- return $links;
368
-
369
- }
370
- $plugin = plugin_basename(__FILE__);
371
- add_filter( "plugin_action_links_$plugin", "cau_settings_link" );
372
-
373
- // Auto Update Class
374
- class CAU_auto_update {
375
-
376
- public function __construct() {
377
-
378
- // Enable Update filters
379
- add_action( 'plugins_loaded', array( &$this, 'CAU_auto_update_filters' ), 1 );
380
-
381
- }
382
-
383
- public function CAU_auto_update_filters() {
384
-
385
- global $wpdb;
386
- $table_name = $wpdb->prefix . "auto_updates";
387
-
388
- // Disable WP emails
389
- add_filter( 'auto_plugin_update_send_email', '__return_false' ); // Plugin updates
390
- add_filter( 'auto_theme_update_send_email', '__return_false' ); // Theme updates
391
-
392
- // Enable for major updates
393
- $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'major'");
394
- foreach ( $configs as $config ) {
395
- if( $config->onoroff == 'on' ) add_filter( 'allow_major_auto_core_updates', '__return_true', 1 ); // Turn on
396
- else add_filter( 'allow_major_auto_core_updates', '__return_false', 1 ); // Turn off
397
- }
398
-
399
- // Enable for minor updates
400
- $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'minor'");
401
- foreach ( $configs as $config ) {
402
- if( $config->onoroff == 'on' ) add_filter( 'allow_minor_auto_core_updates', '__return_true', 1 ); // Turn on
403
- else add_filter( 'allow_minor_auto_core_updates', '__return_false', 1 ); // Turn off
404
- }
405
-
406
- // Enable for plugins
407
- $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'plugins'");
408
- foreach ( $configs as $config ) {
409
- if( $config->onoroff == 'on' ) add_filter( 'auto_update_plugin', 'cau_dontUpdatePlugins', 10, 2 ); // Turn on
410
- else add_filter( 'auto_update_plugin', '__return_false', 1 ); // Turn off
411
- }
412
-
413
- // Enable for themes
414
- $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'themes'");
415
- foreach ( $configs as $config ) {
416
- if( $config->onoroff == 'on' ) add_filter( 'auto_update_theme', '__return_true' ); // Turn on
417
- else add_filter( 'auto_update_theme', '__return_false', 1 ); // Turn off
418
- }
419
-
420
- // Enable for translation files
421
- $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'translations'");
422
- foreach ( $configs as $config ) {
423
- if( $config->onoroff == 'on' ) add_filter( 'auto_update_translation', '__return_true', 1 ); // Turn on
424
- else add_filter( 'auto_update_translation', '__return_false', 1 ); // Turn off
425
- }
426
-
427
- // WP Email Config
428
- $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'wpemails'");
429
- foreach ( $configs as $config ) {
430
- if( $config->onoroff == 'on' ) {
431
- add_filter( 'auto_core_update_send_email', '__return_true' ); // Core updates
432
- } else {
433
- add_filter( 'auto_core_update_send_email', '__return_false' ); // Core updates
434
- }
435
- }
436
-
437
-
438
- }
439
-
440
- }
441
- new CAU_auto_update();
442
-
443
- // Check for issues
444
- function cau_checkForIssues( $admin_bar ) {
445
-
446
- if( cau_pluginHasIssues() && is_admin() ) {
447
-
448
- if( cau_pluginIssueLevels() == 'high' ) {
449
- $cauWaningBarTitle = __( 'Companion Auto Update ran into a critical error. View the status log for more info.', 'companion-auto-update' );
450
-
451
- $admin_bar->add_menu( array(
452
- 'id' => 'cau-has-issues',
453
- 'title' => '<span class="ab-icon"></span><span class="cau-level-'.cau_pluginIssueLevels().'">'.cau_pluginIssueCount().'</span>',
454
- 'href' => cau_url( 'status' ),
455
- 'meta' => array(
456
- 'target' => '_self',
457
- 'title' => $cauWaningBarTitle,
458
- ),
459
- ));
460
-
461
- }
462
-
463
- }
464
-
465
- }
466
- add_action( 'admin_bar_menu', 'cau_checkForIssues', 150 );
 
1
+ <?php
2
+ /*
3
+ * Plugin Name: Companion Auto Update
4
+ * Plugin URI: http://codeermeneer.nl/portfolio/companion-auto-update/
5
+ * Description: This plugin auto updates all plugins, all themes and the wordpress core.
6
+ * Version: 3.8.3
7
+ * Author: Papin Schipper
8
+ * Author URI: http://codeermeneer.nl/
9
+ * Contributors: papin
10
+ * License: GPLv2 or later
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_init() {
21
+ load_plugin_textdomain( 'companion-auto-update', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); // Load language files (for backwards compat mostly)
22
+ add_filter( 'plugins_auto_update_enabled', '__return_false' ); // Turn off default WP5.5 plugin update features to avoid confusion
23
+ add_filter( 'themes_auto_update_enabled', '__return_false' ); // Turn off default WP5.5 theme update features to avoid confusion
24
+ }
25
+ add_action( 'init', 'cau_init' );
26
+
27
+ // Set up the database and required schedules
28
+ function cau_install( $network_wide ) {
29
+ if ( is_multisite() && $network_wide ) {
30
+ global $wpdb;
31
+ $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
32
+ foreach ( $blog_ids as $blog_id ) {
33
+ switch_to_blog( $blog_id );
34
+ cau_database_creation();
35
+ restore_current_blog();
36
+ }
37
+ } else {
38
+ cau_database_creation();
39
+ }
40
+ if (! wp_next_scheduled ( 'cau_set_schedule_mail' )) wp_schedule_event( time(), 'daily', 'cau_set_schedule_mail'); // Set schedule for basic notifcations
41
+ if (! wp_next_scheduled ( 'cau_custom_hooks_plugins' )) wp_schedule_event( time(), 'daily', 'cau_custom_hooks_plugins'); // Run custom hooks on plugin updates
42
+ if (! wp_next_scheduled ( 'cau_custom_hooks_themes' )) wp_schedule_event( time(), 'daily', 'cau_custom_hooks_themes'); // Run custom hooks on theme updates
43
+ if (! wp_next_scheduled ( 'cau_log_updater' )) wp_schedule_event( ( time() - 1800 ), 'daily', 'cau_log_updater'); // Keep the log up to date
44
+ if (! wp_next_scheduled ( 'cau_outdated_notifier' )) wp_schedule_event( time(), 'daily', 'cau_outdated_notifier'); // Set schedule for basic notifcations
45
+ }
46
+ add_action( 'cau_set_schedule_mail', 'cau_check_updates_mail' );
47
+ add_action( 'cau_outdated_notifier', 'cau_outdated_notifier_mail' );
48
+ add_action( 'wp_update_plugins', 'cau_run_custom_hooks_p' );
49
+ add_action( 'wp_update_themes', 'cau_run_custom_hooks_t' );
50
+ add_action( 'wp_version_check', 'cau_run_custom_hooks_c' );
51
+
52
+ // Hourly event to keep the log up to date
53
+ function cau_keep_log_uptodate() {
54
+ cau_savePluginInformation(); // Check for new plugins and themes
55
+ cau_check_delayed(); // Check for plugin delays
56
+ }
57
+ add_action( 'cau_log_updater', 'cau_keep_log_uptodate' );
58
+
59
+ // Redirect to welcome screen on activation of plugin
60
+ function cau_pluginActivateWelcome() {
61
+ add_option( 'cau_redirectToWelcomeScreen', true );
62
+ }
63
+ register_activation_hook(__FILE__, 'cau_pluginActivateWelcome');
64
+
65
+ function cau_pluginRedirectWelcomeScreen() {
66
+ if ( get_option( 'cau_redirectToWelcomeScreen', false ) ) {
67
+ delete_option( 'cau_redirectToWelcomeScreen' );
68
+ if( !isset( $_GET['activate-multi'] ) ) {
69
+ wp_redirect( admin_url( cau_menloc().'?page=cau-settings&welcome=1' ) );
70
+ }
71
+ }
72
+ }
73
+ add_action( 'admin_init', 'cau_pluginRedirectWelcomeScreen' );
74
+
75
+ // Donate url
76
+ function cau_donateUrl() {
77
+ return 'https://www.paypal.me/dakel/10/';
78
+ }
79
+
80
+ // Database version
81
+ function cau_db_version() {
82
+ return '3.8.3';
83
+ }
84
+ function cau_database_creation() {
85
+
86
+ global $wpdb;
87
+
88
+ // Plugin db info
89
+ $cau_db_version = cau_db_version();
90
+ $autoupdates = $wpdb->prefix."auto_updates";
91
+ $updateLog = $wpdb->prefix."update_log";
92
+
93
+ // WordPress db info
94
+ $charset_collate = $wpdb->get_charset_collate();
95
+
96
+ // DB table creation queries
97
+ $sql = "CREATE TABLE $autoupdates (
98
+ id INT(9) NOT NULL AUTO_INCREMENT,
99
+ name VARCHAR(255) NOT NULL,
100
+ onoroff TEXT NOT NULL,
101
+ UNIQUE KEY id (id)
102
+ ) $charset_collate;";
103
+
104
+ $sql2 = "CREATE TABLE $updateLog (
105
+ id INT(9) NOT NULL AUTO_INCREMENT,
106
+ slug VARCHAR(255) NOT NULL,
107
+ oldVersion VARCHAR(10) NOT NULL,
108
+ newVersion VARCHAR(10) NOT NULL,
109
+ method VARCHAR(10) NOT NULL,
110
+ put_on_hold VARCHAR(100) DEFAULT '0',
111
+ UNIQUE KEY id (id)
112
+ ) $charset_collate;";
113
+
114
+ // Create DB tables
115
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
116
+ dbDelta( $sql );
117
+ dbDelta( $sql2 );
118
+
119
+ // Database version
120
+ add_option( "cau_db_version", "$cau_db_version" );
121
+
122
+ // Insert data
123
+ cau_install_data();
124
+
125
+ }
126
+
127
+ // Check if database table exists before creating
128
+ function cau_check_if_exists( $whattocheck, $id = 'name', $db_table = 'auto_updates' ) {
129
+
130
+ global $wpdb;
131
+ $table_name = $wpdb->prefix.$db_table;
132
+
133
+ $rows = $wpdb->get_col( "SELECT COUNT(*) as num_rows FROM {$table_name} WHERE {$id} = '{$whattocheck}'" );
134
+ $check = $rows[0];
135
+
136
+ if( $check > 0 ) {
137
+ return true;
138
+ } else {
139
+ return false;
140
+ }
141
+
142
+ }
143
+
144
+ // Insert date into database
145
+ function cau_install_data() {
146
+
147
+ global $wpdb;
148
+ $table_name = $wpdb->prefix . "auto_updates";
149
+ $toemail = get_option('admin_email');
150
+
151
+ // Update configs
152
+ if( !cau_check_if_exists( 'plugins' ) ) $wpdb->insert( $table_name, array( 'name' => 'plugins', 'onoroff' => 'on' ) );
153
+ if( !cau_check_if_exists( 'themes' ) ) $wpdb->insert( $table_name, array( 'name' => 'themes', 'onoroff' => 'on' ) );
154
+ if( !cau_check_if_exists( 'minor' ) ) $wpdb->insert( $table_name, array( 'name' => 'minor', 'onoroff' => 'on' ) );
155
+ if( !cau_check_if_exists( 'major' ) ) $wpdb->insert( $table_name, array( 'name' => 'major', 'onoroff' => '' ) );
156
+
157
+ // Email configs
158
+ if( !cau_check_if_exists( 'email' ) ) $wpdb->insert( $table_name, array( 'name' => 'email', 'onoroff' => '' ) );
159
+ if( !cau_check_if_exists( 'send' ) ) $wpdb->insert( $table_name, array( 'name' => 'send', 'onoroff' => '' ) );
160
+ if( !cau_check_if_exists( 'sendupdate' ) ) $wpdb->insert( $table_name, array( 'name' => 'sendupdate', 'onoroff' => '' ) );
161
+ if( !cau_check_if_exists( 'sendoutdated' ) ) $wpdb->insert( $table_name, array( 'name' => 'sendoutdated', 'onoroff' => '' ) );
162
+
163
+ // Advanced
164
+ if( !cau_check_if_exists( 'notUpdateList' ) ) $wpdb->insert( $table_name, array( 'name' => 'notUpdateList', 'onoroff' => '' ) );
165
+ if( !cau_check_if_exists( 'translations' ) ) $wpdb->insert( $table_name, array( 'name' => 'translations', 'onoroff' => 'on' ) );
166
+ if( !cau_check_if_exists( 'wpemails' ) ) $wpdb->insert( $table_name, array( 'name' => 'wpemails', 'onoroff' => 'on' ) );
167
+ if( !cau_check_if_exists( 'notUpdateListTh' ) ) $wpdb->insert( $table_name, array( 'name' => 'notUpdateListTh', 'onoroff' => '' ) );
168
+
169
+ // Stuff
170
+ if( !cau_check_if_exists( 'html_or_text' ) ) $wpdb->insert( $table_name, array( 'name' => 'html_or_text', 'onoroff' => 'html' ) );
171
+ if( !cau_check_if_exists( 'dbupdateemails' ) ) $wpdb->insert( $table_name, array( 'name' => 'dbupdateemails', 'onoroff' => '' ) );
172
+
173
+ // Advanced
174
+ if( !cau_check_if_exists( 'allow_administrator' ) ) $wpdb->insert( $table_name, array( 'name' => 'allow_administrator', 'onoroff' => 'on' ) );
175
+ if( !cau_check_if_exists( 'allow_editor' ) ) $wpdb->insert( $table_name, array( 'name' => 'allow_editor', 'onoroff' => '' ) );
176
+ if( !cau_check_if_exists( 'allow_author' ) ) $wpdb->insert( $table_name, array( 'name' => 'allow_author', 'onoroff' => '' ) );
177
+ if( !cau_check_if_exists( 'ignore_seo' ) ) $wpdb->insert( $table_name, array( 'name' => 'ignore_seo', 'onoroff' => '' ) );
178
+ if( !cau_check_if_exists( 'ignore_cron' ) ) $wpdb->insert( $table_name, array( 'name' => 'ignore_cron', 'onoroff' => '' ) );
179
+ if( !cau_check_if_exists( 'advanced_info_emails' ) ) $wpdb->insert( $table_name, array( 'name' => 'advanced_info_emails', 'onoroff' => '' ) );
180
+ if( !cau_check_if_exists( 'update_delay' ) ) $wpdb->insert( $table_name, array( 'name' => 'update_delay', 'onoroff' => '' ) );
181
+ if( !cau_check_if_exists( 'update_delay_days' ) ) $wpdb->insert( $table_name, array( 'name' => 'update_delay_days', 'onoroff' => '' ) );
182
+ if( !cau_check_if_exists( 'plugin_links_emails' ) ) $wpdb->insert( $table_name, array( 'name' => 'plugin_links_emails', 'onoroff' => '' ) );
183
+
184
+ }
185
+ register_activation_hook( __FILE__, 'cau_install' );
186
+
187
+ // Clear everything on deactivation
188
+ function cau_remove() {
189
+
190
+ // Delete tables
191
+ global $wpdb;
192
+ $autoupdates = $wpdb->prefix."auto_updates";
193
+ $updateLog = $wpdb->prefix."update_log";
194
+ $wpdb->query( "DROP TABLE IF EXISTS $autoupdates" );
195
+ $wpdb->query( "DROP TABLE IF EXISTS $updateLog" );
196
+
197
+ // Clear schedules
198
+ wp_clear_scheduled_hook( 'cau_set_schedule_mail' );
199
+ wp_clear_scheduled_hook( 'cau_custom_hooks_plugins' );
200
+ wp_clear_scheduled_hook( 'cau_custom_hooks_themes' );
201
+ wp_clear_scheduled_hook( 'cau_log_updater' );
202
+
203
+ // Restore WordPress default update functionality
204
+ add_filter( 'plugins_auto_update_enabled', '__return_true' );
205
+ add_filter( 'themes_auto_update_enabled', '__return_true' );
206
+ add_filter( 'auto_plugin_update_send_email', '__return_true' );
207
+ add_filter( 'auto_theme_update_send_email', '__return_true' );
208
+ }
209
+ register_deactivation_hook( __FILE__, 'cau_remove' );
210
+
211
+ // Update
212
+ function cau_update_db_check() {
213
+
214
+ $cau_db_version = cau_db_version();
215
+
216
+ if ( get_site_option( 'cau_db_version' ) != $cau_db_version ) {
217
+
218
+ cau_database_creation();
219
+
220
+ // In 3.7.2 we've added $wpdb->get_charset_collate
221
+ if( get_site_option( 'cau_db_version' ) < '3.7.2' ) {
222
+
223
+ global $wpdb;
224
+ $autoupdates = $wpdb->prefix."auto_updates";
225
+ $updateLog = $wpdb->prefix."update_log";
226
+ $db_charset = constant( 'DB_CHARSET' );
227
+ $wpdb->query( "ALTER TABLE $autoupdates CONVERT TO CHARACTER SET $db_charset" );
228
+ $wpdb->query( "ALTER TABLE $updateLog CONVERT TO CHARACTER SET $db_charset" );
229
+
230
+ }
231
+
232
+ update_option( "cau_db_version", $cau_db_version );
233
+ }
234
+
235
+ }
236
+ add_action( 'upgrader_process_complete', 'cau_update_db_check' );
237
+
238
+ // Manual update
239
+ function cau_manual_update() {
240
+ cau_update_db_check();
241
+ }
242
+
243
+ // Load custom functions
244
+ require_once( plugin_dir_path( __FILE__ ) . 'cau_functions.php' );
245
+
246
+ // Add plugin to menu
247
+ function register_cau_menu_page() {
248
+ 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' );
249
+ }
250
+ add_action( 'admin_menu', 'register_cau_menu_page' );
251
+
252
+ // Settings page
253
+ function cau_frontend() { ?>
254
+
255
+ <div class='wrap cau_content_wrap cau_content'>
256
+
257
+ <h1 class="wp-heading-inline"><?php _e( 'Companion Auto Update', 'companion-auto-update' ); ?></h1>
258
+
259
+ <hr class="wp-header-end">
260
+
261
+ <?php
262
+
263
+ // Make sure the correct timezone is used
264
+ date_default_timezone_set( cau_get_proper_timezone() );
265
+
266
+ // Allow only access to these pages
267
+ $allowedPages = array(
268
+ 'dashboard' => __( 'Dashboard' ),
269
+ 'pluginlist' => __( 'Update filter', 'companion-auto-update' ),
270
+ 'log' => __( 'Update log', 'companion-auto-update' ),
271
+ 'status' => __( 'Status', 'companion-auto-update' ),
272
+ );
273
+
274
+ // Show subtabs
275
+ echo "<h2 class='nav-tab-wrapper wp-clearfix'>";
276
+ foreach ( $allowedPages as $page => $title ) {
277
+ echo "<a href='".cau_url( $page )."' id='tab-".$page."' class='nav-tab "._active_tab( $page )."'>".$title;
278
+ if( $page == 'status' ) {
279
+ if( cau_pluginHasIssues() ) {
280
+ echo "<span class='cau_melding level-".cau_pluginIssueLevels()."'></span>";
281
+ } else {
282
+ echo "<span class='cau_melding level-okay'></span>";
283
+ }
284
+ }
285
+ echo "</a>";
286
+ }
287
+ echo "</h2>";
288
+
289
+ // Show page content
290
+ if( !isset( $_GET['tab'] ) ) {
291
+ $requestedPage = 'dashboard';
292
+ echo "<script>jQuery('#tab-dashboard').addClass('nav-tab-active');</script>"; // Set active tab class
293
+ } else {
294
+ $requestedPage = sanitize_key( $_GET['tab'] );
295
+ }
296
+
297
+ if( array_key_exists( $requestedPage, $allowedPages ) ) {
298
+ require_once( plugin_dir_path( __FILE__ ) . 'admin/'.$requestedPage.'.php' );
299
+ } else {
300
+ wp_die( 'You\'re not allowed to view <strong>'.$requestedPage.'</strong>.' );
301
+ }
302
+
303
+ ?>
304
+
305
+ </div>
306
+
307
+ <?php }
308
+
309
+ // Add a widget to the dashboard.
310
+ function cau_add_widget() {
311
+ if ( cau_allowed_user_rights() ) wp_add_dashboard_widget( 'cau-update-log', __('Update log', 'companion-auto-update'), 'cau_widget' );
312
+ }
313
+ add_action( 'wp_dashboard_setup', 'cau_add_widget' );
314
+
315
+ function cau_widget() {
316
+
317
+ echo '<style>table.autoupdatewidget { border: 0px solid transparent; border-bottom: 1px solid #EEEEEE; margin: 0 -12px; width: calc(100% + 24px); } table.autoupdatewidget tr td { border-top: 1px solid #EEEEEE; padding: 9px 12px 5px 12px; background: #FAFAFA; } .cau_divide { display: inline-block; color: #E7E0DF; padding: 0 2px; } </style>';
318
+ echo '<p>'.__('Below are the last 7 updates ran on this site. Includes plugins and themes, both automatically updated and manually updated.', 'companion-auto-update').'</p>';
319
+ cau_fetch_log( '7' );
320
+ echo '<p>
321
+ <a href="'.cau_url( 'log' ).'">'.__('View full changelog', 'companion-auto-update').'</a>
322
+ <span class="cau_divide">|</span>
323
+ <a href="'.cau_url( 'dashboard' ).'">'.__( 'Settings' ).'</a>
324
+ </p>';
325
+
326
+ }
327
+
328
+ // Load admin styles
329
+ function load_cau_global_styles( $hook ) {
330
+
331
+ // Plugin scripts
332
+ wp_enqueue_style( 'cau_admin_styles', plugins_url( 'backend/style.css' , __FILE__ ) );
333
+
334
+ // Check for issues
335
+ wp_enqueue_style( 'cau_warning_styles', plugins_url( 'backend/warningbar.css' , __FILE__ ) );
336
+
337
+ }
338
+ add_action( 'admin_enqueue_scripts', 'load_cau_global_styles', 99 );
339
+
340
+ // Load admin styles
341
+ function load_cau_page_styles( $hook ) {
342
+
343
+ // Only load on plugins' pages
344
+ if( $hook != 'tools_page_cau-settings' && $hook != 'index_page_cau-settings' ) return;
345
+
346
+ // WordPress scripts we need
347
+ wp_enqueue_style( 'thickbox' );
348
+ wp_enqueue_script( 'thickbox' );
349
+ wp_enqueue_script( 'plugin-install' );
350
+
351
+ }
352
+ add_action( 'admin_enqueue_scripts', 'load_cau_page_styles', 100 );
353
+
354
+ // Send e-mails
355
+ require_once( plugin_dir_path( __FILE__ ) . 'cau_emails.php' );
356
+
357
+ // Add settings link on plugin page
358
+ function cau_settings_link( $links ) {
359
+
360
+ $settings_link = '<a href="'.cau_url( 'dashboard' ).'">'.__( 'Settings' ).'</a>';
361
+ $settings_link2 = '<a href="https://translate.wordpress.org/projects/wp-plugins/companion-auto-update">'.__( 'Help us translate', 'companion-auto-update' ).'</a>';
362
+ $settings_link3 = '<a href="'.cau_donateUrl().'">'.__( 'Donate to help development', 'companion-auto-update' ).'</a>';
363
+
364
+ array_unshift( $links, $settings_link2 );
365
+ array_unshift( $links, $settings_link3 );
366
+ if( cau_allowed_user_rights() ) array_unshift( $links, $settings_link );
367
+
368
+ return $links;
369
+
370
+ }
371
+ $plugin = plugin_basename(__FILE__);
372
+ add_filter( "plugin_action_links_$plugin", "cau_settings_link" );
373
+
374
+ // Auto Update Class
375
+ class CAU_auto_update {
376
+
377
+ public function __construct() {
378
+
379
+ // Enable Update filters
380
+ add_action( 'plugins_loaded', array( &$this, 'CAU_auto_update_filters' ), 1 );
381
+
382
+ }
383
+
384
+ public function CAU_auto_update_filters() {
385
+
386
+ global $wpdb;
387
+ $table_name = $wpdb->prefix . "auto_updates";
388
+
389
+ // Disable WP emails
390
+ add_filter( 'auto_plugin_update_send_email', '__return_false' ); // Plugin updates
391
+ add_filter( 'auto_theme_update_send_email', '__return_false' ); // Theme updates
392
+
393
+ // Enable for major updates
394
+ $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'major'");
395
+ foreach ( $configs as $config ) {
396
+ if( $config->onoroff == 'on' ) add_filter( 'allow_major_auto_core_updates', '__return_true', 1 ); // Turn on
397
+ else add_filter( 'allow_major_auto_core_updates', '__return_false', 1 ); // Turn off
398
+ }
399
+
400
+ // Enable for minor updates
401
+ $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'minor'");
402
+ foreach ( $configs as $config ) {
403
+ if( $config->onoroff == 'on' ) add_filter( 'allow_minor_auto_core_updates', '__return_true', 1 ); // Turn on
404
+ else add_filter( 'allow_minor_auto_core_updates', '__return_false', 1 ); // Turn off
405
+ }
406
+
407
+ // Enable for plugins
408
+ $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'plugins'");
409
+ foreach ( $configs as $config ) {
410
+ if( $config->onoroff == 'on' ) add_filter( 'auto_update_plugin', 'cau_dontUpdatePlugins', 10, 2 ); // Turn on
411
+ else add_filter( 'auto_update_plugin', '__return_false', 1 ); // Turn off
412
+ }
413
+
414
+ // Enable for themes
415
+ $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'themes'");
416
+ foreach ( $configs as $config ) {
417
+ if( $config->onoroff == 'on' ) add_filter( 'auto_update_theme', '__return_true' ); // Turn on
418
+ else add_filter( 'auto_update_theme', '__return_false', 1 ); // Turn off
419
+ }
420
+
421
+ // Enable for translation files
422
+ $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'translations'");
423
+ foreach ( $configs as $config ) {
424
+ if( $config->onoroff == 'on' ) add_filter( 'auto_update_translation', '__return_true', 1 ); // Turn on
425
+ else add_filter( 'auto_update_translation', '__return_false', 1 ); // Turn off
426
+ }
427
+
428
+ // WP Email Config
429
+ $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'wpemails'");
430
+ foreach ( $configs as $config ) {
431
+ if( $config->onoroff == 'on' ) {
432
+ add_filter( 'auto_core_update_send_email', '__return_true' ); // Core updates
433
+ } else {
434
+ add_filter( 'auto_core_update_send_email', '__return_false' ); // Core updates
435
+ }
436
+ }
437
+
438
+
439
+ }
440
+
441
+ }
442
+ new CAU_auto_update();
443
+
444
+ // Check for issues
445
+ function cau_checkForIssues( $admin_bar ) {
446
+
447
+ if( cau_pluginHasIssues() && is_admin() ) {
448
+
449
+ if( cau_pluginIssueLevels() == 'high' ) {
450
+ $cauWaningBarTitle = __( 'Companion Auto Update ran into a critical error. View the status log for more info.', 'companion-auto-update' );
451
+
452
+ $admin_bar->add_menu( array(
453
+ 'id' => 'cau-has-issues',
454
+ 'title' => '<span class="ab-icon"></span><span class="cau-level-'.cau_pluginIssueLevels().'">'.cau_pluginIssueCount().'</span>',
455
+ 'href' => cau_url( 'status' ),
456
+ 'meta' => array(
457
+ 'target' => '_self',
458
+ 'title' => $cauWaningBarTitle,
459
+ ),
460
+ ));
461
+
462
+ }
463
+
464
+ }
465
+
466
+ }
467
+ add_action( 'admin_bar_menu', 'cau_checkForIssues', 150 );
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: Papin, qweb
3
  Donate link: https://www.paypal.me/dakel/10/
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.6.0
6
- Tested up to: 5.7
7
  Requires PHP: 5.1
8
- Stable tag: 3.8.2
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -81,6 +81,11 @@ So obviously, some of you wondered what the difference would be between the defa
81
 
82
  == Changelog ==
83
 
 
 
 
 
 
84
  = 3.8.2 (July 1, 2021) =
85
  * Fix: Error: Call to undefined function get_plugin_updates()
86
 
3
  Donate link: https://www.paypal.me/dakel/10/
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.6.0
6
+ Tested up to: 5.9
7
  Requires PHP: 5.1
8
+ Stable tag: 3.8.3
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
81
 
82
  == Changelog ==
83
 
84
+ = 3.8.3 (December 9, 2021) =
85
+ * New: Plugin update e-mails now have an option to link to a few important pages
86
+ * Fix: Error: Undefined index: dbupdateemails
87
+ * Fix: Error: A non-numeric value encountered
88
+
89
  = 3.8.2 (July 1, 2021) =
90
  * Fix: Error: Call to undefined function get_plugin_updates()
91