Companion Auto Update - Version 3.8.1

Version Description

(June 4, 2021) = * New: Be notified when we need your help updating to a new database version Feature Request * Tweak: Made some under the hood performance improvements

Download this release

Release Info

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

Code changes from version 3.8.0 to 3.8.1

Files changed (7) hide show
  1. admin/dashboard.php +572 -558
  2. backend/style.css +566 -546
  3. cau_emails.php +510 -480
  4. cau_functions.php +1429 -1429
  5. companion-auto-update.php +466 -465
  6. index.php +1 -1
  7. readme.txt +7 -3
admin/dashboard.php CHANGED
@@ -1,559 +1,573 @@
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
- if( isset( $_POST['plugins'] ) ) $plugins = sanitize_text_field( $_POST['plugins'] ); else $plugins = '';
30
- if( isset( $_POST['themes'] ) ) $themes = sanitize_text_field( $_POST['themes'] ); else $themes = '';
31
- if( isset( $_POST['minor'] ) ) $minor = sanitize_text_field( $_POST['minor'] ); else $minor = '';
32
- if( isset( $_POST['major'] ) ) $major = sanitize_text_field( $_POST['major'] ); else $major = '';
33
- if( isset( $_POST['translations'] ) ) $translations = sanitize_text_field( $_POST['translations'] ); else $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
- if( isset( $_POST['cau_send'] ) ) $send = sanitize_text_field( $_POST['cau_send'] ); else $send = '';
43
- if( isset( $_POST['cau_send_update'] ) ) $sendupdate = sanitize_text_field( $_POST['cau_send_update'] ); else $sendupdate = '';
44
- if( isset( $_POST['cau_send_outdated'] ) ) $sendoutdated = sanitize_text_field( $_POST['cau_send_outdated'] ); else $sendoutdated = '';
45
- if( isset( $_POST['wpemails'] ) ) $wpemails = sanitize_text_field( $_POST['wpemails'] ); else $wpemails = '';
46
- if( isset( $_POST['cau_email'] ) ) $email = sanitize_text_field( $_POST['cau_email'] );
47
- if( isset( $_POST['html_or_text'] ) ) $html_or_text = sanitize_text_field( $_POST['html_or_text'] );
48
-
49
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'email'", $email ) );
50
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'send'", $send ) );
51
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'sendupdate'", $sendupdate ) );
52
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'sendoutdated'", $sendoutdated ) );
53
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'wpemails'", $wpemails ) );
54
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'html_or_text'", $html_or_text ) );
55
-
56
- // Advanced
57
- if( isset( $_POST['allow_editor'] ) ) $allow_editor = sanitize_text_field( $_POST['allow_editor'] ); else $allow_editor = '';
58
- if( isset( $_POST['allow_author'] ) ) $allow_author = sanitize_text_field( $_POST['allow_author'] ); else $allow_author = '';
59
- if( isset( $_POST['advanced_info_emails'] ) ) $advanced_info_emails = sanitize_text_field( $_POST['advanced_info_emails'] ); else $advanced_info_emails = '';
60
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'allow_editor'", $allow_editor ) );
61
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'allow_author'", $allow_author ) );
62
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'advanced_info_emails'", $advanced_info_emails ) );
63
-
64
- // Delay
65
- if( isset( $_POST['update_delay'] ) ) $update_delay = sanitize_text_field( $_POST['update_delay'] ); else $update_delay = '';
66
- if( isset( $_POST['update_delay_days'] ) ) $update_delay_days = sanitize_text_field( $_POST['update_delay_days'] ); else $update_delay_days = '';
67
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'update_delay'", $update_delay ) );
68
- $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'update_delay_days'", $update_delay_days ) );
69
-
70
- // Intervals
71
-
72
- // Set variables
73
- $plugin_sc = sanitize_text_field( $_POST['plugin_schedule'] );
74
- $theme_sc = sanitize_text_field( $_POST['theme_schedule'] );
75
- $core_sc = sanitize_text_field( $_POST['core_schedule'] );
76
- $schedule_mail = sanitize_text_field( $_POST['update_notifications'] );
77
- $outdated_notifier = sanitize_text_field( $_POST['outdated_notifier'] );
78
- $html_or_text = sanitize_text_field( $_POST['html_or_text'] );
79
-
80
- // First clear schedules
81
- wp_clear_scheduled_hook('wp_update_plugins');
82
- wp_clear_scheduled_hook('wp_update_themes');
83
- wp_clear_scheduled_hook('wp_version_check');
84
- wp_clear_scheduled_hook('cau_set_schedule_mail');
85
- wp_clear_scheduled_hook('cau_custom_hooks_plugins');
86
- wp_clear_scheduled_hook('cau_custom_hooks_themes');
87
- wp_clear_scheduled_hook('cau_log_updater');
88
- wp_clear_scheduled_hook('cau_outdated_notifier');
89
-
90
- // Then set the new times
91
-
92
- // Plugins
93
- if( $plugin_sc == 'daily' ) {
94
-
95
- $date = date( 'Y-m-d' );
96
- $hours = sanitize_text_field( $_POST['plugin_schedule-sethour'] );
97
- $minutes = sanitize_text_field( $_POST['plugin_schedule-setminutes'] );
98
- $seconds = date( 's' );
99
- $fullDate = $date.' '.$hours.':'.$minutes.':'.$seconds;
100
- $pluginSetTime = strtotime( $fullDate );
101
-
102
- wp_schedule_event( $pluginSetTime, $plugin_sc, 'wp_update_plugins' );
103
- wp_schedule_event( $pluginSetTime, $plugin_sc, 'cau_custom_hooks_plugins' );
104
- wp_schedule_event( ( $pluginSetTime - 1800 ), $plugin_sc, 'cau_log_updater' );
105
-
106
- } else {
107
-
108
- wp_schedule_event( time(), $plugin_sc, 'wp_update_plugins' );
109
- wp_schedule_event( time(), $plugin_sc, 'cau_custom_hooks_plugins' );
110
- wp_schedule_event( ( time() - 1800 ), $plugin_sc, 'cau_log_updater' );
111
-
112
- }
113
-
114
- // Themes
115
- if( $theme_sc == 'daily' ) {
116
-
117
- $dateT = date( 'Y-m-d' );
118
- $hoursT = sanitize_text_field( $_POST['theme_schedule-sethour'] );
119
- $minutesT = sanitize_text_field( $_POST['theme_schedule-setminutes'] );
120
- $secondsT = date( 's' );
121
- $fullDateT = $dateT.' '.$hoursT.':'.$minutesT.':'.$secondsT;
122
- $themeSetTime = strtotime( $fullDateT );
123
-
124
- wp_schedule_event( $themeSetTime, $theme_sc, 'wp_update_themes' );
125
- wp_schedule_event( $themeSetTime, $theme_sc, 'cau_custom_hooks_themes' );
126
-
127
- } else {
128
-
129
- wp_schedule_event( time(), $theme_sc, 'wp_update_themes' );
130
- wp_schedule_event( time(), $theme_sc, 'cau_custom_hooks_themes' );
131
-
132
- }
133
-
134
- // Core
135
- if( $core_sc == 'daily' ) {
136
-
137
- $dateC = date( 'Y-m-d' );
138
- $hoursC = sanitize_text_field( $_POST['core_schedule-sethour'] );
139
- $minutesC = sanitize_text_field( $_POST['core_schedule-setminutes'] );
140
- $secondsC = date( 's' );
141
- $fullDateC = $dateC.' '.$hoursC.':'.$minutesC.':'.$secondsC;
142
- $coreSetTime = strtotime( $fullDateC );
143
-
144
- wp_schedule_event( $coreSetTime, $core_sc, 'wp_version_check' );
145
-
146
- } else {
147
-
148
- wp_schedule_event( time(), $core_sc, 'wp_version_check' );
149
-
150
- }
151
-
152
- // Update notifications
153
- if( $schedule_mail == 'daily' ) {
154
-
155
- $dateT = date( 'Y-m-d' );
156
- $hoursT = sanitize_text_field( $_POST['update_notifications-sethour'] );
157
- $minutesT = sanitize_text_field( $_POST['update_notifications-setminutes'] );
158
- $secondsT = date( 's' );
159
- $fullDateT = $dateT.' '.$hoursT.':'.$minutesT.':'.$secondsT;
160
- $emailSetTime = strtotime( $fullDateT );
161
-
162
- wp_schedule_event( $emailSetTime, $schedule_mail, 'cau_set_schedule_mail' );
163
-
164
- } else {
165
-
166
- wp_schedule_event( time(), $schedule_mail, 'cau_set_schedule_mail' );
167
-
168
- }
169
-
170
- // Outdated notifications
171
- if( $outdated_notifier == 'daily' ) {
172
-
173
- $dateT = date( 'Y-m-d' );
174
- $hoursT = sanitize_text_field( $_POST['outdated_notifier-sethour'] );
175
- $minutesT = sanitize_text_field( $_POST['outdated_notifier-setminutes'] );
176
- $secondsT = date( 's' );
177
- $fullDateT = $dateT.' '.$hoursT.':'.$minutesT.':'.$secondsT;
178
- $emailSetTime = strtotime( $fullDateT );
179
-
180
- wp_schedule_event( $emailSetTime, $outdated_notifier, 'cau_outdated_notifier' );
181
-
182
- } else {
183
-
184
- wp_schedule_event( time(), $outdated_notifier, 'cau_outdated_notifier' );
185
-
186
- }
187
-
188
-
189
- echo '<div id="message" class="updated"><p><b>'.__( 'Settings saved.' ).'</b></p></div>';
190
-
191
- }
192
-
193
- if( isset( $_GET['welcome'] ) ) {
194
-
195
- echo '<div class="welcome-to-cau welcome-bg welcome-panel" style="margin-bottom: 0px;">
196
- <div class="welcome-image">
197
- </div><div class="welcome-content">
198
-
199
- <h3>'.__( 'Welcome to Companion Auto Update', 'companion-auto-update' ).'</h3>
200
- <br />
201
- <p><strong>'.__( 'You\'re set and ready to go', 'companion-auto-update' ).'</strong></p>
202
- <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>
203
- <br />
204
- <p><strong>'.__( 'Get Started' ).': </strong> <a href="'.cau_url( 'pluginlist' ).'">'.__( 'Update filter', 'companion-auto-update' ).'</a> &nbsp; | &nbsp;
205
- <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>
206
-
207
- </div>
208
- </div>';
209
- }
210
-
211
- $plugin_schedule = wp_get_schedule( 'wp_update_plugins' );
212
- $theme_schedule = wp_get_schedule( 'wp_update_themes' );
213
- $core_schedule = wp_get_schedule( 'wp_version_check' );
214
- $schedule_mail = wp_get_schedule( 'cau_set_schedule_mail' );
215
- $outdated_notifier = wp_get_schedule( 'cau_outdated_notifier' );
216
- $cs_hooks_p = wp_get_schedule( 'cau_custom_hooks_plugins' );
217
- $cs_hooks_t = wp_get_schedule( 'cau_custom_hooks_themes' );
218
- $availableIntervals = cau_wp_get_schedules();
219
-
220
- ?>
221
-
222
- <div class="cau-column-wide">
223
-
224
- <form method="POST">
225
-
226
- <div class="welcome-to-cau update-bg welcome-panel cau-dashboard-box">
227
-
228
- <h2 class="title"><?php _e('Auto Updater', 'companion-auto-update');?></h2>
229
-
230
- <table class="form-table">
231
- <tr>
232
- <td>
233
- <fieldset>
234
-
235
- <?php
236
-
237
- echo '<p><input id="plugins" name="plugins" type="checkbox"';
238
- if( cau_get_db_value( 'plugins' ) == 'on' ) echo 'checked';
239
- echo '/> <label for="plugins">'.__('Auto update plugins?', 'companion-auto-update').'</label></p>';
240
-
241
- echo '<p><input id="themes" name="themes" type="checkbox"';
242
- if( cau_get_db_value( 'themes' ) == 'on' ) echo 'checked';
243
- echo '/> <label for="themes">'.__('Auto update themes?', 'companion-auto-update').'</label></p>';
244
-
245
- echo '<p><input id="minor" name="minor" type="checkbox"';
246
- if( cau_get_db_value( 'minor' ) == 'on' ) echo 'checked';
247
- echo '/> <label for="minor">'.__('Auto update minor core updates?', 'companion-auto-update').' <code class="majorMinorExplain">5.3.0 > 5.3.1</code></label></p>';
248
-
249
- echo '<p><input id="major" name="major" type="checkbox"';
250
- if( cau_get_db_value( 'major' ) == 'on' ) echo 'checked';
251
- echo '/> <label for="major">'.__('Auto update major core updates?', 'companion-auto-update').' <code class="majorMinorExplain">5.3.0 > 5.4.0</code></label></p>';
252
-
253
- echo '<p><input id="translations" name="translations" type="checkbox"';
254
- if( cau_get_db_value( 'translations' ) == 'on' ) echo 'checked';
255
- echo '/> <label for="translations">'.__('Auto update translation files?', 'companion-auto-update').'</label></p>';
256
-
257
- ?>
258
-
259
- </fieldset>
260
- </td>
261
- </tr>
262
- </table>
263
-
264
- </div>
265
-
266
- <div class="welcome-to-cau email-bg welcome-panel cau-dashboard-box">
267
-
268
- <h2 class="title"><?php _e( 'Email Notifications', 'companion-auto-update' );?></h2>
269
-
270
- <?php
271
- if( cau_get_db_value( 'email' ) == '' ) $toemail = get_option('admin_email');
272
- else $toemail = cau_get_db_value( 'email' );
273
- ?>
274
-
275
- <table class="form-table">
276
- <tr>
277
- <th scope="row"><?php _e( 'Update notifications', 'companion-auto-update' );?></th>
278
- <td>
279
- <p>
280
- <input id="cau_send_update" name="cau_send_update" type="checkbox" <?php if( cau_get_db_value( 'sendupdate' ) == 'on' ) { echo 'checked'; } ?> />
281
- <label for="cau_send_update"><?php _e( 'Send me emails when something has been updated.', 'companion-auto-update' );?></label>
282
- </p>
283
- <p>
284
- <input id="cau_send" name="cau_send" type="checkbox" <?php if( cau_get_db_value( 'send' ) == 'on' ) { echo 'checked'; } ?> />
285
- <label for="cau_send"><?php _e('Send me emails when an update is available.', 'companion-auto-update');?></label>
286
- </p>
287
- </td>
288
- </tr>
289
- <tr>
290
- <th scope="row"><?php _e( 'Outdated software', 'companion-auto-update' );?></th>
291
- <td>
292
- <p>
293
- <input id="cau_send_outdated" name="cau_send_outdated" type="checkbox" <?php if( cau_get_db_value( 'sendoutdated' ) == 'on' ) { echo 'checked'; } ?> />
294
- <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>
295
- </p>
296
- </td>
297
- </tr>
298
- <tr>
299
- <th scope="row"><?php _e( 'Email Address', 'companion-auto-update' );?></th>
300
- <td>
301
- <p>
302
- <label for="cau_email"><?php _e( 'To', 'companion-auto-update' ); ?>:</label>
303
- <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 ); ?>" />
304
- </p>
305
-
306
- <p class="description"><?php _e('Seperate email addresses using commas.', 'companion-auto-update');?></p>
307
- </td>
308
- </tr>
309
- <tr>
310
- <th scope="row"><?php _e( 'Use HTML in emails?', 'companion-auto-update' );?></th>
311
- <td>
312
- <p>
313
- <select id='html_or_text' name='html_or_text'>
314
- <option value='html' <?php if( cau_get_db_value( 'html_or_text' ) == 'html' ) { echo "SELECTED"; } ?>><?php _e( 'Use HTML', 'companion-auto-update' ); ?></option>
315
- <option value='text' <?php if( cau_get_db_value( 'html_or_text' ) == 'text' ) { echo "SELECTED"; } ?>><?php _e( 'Use plain text', 'companion-auto-update' ); ?></option>
316
- </select>
317
- </p>
318
- </td>
319
- </tr>
320
- <tr>
321
- <th scope="row"><?php _e( 'Show more info in emails', 'companion-auto-update' );?></th>
322
- <td>
323
- <p>
324
- <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>
325
- </p>
326
- </td>
327
- </tr>
328
- <tr>
329
- <th scope="row">
330
- <?php _e( 'WordPress notifications', 'companion-auto-update' );?>
331
- <span class='cau_tooltip'><span class="dashicons dashicons-editor-help"></span>
332
- <span class='cau_tooltip_text'>
333
- <?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' );?>
334
- </span>
335
- </span>
336
- </th>
337
- <td>
338
- <p>
339
- <input id="wpemails" name="wpemails" type="checkbox" <?php if( cau_get_db_value( 'wpemails' ) == 'on' ) { echo 'checked'; } ?> />
340
- <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>
341
- </p>
342
- </td>
343
- </tr>
344
- </table>
345
-
346
- </div>
347
-
348
- <div class="welcome-to-cau interval-bg welcome-panel cau-dashboard-box" style="overflow: hidden;">
349
-
350
- <h2 class="title"><?php _e( 'Intervals', 'companion-auto-update' );?></h2>
351
-
352
- <?php
353
-
354
- function cau_show_interval_selection( $identiefier, $schedule ) {
355
-
356
- // Get the info
357
- $setValue = wp_get_schedule( $schedule );
358
- $setTime = wp_next_scheduled( $schedule );
359
- $setHour = date( 'H' , $setTime );
360
- $setMinutes = date( 'i' , $setTime );
361
-
362
- // Show interval selection
363
- echo "<p>";
364
- echo "<select name='$identiefier' id='$identiefier' class='schedule_interval wide interval_scheduler' data-timeblock='$identiefier'>";
365
- foreach ( cau_wp_get_schedules() as $key => $value ) {
366
- echo "<option "; if( $setValue == $key ) { echo "selected "; } echo "value='".$key."'>".$value."</option>";
367
- }
368
- echo "</select>";
369
- echo "</p>";
370
-
371
- // Set the time when daily is selected
372
- echo "<div class='timeblock-$identiefier' style='display: none;'>";
373
-
374
- echo "<div class='cau_schedule_input'>
375
- <input type='number' min='0' max='23' name='".$identiefier."-sethour' value='$setHour' maxlength='2' >
376
- </div><div class='cau_schedule_input_div'>
377
- :
378
- </div><div class='cau_schedule_input'>
379
- <input type='number' min='0' max='59' name='".$identiefier."-setminutes' value='$setMinutes' maxlength='2' >
380
- </div><div class='cau_shedule_notation'>
381
- <span class='cau_tooltip'><span class='dashicons dashicons-editor-help'></span>
382
- <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>
383
- </span>
384
- </div>";
385
-
386
- echo "</div>";
387
-
388
- }
389
-
390
- ?>
391
-
392
- <div class="welcome-column">
393
-
394
- <h4><?php _e( 'Plugin update interval', 'companion-auto-update' );?></h4>
395
- <?php cau_show_interval_selection( 'plugin_schedule', 'wp_update_plugins' ); ?>
396
-
397
- </div>
398
-
399
- <div class="welcome-column">
400
-
401
- <h4><?php _e( 'Theme update interval', 'companion-auto-update' );?></h4>
402
- <?php cau_show_interval_selection( 'theme_schedule', 'wp_update_themes' ); ?>
403
-
404
- </div>
405
-
406
- <div class="welcome-column">
407
-
408
- <h4><?php _e( 'Core update interval', 'companion-auto-update' );?></h4>
409
- <?php cau_show_interval_selection( 'core_schedule', 'wp_version_check' ); ?>
410
-
411
- </div>
412
-
413
- <div class="welcome-column">
414
-
415
- <h4><?php _e( 'Update notifications', 'companion-auto-update' );?></h4>
416
- <?php cau_show_interval_selection( 'update_notifications', 'cau_set_schedule_mail' ); ?>
417
-
418
- </div>
419
-
420
- <div class="welcome-column">
421
-
422
- <h4><?php _e( 'Outdated software', 'companion-auto-update' );?></h4>
423
- <?php cau_show_interval_selection( 'outdated_notifier', 'cau_outdated_notifier' ); ?>
424
-
425
- </div>
426
-
427
- </div>
428
-
429
- <div class="welcome-to-cau advanced-bg welcome-panel cau-dashboard-box">
430
-
431
- <h2 class="title"><?php _e( 'Advanced settings', 'companion-auto-update' ); ?></h2>
432
-
433
- <table class="form-table">
434
- <tbody>
435
- <tr>
436
- <th scope="row"><label><?php _e( 'Allow access to:', 'companion-auto-update' ); ?></label></th>
437
- <td>
438
- <p><label for="allow_administrator"><input name="allow_administrator" type="checkbox" id="allow_administrator" disabled="" checked=""><?php _e( 'Administrator', 'companion-auto-update' ); ?></label></p>
439
- <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>
440
- <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>
441
- </td>
442
- </tr>
443
- <tr>
444
- <th scope="row"><label><?php _e( 'Delay updates', 'companion-auto-update' ); ?></label></th>
445
- <td>
446
- <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>
447
- </td>
448
- </tr>
449
- <tr id='update_delay_days_block' <?php if( cau_get_db_value( 'update_delay' ) != 'on' ) { echo "class='disabled_option'"; } ?>>
450
- <th scope="row"><label><?php _e( 'Number of days', 'companion-auto-update' ); ?></label></th>
451
- <td>
452
- <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' ); ?>" />
453
- <p><?php _e( 'For how many days should updates be put on hold?', 'companion-auto-update' ); ?></p>
454
- </td>
455
- </tr>
456
- </tbody>
457
- </table>
458
-
459
- </div>
460
-
461
- <?php wp_nonce_field( 'cau_save_settings' ); ?>
462
- <?php submit_button(); ?>
463
-
464
- </form>
465
-
466
- </div><div class="cau-column-small">
467
-
468
- <div class="welcome-to-cau help-bg welcome-panel cau-dashboard-box">
469
- <div class="welcome-column welcome-column.welcome-column-half">
470
- <h3 class="support-sidebar-title"><?php _e( 'Help' ); ?></h3>
471
- <ul class="support-sidebar-list">
472
- <li><a href="https://codeermeneer.nl/stuffs/faq-auto-updater/" target="_blank"><?php _e( 'Frequently Asked Questions', 'companion-auto-update' ); ?></a></li>
473
- <li><a href="https://wordpress.org/support/plugin/companion-auto-update" target="_blank"><?php _e( 'Support Forums' ); ?></a></li>
474
- </ul>
475
-
476
- <h3 class="support-sidebar-title"><?php _e( 'Want to contribute?', 'companion-auto-update' ); ?></h3>
477
- <ul class="support-sidebar-list">
478
- <li><a href="http://codeermeneer.nl/cau_poll/" target="_blank"><?php _e( 'Give feedback', 'companion-auto-update' ); ?></a></li>
479
- <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>
480
- <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>
481
- </ul>
482
- </div>
483
- <div class="welcome-column welcome-column.welcome-column-half">
484
- <h3 class="support-sidebar-title"><?php _e( 'Developer?', 'companion-auto-update' ); ?></h3>
485
- <ul class="support-sidebar-list">
486
- <li><a href="https://codeermeneer.nl/documentation/auto-update/" target="_blank"><?php _e( 'Documentation' ); ?></a></li>
487
- </ul>
488
- </div>
489
- </div>
490
-
491
- <div class="welcome-to-cau support-bg welcome-panel cau-dashboard-box">
492
- <div class="welcome-column welcome-column">
493
- <h3><?php _e('Support', 'companion-auto-update');?></h3>
494
- <p><?php _e('Feel free to reach out to us if you have any questions or feedback.', 'companion-auto-update'); ?></p>
495
- <p><a href="https://codeermeneer.nl/contact/" target="_blank" class="button button-primary"><?php _e( 'Contact us', 'companion-auto-update' ); ?></a></p>
496
- <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>
497
- </div>
498
- </div>
499
-
500
- <div class="welcome-to-cau love-bg cau-show-love welcome-panel cau-dashboard-box">
501
- <h3><?php _e( 'Like our plugin?', 'companion-auto-update' ); ?></h3>
502
- <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>
503
- <a href="https://wordpress.org/support/plugin/companion-auto-update/reviews/#new-post" target="_blank" class="button button-alt button-hero">
504
- <?php _e('Rate us (5 stars?)', 'companion-auto-update'); ?>
505
- </a>
506
- <a href="<?php echo cau_donateUrl(); ?>" target="_blank" class="button button-primary button-hero">
507
- <?php _e('Donate to help development', 'companion-auto-update'); ?>
508
- </a>
509
- <p style="font-size: 12px; color: #BDBDBD;"><?php _e( 'Donations via PayPal. Amount can be changed.', 'companion-auto-update'); ?></p>
510
- </div>
511
-
512
- <div class="welcome-to-cau welcome-panel cau-dashboard-box">
513
- <h3><span style='background: #EBE3F7; color: #BCADD3; padding: 1px 5px; border-radius: 3px; font-size: .8em'>Plugin Promotion</span></h3>
514
- <h3>Keep your site fast with our Revision Manager</h3>
515
- <p>Post Revisions are great, but will also slow down your site. Take back control over revisions with Companion Revision Manager!</p>
516
- <a href="https://codeermeneer.nl/portfolio/plugin/companion-revision-manager/" target="_blank" class="button button-alt">Read more</a>
517
- </div>
518
-
519
- </div>
520
-
521
- <style>
522
- .disabled_option {
523
- opacity: .5;
524
- }
525
- </style>
526
-
527
- <script type="text/javascript">
528
-
529
- jQuery( '#update_delay' ).change( function() {
530
- jQuery( '#update_delay_days_block' ).toggleClass( 'disabled_option' );
531
- });
532
-
533
- jQuery( '.interval_scheduler' ).change( function() {
534
-
535
- var selected = jQuery(this).val(); // Selected value
536
- var timeblock = jQuery(this).data( 'timeblock' ); // Corresponding time block
537
-
538
- if( selected == 'daily' ) {
539
- jQuery( '.timeblock-'+timeblock ).show();
540
- } else {
541
- jQuery( '.timeblock-'+timeblock ).hide();
542
- }
543
-
544
- });
545
-
546
- jQuery( '.interval_scheduler' ).each( function() {
547
-
548
- var selected = jQuery(this).val(); // Selected value
549
- var timeblock = jQuery(this).data( 'timeblock' ); // Corresponding time block
550
-
551
- if( selected == 'daily' ) {
552
- jQuery( '.timeblock-'+timeblock ).show();
553
- } else {
554
- jQuery( '.timeblock-'+timeblock ).hide();
555
- }
556
-
557
- });
558
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
559
  </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
+
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>
backend/style.css CHANGED
@@ -1,547 +1,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
-
117
- /* Overwrite core UI */
118
- /*.cau_content input[type="checkbox"]:checked::before {
119
- content: "";
120
- background: url( 'images/check.svg' );
121
- background-size: contain;
122
- background-position: center center;
123
- }*/
124
- .cau_content a {
125
- color: #9178B7;
126
- }
127
- .cau_content a.nav-tab {
128
- color: #23282D;
129
- }
130
- .cau_content .button-primary {
131
- background-color: #9178B7!important;
132
- border-color: #9178B7!important;
133
- }
134
- .cau_content .button-alt {
135
- color: #9178B7!important;
136
- border-color: #9178B7!important;
137
- }
138
- .cau_content .button-hero {
139
- font-weight: 500;
140
- padding: 15px 30px!important;
141
- }
142
- #message.cau {
143
- background: #FFF;
144
- border: 1px solid #CCD0D4;
145
- border-left-width: 4px;
146
- border-left-color: #9178B7;
147
- box-shadow: 0 1px 1px rgba(0,0,0,.04);
148
- margin: 25px 0px 5px 0;
149
- padding: 15px;
150
- }
151
- #message.cau a, #message.cau strong {
152
- color: #9178B7;
153
- }
154
-
155
- /* Dashboard */
156
- .cau-column-wide {
157
- box-sizing: border-box;
158
- display: inline-block;
159
- vertical-align: top;
160
- width: calc(100% - 450px);
161
- padding-right: 25px;
162
- }
163
- .cau-column-small {
164
- display: inline-block;
165
- vertical-align: top;
166
- width: 450px;
167
- }
168
- .cau-dashboard-box {
169
- background-position: right bottom;
170
- }
171
- .cau-column-wide .cau-dashboard-box {
172
- padding-right: 125px;
173
- }
174
- .cau-dashboard-box a {
175
- margin-left: 0px;
176
- margin-top: 10px;
177
- }
178
- .cau-dashboard-box .welcome-column {
179
- padding-right: 25px;
180
- }
181
- .support-sidebar-list {
182
- margin-bottom: 25px;
183
- }
184
- .cau_content .nav-tab {
185
- position: relative;
186
- }
187
- .cau_content .nav-tab .cau_melding {
188
- display: inline-block;
189
- width: 11px;
190
- height: 11px;
191
- border-radius: 10px;
192
- margin-left: 5px;
193
- position: relative;
194
- bottom: -1px;
195
- }
196
- .cau_content .nav-tab .cau_melding.level-okay {
197
- background: #7AD03A;
198
- }
199
- .cau_content .nav-tab .cau_melding.level-low {
200
- background: #FFBA00;
201
- }
202
- .cau_content .nav-tab .cau_melding.level-high {
203
- background: #FF0000;
204
- }
205
-
206
- /* Table Styling */
207
- .cau_content .widefat td {
208
- vertical-align: middle!important;
209
- }
210
- table.autoupdate th.head-plugin {
211
- min-width: 250px;
212
- }
213
- table.autoupdate th.head-status {
214
- min-width: 150px;
215
- }
216
- table.autoupdate th.check-column {
217
- position: relative;
218
- min-width: 55px;
219
- }
220
- table.autoupdate tr.inactive {
221
- background: #FEF7F1;
222
- }
223
- table.autoupdate tr.active .check-column {
224
- border-left: 3px solid transparent;
225
- }
226
- table.autoupdate tr.inactive .check-column {
227
- border-left: 3px solid #D54E21;
228
- }
229
- table.autoupdate tr.inactive td.column-status p {
230
- color: #BF3D3C;
231
- }
232
- table.autoupdate tr.active td.column-status p {
233
- color: #000;
234
- }
235
- table.autoupdate tr td.column-description p {
236
- overflow: hidden;
237
- max-height: 18px;
238
- }
239
-
240
- /* Update Log */
241
- table.autoupdatelog {
242
- margin-top: 25px;
243
- }
244
- table.autoupdatelog strong {
245
- color: #000;
246
- }
247
- table.autoupdatelog .dashicons {
248
- color: #00A0D2;
249
- }
250
-
251
- /* Status */
252
- table.cau_status_list {
253
- margin-top: 25px;
254
- }
255
- table.cau_status_list:not(.no_column_width) th, table.cau_status_list:not(.no_column_width) td {
256
- width: 25%;
257
- }
258
- .cau_enabled {
259
- color: #7AD03A;
260
- }
261
- .cau_disabled {
262
- color: #FF0000;
263
- }
264
- .cau_warning {
265
- color: #FFBA00;
266
- }
267
- .cau_mobile_prefix {
268
- display: none;
269
- }
270
-
271
- /* Rollback list */
272
- table.rollbacklist {
273
- max-width: 650px;
274
- }
275
- table.rollbacklist td {
276
- vertical-align: middle;
277
- }
278
- table.rollbacklist td a.versionselectbutton {
279
- display: inline-block;
280
- width: 100px;
281
- text-align: center;
282
- }
283
-
284
- /* Plugin list */
285
- .pluginListButtons {
286
- display: block;
287
- padding: 15px 0;
288
- }
289
- .pluginListButtons p.submit {
290
- display: inline-block;
291
- margin: 0!important;
292
- padding: 0!important;
293
- }
294
- .cau_content #the-list input[type="checkbox"]:not(:checked), .cau_content #the-list input[type="checkbox"]:checked {
295
- width: 45px;
296
- height: 45px;
297
- position: absolute;
298
- top: 0;
299
- bottom: 0;
300
- z-index: 100;
301
- display: block;
302
- opacity: 0;
303
- }
304
- .cau_content #the-list input[type="checkbox"]:not(:checked) + label, .cau_content #the-list input[type="checkbox"]:checked + label {
305
- position: absolute;
306
- top: 15px;
307
- left: 12px;
308
- cursor: pointer;
309
- }
310
- .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 {
311
- content: '';
312
- position: absolute;
313
- }
314
- .cau_content #the-list input[type="checkbox"]:not(:checked) + label:before, .cau_content #the-list input[type="checkbox"]:checked + label:before {
315
- left: 0;
316
- top: -3px;
317
- width: 30px;
318
- height: 16px;
319
- background: transparent;
320
- border: 2px solid #9178B7;
321
- border-radius: 15px;
322
- transition: background-color .2s;
323
- }
324
- .cau_content #the-list input[type="checkbox"]:not(:checked) + label:after, .cau_content #the-list input[type="checkbox"]:checked + label:after {
325
- width: 8px;
326
- height: 8px;
327
- transition: all .2s;
328
- border-radius: 500px;
329
- background: transparent;
330
- border: 2px solid #9178B7;
331
- top: 1px;
332
- left: 5px;
333
- }
334
- .cau_content #the-list input[type="checkbox"]:not(:checked) + label:before {
335
- background: #9178B7;
336
- border: 2px solid #9178B7;
337
- }
338
- .cau_content #the-list input[type="checkbox"]:not(:checked) + label:after {
339
- background: #9178B7;
340
- border-color: #FFF;
341
- left: 18px;
342
- }
343
-
344
- /* Scheduling */
345
- .cau_schedule_input {
346
- display: inline-block;
347
- vertical-align: middle;
348
- width: 50px;
349
- padding-top: 5px;
350
- }
351
- .cau_schedule_input input {
352
- max-width: 100%;
353
- text-align: center;
354
- }
355
- .cau_schedule_input_div {
356
- display: inline-block;
357
- vertical-align: middle;
358
- padding: 0 6px;
359
- font-weight: bold;
360
- }
361
- .cau_shedule_notation {
362
- display: inline-block;
363
- vertical-align: middle;
364
- width: 125px;
365
- padding-left: 5px;
366
- }
367
- .cau_shedule_notation .dashicons {
368
- position: relative;
369
- bottom: -5px;
370
- }
371
-
372
- /* Tooltip */
373
- .cau_tooltip {
374
- position: relative;
375
- }
376
- .cau_tooltip .cau_tooltip_text {
377
- visibility: hidden;
378
- background-color: rgba(0,0,0,0.7);
379
- color: #FFF;
380
- text-align: left;
381
- font-size: 14px;
382
- padding: 15px;
383
- border-radius: 6px;
384
- position: absolute;
385
- z-index: 1;
386
- width: 240px;
387
- bottom: 100%;
388
- left: 50%;
389
- margin-left: -60px;
390
- margin-bottom: 10px;
391
- opacity: 0;
392
- transition: .3s;
393
- font-weight: normal;
394
- }
395
- .cau_tooltip:hover .cau_tooltip_text {
396
- visibility: visible;
397
- opacity: 1;
398
- }
399
- .cau_tooltip .cau_tooltip_text::after {
400
- content: " ";
401
- position: absolute;
402
- top: 100%;
403
- left: 50%;
404
- margin-left: -75px;
405
- border-width: 5px;
406
- border-style: solid;
407
- border-color: rgba(0,0,0,0.7) transparent transparent transparent;
408
- }
409
-
410
- /* Responsive */
411
- @media screen and (max-width: 1400px) {
412
-
413
- .cau-column-wide {
414
- width: calc(100% - 350px);
415
- }
416
- .cau-column-small {
417
- width: 350px;
418
- }
419
- .welcome-to-cau .welcome-column.welcome-column-quarter {
420
- width: 50%;
421
- padding-bottom: 35px;
422
- }
423
- .cau-column-small .welcome-to-cau {
424
- background-image: none;
425
- }
426
-
427
- }
428
- @media screen and (max-width: 1150px) {
429
-
430
- .cau-column-wide, .cau-column-small {
431
- width: 100%;
432
- padding: 0;
433
- }
434
-
435
- }
436
- @media screen and (max-width: 1000px) {
437
-
438
- /* Basics */
439
- .cau_hide_on_mobile, table.autoupdate thead {
440
- display: none!important;
441
- }
442
- .form-table td fieldset p {
443
- display: block;
444
- padding: 5px 0;
445
- }
446
- .form-table td fieldset input[type="checkbox"] {
447
- display: inline-block;
448
- vertical-align: middle;
449
- width: 25px;
450
- }
451
- .form-table td fieldset label {
452
- display: inline-block;
453
- vertical-align: middle;
454
- width: calc(100% - 40px);
455
- box-sizing: border-box;
456
- padding-left: 5px;
457
- }
458
- .cau_content .nav-tab-wrapper {
459
- position: relative;
460
- top: -20px;
461
- border-bottom: 1px solid #CCC!important;
462
- padding-bottom: 15px!important;
463
- margin-bottom: 0px!important;
464
- }
465
- .cau_content .nav-tab {
466
- font-size: 12px;
467
- margin: 5px 5px 0 0!important;
468
- box-sizing: border-box;
469
- text-align: center;
470
- }
471
-
472
- /* Scheduling */
473
- .cau_schedule_input {
474
- width: 75px;
475
- }
476
-
477
- /* Custom buttons */
478
- .cau-button {
479
- display: block;
480
- text-align: center;
481
- margin: 5px 0;
482
- }
483
- .cau-button .dashicons {
484
- float: left;
485
- }
486
-
487
- /* Dashboard */
488
- .welcome-to-cau {
489
- background-position: right bottom;
490
- }
491
- .welcome-to-cau.love-bg {
492
- background-image: none;
493
- }
494
- .welcome-to-cau .welcome-column {
495
- min-width: 100%;
496
- }
497
- .welcome-to-cau .welcome-column.welcome-column-first {
498
- padding-left: 0px;
499
- }
500
- .cau-column-wide .cau-dashboard-box {
501
- padding-right: 30px;
502
- padding-bottom: 125px
503
- }
504
- .majorMinorExplain {
505
- display: none;
506
- }
507
-
508
- /* Status */
509
- table.cau_status_list .cau_status_name {
510
- display: inline-block;
511
- width: 50%;
512
- box-sizing: border-box;
513
- font-weight: 500;
514
- }
515
- table.cau_status_list .cau_status_interval {
516
- display: none;
517
- }
518
- table.cau_status_list th.cau_status_next {
519
- display: none;
520
- }
521
- table.cau_status_list td.cau_status_next {
522
- display: block;
523
- width: 100%;
524
- }
525
- table.cau_status_list .cau_status_active_state {
526
- display: inline-block;
527
- width: 50%;
528
- box-sizing: border-box;
529
- text-align: right;
530
- }
531
- .cau_mobile_prefix {
532
- display: inline-block;
533
- padding-right: 5px;
534
- }
535
- table.cau_status_list.cau_status_warnings td {
536
- display: block;
537
- width: 100%;
538
- box-sizing: border-box;
539
- }
540
- table.cau_status_list.cau_status_warnings th.cau_plugin_issue_explain, table.cau_status_list.cau_status_warnings th.cau_plugin_issue_fixit {
541
- display: none;
542
- }
543
- table.cau_status_list.cau_status_warnings td.cau_plugin_issue_name {
544
- font-weight: 500;
545
- }
546
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
547
  }
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
  }
cau_emails.php CHANGED
@@ -1,480 +1,510 @@
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
- }
18
-
19
- // Notify of out of date software
20
- function cau_outdated_notifier_mail() {
21
- if( cau_get_db_value( 'sendoutdated' ) == 'on' ) {
22
- cau_list_outdated_software(); // Check for oudated plugins
23
- }
24
- }
25
-
26
- // Ge the emailadresses it should be send to
27
- function cau_set_email() {
28
-
29
- $emailArray = array();
30
-
31
- if( cau_get_db_value( 'email' ) == '' ) {
32
- array_push( $emailArray, get_option('admin_email') );
33
- } else {
34
- $emailAdresses = cau_get_db_value( 'email' );
35
- $list = explode( ", ", $emailAdresses );
36
- foreach ( $list as $key ) {
37
- array_push( $emailArray, $list );
38
- }
39
- }
40
-
41
- return $emailArray;
42
-
43
- }
44
-
45
- // Mail format
46
- function cau_is_html() {
47
-
48
- // Check if cau_get_db_value() function exists.
49
- if ( !function_exists( 'cau_get_db_value' ) ) require_once( plugin_dir_path( __FILE__ ) . 'cau_function.php' );
50
-
51
- // Check if html
52
- if( cau_get_db_value( 'html_or_text' ) == 'html' ) {
53
- $html = true;
54
- } else {
55
- $html = false;
56
- }
57
-
58
- }
59
-
60
- // Set the content for the emails about pending updates
61
- function cau_outdated_message( $single, $plural, $list ) {
62
-
63
- // WP version
64
- $wpversion = get_bloginfo( 'version' );
65
-
66
- // Base text
67
- $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() );
68
- $text .= "\n";
69
- $text .= "\n";
70
-
71
- // The list
72
- if( !empty( $list ) ) {
73
-
74
- $text .= sprintf( esc_html__( "The following %s have not been tested with WordPress %s:", "companion-auto-update" ), $plural, $wpversion );
75
- $text .= "\n";
76
- $text .= "\n";
77
-
78
- foreach ( $list as $plugin => $version ) {
79
- if( $version == '' ) $version = __( "Unknown", "companion-auto-update" );
80
- $text .= "- ".sprintf( esc_html__( "%s tested up to: %s", "companion-auto-update" ), $plugin, $version )."\n";
81
- }
82
-
83
- }
84
-
85
- return $text;
86
-
87
- }
88
-
89
- // Set the content for the emails about pending updates
90
- function cau_pending_message( $single, $plural, $list ) {
91
-
92
- // What markup to use
93
- if( cau_is_html() ) $break = '<br />';
94
- else $break = "\n";
95
-
96
- // Base text
97
- $text = sprintf( esc_html__( 'You have pending %1$s updates on your WordPress site at %2$s.', 'companion-auto-update' ), $single, get_site_url() );
98
- $text .= $break;
99
-
100
- if( !empty( $list ) ) {
101
-
102
- $text .= $break;
103
- $text .= sprintf( esc_html__( 'The following %1$s have new versions available.', 'companion-auto-update' ), $plural );
104
- $text .= $break;
105
-
106
- if( cau_is_html() ) $text .= "<ol>";
107
- foreach ( $list as $key => $value ) {
108
- if( cau_is_html() ) {
109
- $text .= "<li>$value</li>";
110
- } else {
111
- $text .= "-$value\n";
112
- }
113
- }
114
- if( cau_is_html() ) $text .= "</ol>";
115
-
116
- $text .= $break;
117
- }
118
-
119
- $text .= __( 'Leaving your site outdated is a security risk so please consider manually updating them.', 'companion-auto-update' );
120
- $text .= $break;
121
-
122
- // End
123
- $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' );
124
-
125
- return $text;
126
-
127
- }
128
-
129
- // Set the content for the emails about recent updates
130
- function cau_updated_message( $type, $updatedList ) {
131
-
132
- // What markup to use
133
- if( cau_is_html() ) $break = '<br />';
134
- else $break = "\n";
135
-
136
- // The message
137
- $text = sprintf( esc_html__(
138
- '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.
139
- For more info on what is new visit your dashboard and check the changelog.', 'companion-auto-update'
140
- ), $type, get_site_url() );
141
-
142
- $text .= $break;
143
- $text .= $break;
144
- $text .= sprintf( esc_html__(
145
- 'The following %1$s have been updated:', 'companion-auto-update'
146
- ), $type );
147
-
148
- $text .= $break;
149
- $text .= $updatedList;
150
-
151
- $text .= $break;
152
- $text .= __( "(You'll also receive this email if you manually updated a plugin or theme)", "companion-auto-update" );
153
-
154
- return $text;
155
-
156
- }
157
-
158
- // Checks if plugins are out of date
159
- function cau_list_outdated_software() {
160
-
161
- // Check if cau_get_db_value() function exists.
162
- if ( !function_exists( 'cau_get_db_value' ) ) require_once( plugin_dir_path( __FILE__ ) . 'cau_function.php' );
163
-
164
- // Set up mail
165
- $subject = '['.get_bloginfo( 'name' ).'] ' . __( 'You have outdated plugins on your site.', 'companion-auto-update' );
166
- $type = __( 'plugin', 'companion-auto-update' );
167
- $type_plural = __( 'plugins', 'companion-auto-update' );
168
- $message = cau_outdated_message( $type, $type_plural, cau_list_outdated() );
169
-
170
- // Send to all addresses
171
- foreach ( cau_set_email() as $key => $value ) {
172
- foreach ( $value as $k => $v ) {
173
- wp_mail( $v, $subject, $message );
174
- }
175
- break;
176
- }
177
-
178
- }
179
-
180
- // Checks if theme updates are available
181
- function cau_list_theme_updates() {
182
-
183
- global $wpdb;
184
- $table_name = $wpdb->prefix . "auto_updates";
185
-
186
- $configs = $wpdb->get_results( "SELECT * FROM $table_name WHERE name = 'themes'");
187
- foreach ( $configs as $config ) {
188
-
189
- if( $config->onoroff != 'on' ) {
190
-
191
- require_once ABSPATH . '/wp-admin/includes/update.php';
192
- $themes = get_theme_updates();
193
- $list = array();
194
-
195
- if ( !empty( $themes ) ) {
196
-
197
- foreach ( $themes as $stylesheet => $theme ) {
198
- array_push( $list, $theme->get( 'Name' ) );
199
- }
200
-
201
- $subject = '[' . get_bloginfo( 'name' ) . '] ' . __( 'Theme update available.', 'companion-auto-update' );
202
- $type = __('theme', 'companion-auto-update');
203
- $type_plural = __('themes', 'companion-auto-update');
204
- $message = cau_pending_message( $type, $type_plural, $list );
205
-
206
- foreach ( cau_set_email() as $key => $value) {
207
- foreach ($value as $k => $v) {
208
- wp_mail( $v, $subject, $message );
209
- }
210
- break;
211
- }
212
- }
213
-
214
- }
215
-
216
- }
217
-
218
- }
219
-
220
- // Checks if plugin updates are available
221
- function cau_list_plugin_updates() {
222
-
223
- global $wpdb;
224
- $table_name = $wpdb->prefix . "auto_updates";
225
-
226
- $configs = $wpdb->get_results( "SELECT * FROM $table_name WHERE name = 'plugins'");
227
- foreach ( $configs as $config ) {
228
-
229
- if( $config->onoroff != 'on' ) {
230
-
231
- require_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
232
- $plugins = get_plugin_updates();
233
-
234
- if ( !empty( $plugins ) ) {
235
-
236
- $list = array();
237
- foreach ( (array) $plugins as $plugin_file => $plugin_data ) {
238
- $plugin_data = (object) _get_plugin_data_markup_translate( $plugin_file, (array) $plugin_data, false, true );
239
- $name = $plugin_data->Name;
240
- array_push( $list, $name );
241
- }
242
-
243
- $subject = '[' . get_bloginfo( 'name' ) . '] ' . __( 'Plugin update available.', 'companion-auto-update' );
244
- $type = __( 'plugin', 'companion-auto-update' );
245
- $type_plural = __( 'plugins', 'companion-auto-update' );
246
- $message = cau_pending_message( $type, $type_plural, $list );
247
-
248
- foreach ( cau_set_email() as $key => $value) {
249
- foreach ($value as $k => $v) {
250
- wp_mail( $v, $subject, $message );
251
- }
252
- break;
253
- }
254
- }
255
-
256
- }
257
-
258
- }
259
- }
260
-
261
- // Alerts when plugin has been updated
262
- function cau_plugin_updated() {
263
-
264
- // Check if cau_get_db_value() function exists.
265
- if ( !function_exists( 'cau_get_db_value' ) ) require_once( plugin_dir_path( __FILE__ ) . 'cau_function.php' );
266
-
267
- // Set the correct timezone for emails
268
- date_default_timezone_set( cau_get_proper_timezone() );
269
-
270
- // Create arrays
271
- $pluginNames = array();
272
- $pluginDates = array();
273
- $pluginVersion = array();
274
- $pluginSlug = array();
275
- $pluginTimes = array();
276
- $themeNames = array();
277
- $themeDates = array();
278
- $themeTimes = array();
279
-
280
- // Where to look for plugins
281
- $plugdir = plugin_dir_path( __DIR__ );
282
- if ( !function_exists( 'get_plugins' ) ) require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); // Check if get_plugins() function exists.
283
- $allPlugins = get_plugins();
284
-
285
- // Where to look for themes
286
- $themedir = get_theme_root();
287
- $allThemes = wp_get_themes();
288
-
289
- // Mail schedule
290
- $schedule_mail = wp_get_schedule( 'cau_set_schedule_mail' );
291
-
292
- // Loop trough all plugins
293
- foreach ( $allPlugins as $key => $value ) {
294
-
295
- // Get plugin data
296
- $fullPath = $plugdir.'/'.$key;
297
- $getFile = $path_parts = pathinfo( $fullPath );
298
- $pluginData = get_plugin_data( $fullPath );
299
-
300
- // Get the slug
301
- $explosion = explode( '/', $key );
302
- $actualSlug = array_shift( $explosion );
303
-
304
- // Get last update date
305
- $fileDate = date ( 'YmdHi', filemtime( $fullPath ) );
306
-
307
- switch ( $schedule_mail ) {
308
- case 'hourly':
309
- $lastday = date( 'YmdHi', strtotime( '-1 hour', time() ) );
310
- break;
311
- case 'twicedaily':
312
- $lastday = date( 'YmdHi', strtotime( '-12 hours', time() ) );
313
- break;
314
- default:
315
- $lastday = date( 'YmdHi', strtotime( '-1 day', time() ) );
316
- break;
317
- }
318
-
319
- $dateFormat = get_option( 'date_format' );
320
- $timestamp = date_i18n( $dateFormat, filemtime( $fullPath ) );
321
- $timestamp .= ' - '.date( 'H:i', filemtime( $fullPath ) );
322
-
323
- if( $fileDate >= $lastday ) {
324
-
325
- // Get plugin name
326
- foreach ( $pluginData as $dataKey => $dataValue ) {
327
- if( $dataKey == 'Name') {
328
- array_push( $pluginNames , $dataValue );
329
- }
330
- if( $dataKey == 'Version') {
331
- array_push( $pluginVersion , $dataValue );
332
- }
333
- }
334
-
335
- array_push( $pluginDates, $fileDate );
336
- array_push( $pluginSlug, $actualSlug );
337
- array_push( $pluginTimes, $timestamp );
338
- }
339
-
340
- }
341
-
342
- // Loop trough all themes
343
- foreach ( $allThemes as $key => $value ) {
344
-
345
- // Get theme data
346
- $fullPath = $themedir.'/'.$key;
347
- $getFile = $path_parts = pathinfo( $fullPath );
348
-
349
- // Get last update date
350
- $dateFormat = get_option( 'date_format' );
351
- $fileDate = date ( 'YmdHi', filemtime( $fullPath ) );
352
-
353
- if( $schedule_mail == 'hourly' ) {
354
- $lastday = date( 'YmdHi', strtotime( '-1 hour', time() ) );
355
- } elseif( $schedule_mail == 'twicedaily' ) {
356
- $lastday = date( 'YmdHi', strtotime( '-12 hours', time() ) );
357
- } elseif( $schedule_mail == 'daily' ) {
358
- $lastday = date( 'YmdHi', strtotime( '-1 day', time() ) );
359
- }
360
-
361
- $dateFormat = get_option( 'date_format' );
362
- $timestamp = date_i18n( $dateFormat, filemtime( $fullPath ) );
363
- $timestamp .= ' - '.date( 'H:i', filemtime( $fullPath ) );
364
-
365
- if( $fileDate >= $lastday ) {
366
- array_push( $themeNames, $path_parts['filename'] );
367
- array_push( $themeDates, $fileDate );
368
- array_push( $themeTimes, $timestamp );
369
- }
370
-
371
- }
372
-
373
- $totalNumP = 0;
374
- $totalNumT = 0;
375
- $updatedListP = '';
376
- $updatedListT = '';
377
-
378
- if( cau_get_db_value( 'html_or_text' ) == 'html' ) {
379
- $updatedListP .= '<ol>';
380
- $updatedListT .= '<ol>';
381
- }
382
-
383
- foreach ( $pluginDates as $key => $value ) {
384
-
385
- if( cau_get_db_value( 'html_or_text' ) == 'html' ) {
386
-
387
- $more_info = '';
388
- 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>";
389
-
390
- $updatedListP .= "<li>
391
- <strong>".$pluginNames[$key]." </strong><br />
392
- ".__( "to version", "companion-auto-update" )." ".$pluginVersion[$key]." <a href='https://wordpress.org/plugins/".$pluginSlug[$key]."/#developers'>".__( "Release notes", "companion-auto-update" )."</a>
393
- ".$more_info."
394
- </li>";
395
-
396
- } else {
397
-
398
- $updatedListP .= "- ".$pluginNames[$key]." ".__( "to version", "companion-auto-update" )." ".$pluginVersion[$key]."\n";
399
- $updatedListP .= " ".__( "Release notes", "companion-auto-update" ).": https://wordpress.org/plugins/".$pluginSlug[$key]."/#developers\n";
400
-
401
- }
402
-
403
- $totalNumP++;
404
- }
405
-
406
- foreach ( $themeNames as $key => $value ) {
407
-
408
- if( cau_get_db_value( 'html_or_text' ) == 'html' ) {
409
-
410
- $more_info = '';
411
- 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>";
412
- $updatedListT .= "<li><strong>".$themeNames[$key]."</strong>".$more_info."</li>";
413
-
414
- } else {
415
- $updatedListT .= "- ".$themeNames[$key]."\n";
416
- }
417
-
418
- $totalNumT++;
419
- }
420
-
421
- if( cau_get_db_value( 'html_or_text' ) == 'html' ) {
422
- $updatedListP .= '</ol>';
423
- $updatedListT .= '</ol>';
424
- }
425
-
426
- // Set the email content type
427
- if( cau_get_db_value( 'html_or_text' ) == 'html' ) {
428
- function cau_mail_content_type() {
429
- return 'text/html';
430
- }
431
- add_filter( 'wp_mail_content_type', 'cau_mail_content_type' );
432
- }
433
-
434
- // If plugins have been updated, send email
435
- if( $totalNumP > 0 ) {
436
-
437
- // E-mail content
438
- $subject = '[' . get_bloginfo( 'name' ) . '] ' . __('One or more plugins have been updated.', 'companion-auto-update');
439
- $type = __('plugins', 'companion-auto-update');
440
- $message = cau_updated_message( $type, $updatedListP );
441
-
442
- // Send to all addresses
443
- foreach ( cau_set_email() as $key => $value) {
444
- foreach ($value as $k => $v) {
445
- wp_mail( $v, $subject, $message );
446
- }
447
- break;
448
- }
449
-
450
- }
451
-
452
- // If themes have been updated, send email
453
- if( $totalNumT > 0 ) {
454
-
455
- // E-mail content
456
- $subject = '[' . get_bloginfo( 'name' ) . '] ' . __('One or more themes have been updated.', 'companion-auto-update');
457
- $type = __('themes', 'companion-auto-update');
458
- $message = cau_updated_message( $type, $updatedListT );
459
-
460
- // Send to all addresses
461
- foreach ( cau_set_email() as $key => $value) {
462
- foreach ($value as $k => $v) {
463
- wp_mail( $v, $subject, $message );
464
- }
465
- break;
466
- }
467
-
468
- }
469
-
470
- if( cau_get_db_value( 'html_or_text' ) == 'html' ) remove_filter( 'wp_mail_content_type', 'cau_mail_content_type' );
471
-
472
- // Prevent duplicate emails by setting the event again
473
- if( $totalNumT > 0 OR $totalNumP > 0 ) {
474
- if( $schedule_mail == 'hourly' ) {
475
- wp_clear_scheduled_hook('cau_set_schedule_mail');
476
- wp_schedule_event( strtotime( '+1 hour', time() ) , 'hourly', 'cau_set_schedule_mail' );
477
- }
478
- }
479
-
480
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $plugins = get_plugin_updates();
238
+
239
+ if ( !empty( $plugins ) ) {
240
+
241
+ $list = array();
242
+ foreach ( (array) $plugins as $plugin_file => $plugin_data ) {
243
+ $plugin_data = (object) _get_plugin_data_markup_translate( $plugin_file, (array) $plugin_data, false, true );
244
+ $name = $plugin_data->Name;
245
+ array_push( $list, $name );
246
+ }
247
+
248
+ $subject = '[' . get_bloginfo( 'name' ) . '] ' . __( 'Plugin update available.', 'companion-auto-update' );
249
+ $type = __( 'plugin', 'companion-auto-update' );
250
+ $type_plural = __( 'plugins', 'companion-auto-update' );
251
+ $message = cau_pending_message( $type, $type_plural, $list );
252
+
253
+ foreach ( cau_set_email() as $key => $value) {
254
+ foreach ($value as $k => $v) {
255
+ wp_mail( $v, $subject, $message );
256
+ }
257
+ break;
258
+ }
259
+ }
260
+
261
+ }
262
+
263
+ }
264
+ }
265
+
266
+ // Alerts when plugin has been updated
267
+ function cau_plugin_updated() {
268
+
269
+ // Check if cau_get_db_value() function exists.
270
+ if ( !function_exists( 'cau_get_db_value' ) ) require_once( plugin_dir_path( __FILE__ ) . 'cau_function.php' );
271
+
272
+ // Set the correct timezone for emails
273
+ date_default_timezone_set( cau_get_proper_timezone() );
274
+
275
+ // Create arrays
276
+ $pluginNames = array();
277
+ $pluginDates = array();
278
+ $pluginVersion = array();
279
+ $pluginSlug = array();
280
+ $pluginTimes = array();
281
+ $themeNames = array();
282
+ $themeDates = array();
283
+ $themeTimes = array();
284
+
285
+ // Where to look for plugins
286
+ $plugdir = plugin_dir_path( __DIR__ );
287
+ if ( !function_exists( 'get_plugins' ) ) require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); // Check if get_plugins() function exists.
288
+ $allPlugins = get_plugins();
289
+
290
+ // Where to look for themes
291
+ $themedir = get_theme_root();
292
+ $allThemes = wp_get_themes();
293
+
294
+ // Mail schedule
295
+ $schedule_mail = wp_get_schedule( 'cau_set_schedule_mail' );
296
+
297
+ // Loop trough all plugins
298
+ foreach ( $allPlugins as $key => $value ) {
299
+
300
+ // Get plugin data
301
+ $fullPath = $plugdir.'/'.$key;
302
+ $getFile = $path_parts = pathinfo( $fullPath );
303
+ $pluginData = get_plugin_data( $fullPath );
304
+
305
+ // Get the slug
306
+ $explosion = explode( '/', $key );
307
+ $actualSlug = array_shift( $explosion );
308
+
309
+ // Get last update date
310
+ $fileDate = date ( 'YmdHi', filemtime( $fullPath ) );
311
+
312
+ switch ( $schedule_mail ) {
313
+ case 'hourly':
314
+ $lastday = date( 'YmdHi', strtotime( '-1 hour', time() ) );
315
+ break;
316
+ case 'twicedaily':
317
+ $lastday = date( 'YmdHi', strtotime( '-12 hours', time() ) );
318
+ break;
319
+ default:
320
+ $lastday = date( 'YmdHi', strtotime( '-1 day', time() ) );
321
+ break;
322
+ }
323
+
324
+ $dateFormat = get_option( 'date_format' );
325
+ $timestamp = date_i18n( $dateFormat, filemtime( $fullPath ) );
326
+ $timestamp .= ' - '.date( 'H:i', filemtime( $fullPath ) );
327
+
328
+ if( $fileDate >= $lastday ) {
329
+
330
+ // Get plugin name
331
+ foreach ( $pluginData as $dataKey => $dataValue ) {
332
+ if( $dataKey == 'Name') {
333
+ array_push( $pluginNames , $dataValue );
334
+ }
335
+ if( $dataKey == 'Version') {
336
+ array_push( $pluginVersion , $dataValue );
337
+ }
338
+ }
339
+
340
+ array_push( $pluginDates, $fileDate );
341
+ array_push( $pluginSlug, $actualSlug );
342
+ array_push( $pluginTimes, $timestamp );
343
+ }
344
+
345
+ }
346
+
347
+ // Loop trough all themes
348
+ foreach ( $allThemes as $key => $value ) {
349
+
350
+ // Get theme data
351
+ $fullPath = $themedir.'/'.$key;
352
+ $getFile = $path_parts = pathinfo( $fullPath );
353
+
354
+ // Get last update date
355
+ $dateFormat = get_option( 'date_format' );
356
+ $fileDate = date ( 'YmdHi', filemtime( $fullPath ) );
357
+
358
+ if( $schedule_mail == 'hourly' ) {
359
+ $lastday = date( 'YmdHi', strtotime( '-1 hour', time() ) );
360
+ } elseif( $schedule_mail == 'twicedaily' ) {
361
+ $lastday = date( 'YmdHi', strtotime( '-12 hours', time() ) );
362
+ } elseif( $schedule_mail == 'daily' ) {
363
+ $lastday = date( 'YmdHi', strtotime( '-1 day', time() ) );
364
+ }
365
+
366
+ $dateFormat = get_option( 'date_format' );
367
+ $timestamp = date_i18n( $dateFormat, filemtime( $fullPath ) );
368
+ $timestamp .= ' - '.date( 'H:i', filemtime( $fullPath ) );
369
+
370
+ if( $fileDate >= $lastday ) {
371
+ array_push( $themeNames, $path_parts['filename'] );
372
+ array_push( $themeDates, $fileDate );
373
+ array_push( $themeTimes, $timestamp );
374
+ }
375
+
376
+ }
377
+
378
+ $totalNumP = 0;
379
+ $totalNumT = 0;
380
+ $updatedListP = '';
381
+ $updatedListT = '';
382
+
383
+ if( cau_get_db_value( 'html_or_text' ) == 'html' ) {
384
+ $updatedListP .= '<ol>';
385
+ $updatedListT .= '<ol>';
386
+ }
387
+
388
+ foreach ( $pluginDates as $key => $value ) {
389
+
390
+ if( cau_get_db_value( 'html_or_text' ) == 'html' ) {
391
+
392
+ $more_info = '';
393
+ 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>";
394
+
395
+ $updatedListP .= "<li>
396
+ <strong>".$pluginNames[$key]." </strong><br />
397
+ ".__( "to version", "companion-auto-update" )." ".$pluginVersion[$key]." <a href='https://wordpress.org/plugins/".$pluginSlug[$key]."/#developers'>".__( "Release notes", "companion-auto-update" )."</a>
398
+ ".$more_info."
399
+ </li>";
400
+
401
+ } else {
402
+
403
+ $updatedListP .= "- ".$pluginNames[$key]." ".__( "to version", "companion-auto-update" )." ".$pluginVersion[$key]."\n";
404
+ $updatedListP .= " ".__( "Release notes", "companion-auto-update" ).": https://wordpress.org/plugins/".$pluginSlug[$key]."/#developers\n";
405
+
406
+ }
407
+
408
+ $totalNumP++;
409
+ }
410
+
411
+ foreach ( $themeNames as $key => $value ) {
412
+
413
+ if( cau_get_db_value( 'html_or_text' ) == 'html' ) {
414
+
415
+ $more_info = '';
416
+ 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>";
417
+ $updatedListT .= "<li><strong>".$themeNames[$key]."</strong>".$more_info."</li>";
418
+
419
+ } else {
420
+ $updatedListT .= "- ".$themeNames[$key]."\n";
421
+ }
422
+
423
+ $totalNumT++;
424
+ }
425
+
426
+ if( cau_get_db_value( 'html_or_text' ) == 'html' ) {
427
+ $updatedListP .= '</ol>';
428
+ $updatedListT .= '</ol>';
429
+ }
430
+
431
+ // Set the email content type
432
+ if( cau_get_db_value( 'html_or_text' ) == 'html' ) {
433
+ function cau_mail_content_type() {
434
+ return 'text/html';
435
+ }
436
+ add_filter( 'wp_mail_content_type', 'cau_mail_content_type' );
437
+ }
438
+
439
+ // If plugins have been updated, send email
440
+ if( $totalNumP > 0 ) {
441
+
442
+ // E-mail content
443
+ $subject = '[' . get_bloginfo( 'name' ) . '] ' . __('One or more plugins have been updated.', 'companion-auto-update');
444
+ $type = __('plugins', 'companion-auto-update');
445
+ $message = cau_updated_message( $type, $updatedListP );
446
+
447
+ // Send to all addresses
448
+ foreach ( cau_set_email() as $key => $value) {
449
+ foreach ($value as $k => $v) {
450
+ wp_mail( $v, $subject, $message );
451
+ }
452
+ break;
453
+ }
454
+
455
+ }
456
+
457
+ // If themes have been updated, send email
458
+ if( $totalNumT > 0 ) {
459
+
460
+ // E-mail content
461
+ $subject = '[' . get_bloginfo( 'name' ) . '] ' . __('One or more themes have been updated.', 'companion-auto-update');
462
+ $type = __('themes', 'companion-auto-update');
463
+ $message = cau_updated_message( $type, $updatedListT );
464
+
465
+ // Send to all addresses
466
+ foreach ( cau_set_email() as $key => $value) {
467
+ foreach ($value as $k => $v) {
468
+ wp_mail( $v, $subject, $message );
469
+ }
470
+ break;
471
+ }
472
+
473
+ }
474
+
475
+ if( cau_get_db_value( 'html_or_text' ) == 'html' ) remove_filter( 'wp_mail_content_type', 'cau_mail_content_type' );
476
+
477
+ // Prevent duplicate emails by setting the event again
478
+ if( $totalNumT > 0 OR $totalNumP > 0 ) {
479
+ if( $schedule_mail == 'hourly' ) {
480
+ wp_clear_scheduled_hook('cau_set_schedule_mail');
481
+ wp_schedule_event( strtotime( '+1 hour', time() ) , 'hourly', 'cau_set_schedule_mail' );
482
+ }
483
+ }
484
+
485
+ }
486
+
487
+ function cau_notify_outofdate_db() {
488
+
489
+ // Check if cau_get_db_value() function exists.
490
+ if ( !function_exists( 'cau_get_db_value' ) ) require_once( plugin_dir_path( __FILE__ ) . 'cau_function.php' );
491
+
492
+ // Database requires an update
493
+ if ( cau_incorrectDatabaseVersion() ) {
494
+
495
+ // Set up mail
496
+ $subject = '[' . get_bloginfo( 'name' ) . '] ' . __( 'We need your help with something', 'companion-auto-update' );
497
+ $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' );
498
+
499
+ // Send to all addresses
500
+ foreach ( cau_set_email() as $key => $value ) {
501
+ foreach ( $value as $k => $v ) {
502
+ wp_mail( $v, $subject, $message );
503
+ }
504
+ break;
505
+ }
506
+
507
+ }
508
+
509
+ }
510
+
cau_functions.php CHANGED
@@ -1,1430 +1,1430 @@
1
- <?php
2
-
3
- // What user rights can edit plugin settings?
4
- function cau_allowed_user_rights() {
5
-
6
- // Current user
7
- $user = wp_get_current_user();
8
-
9
- // Allow roles
10
- $allowed_roles = array( 'administrator' );
11
- if( cau_get_db_value( 'allow_editor' ) == 'on' ) array_push( $allowed_roles, 'editor' );
12
- if( cau_get_db_value( 'allow_author' ) == 'on' ) array_push( $allowed_roles, 'author' );
13
-
14
- // Check
15
- if ( array_intersect( $allowed_roles, $user->roles ) ) {
16
- return true;
17
- } else {
18
- return false;
19
- }
20
- }
21
-
22
- // Get database value
23
- function cau_get_db_value( $name, $table = 'auto_updates' ) {
24
-
25
- global $wpdb;
26
- $table_name = $wpdb->prefix.$table;
27
- $cau_configs = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$table_name} WHERE name = '%s'", $name ) );
28
- foreach ( $cau_configs as $config ) return $config->onoroff;
29
-
30
- }
31
-
32
- // Get database value
33
- function cau_get_plugininfo( $check, $field ) {
34
-
35
- global $wpdb;
36
- $table_name = $wpdb->prefix.'update_log';
37
- $cau_configs = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$table_name} WHERE slug = '%s'", $check ) );
38
- foreach ( $cau_configs as $config ) return $config->$field;
39
-
40
- }
41
-
42
- // Get the set timezone
43
- function cau_get_proper_timezone() {
44
-
45
- // WP 5.3 adds the wp_timezone_string function
46
- if ( !function_exists( 'wp_timezone_string' ) ) {
47
- $timezone = get_option( 'timezone_string' );
48
- } else {
49
- $timezone = wp_timezone_string();
50
- }
51
-
52
- // Should fix an reported issue
53
- if( $timezone == '+00:00' ) {
54
- $timezone = 'UTC';
55
- }
56
-
57
- return $timezone;
58
-
59
- }
60
-
61
- // Copy of the wp_timezone_string for < 5.3 compat
62
- if ( !function_exists( 'wp_timezone_string' ) ) {
63
- function wp_timezone_string() {
64
- $timezone_string = get_option( 'timezone_string' );
65
-
66
- if ( $timezone_string ) {
67
- return $timezone_string;
68
- }
69
-
70
- $offset = (float) get_option( 'gmt_offset' );
71
- $hours = (int) $offset;
72
- $minutes = ( $offset - $hours );
73
-
74
- $sign = ( $offset < 0 ) ? '-' : '+';
75
- $abs_hour = abs( $hours );
76
- $abs_mins = abs( $minutes * 60 );
77
- $tz_offset = sprintf( '%s%02d:%02d', $sign, $abs_hour, $abs_mins );
78
-
79
- return $tz_offset;
80
- }
81
- }
82
-
83
- // List of incompatible plugins
84
- function cau_incompatiblePluginlist() {
85
-
86
- // Pluginlist, write as Plugin path => Issue
87
- $pluginList = array(
88
- 'better-wp-security/better-wp-security.php' => "<span class='cau_disabled'><span class='dashicons dashicons-no'></span></span> May block auto-updating for everything.",
89
- 'updraftplus/updraftplus.php' => "<span class='cau_warning'><span class='dashicons dashicons-warning'></span></span> By default this plugin will not be auto-updated. You'll have to do this manually or enable auto-updating in the settings. <u>Causes no issues with other plugins.</u>"
90
- );
91
-
92
- return $pluginList;
93
-
94
- }
95
- function cau_incompatiblePlugins() {
96
-
97
- $return = false;
98
-
99
- foreach ( cau_incompatiblePluginlist() as $key => $value ) {
100
- if( is_plugin_active( $key ) ) {
101
- $return = true;
102
- }
103
- }
104
-
105
- return $return;
106
-
107
- }
108
-
109
- // Check if has issues
110
- function cau_pluginHasIssues() {
111
-
112
- $return = false;
113
-
114
- if( get_option( 'blog_public' ) == 0 && cau_get_db_value( 'ignore_seo' ) != 'yes' ) {
115
- $return = true;
116
- }
117
-
118
- if( checkAutomaticUpdaterDisabled() ) {
119
- $return = true;
120
- }
121
-
122
- if( checkCronjobsDisabled() && cau_get_db_value( 'ignore_cron' ) != 'yes' ) {
123
- $return = true;
124
- }
125
-
126
- if( cau_incorrectDatabaseVersion() ) {
127
- $return = true;
128
- }
129
-
130
- return $return;
131
- }
132
- function cau_pluginIssueLevels() {
133
-
134
- if( checkAutomaticUpdaterDisabled() ) {
135
- $level = 'high';
136
- } else {
137
- $level = 'low';
138
- }
139
-
140
- return $level;
141
- }
142
- function cau_pluginIssueCount() {
143
-
144
- $count = 0;
145
-
146
- if( get_option( 'blog_public' ) == 0 ) {
147
- $count++;
148
- }
149
- if( checkAutomaticUpdaterDisabled() ) {
150
- $count++;
151
- }
152
- if( checkCronjobsDisabled() ) {
153
- $count++;
154
- }
155
- if( cau_incompatiblePlugins() ) {
156
- foreach ( cau_incompatiblePluginlist() as $key => $value ) {
157
- if( is_plugin_active( $key ) ) {
158
- $count++;
159
- }
160
- }
161
- }
162
-
163
- return $count;
164
- }
165
- function cau_incorrectDatabaseVersion() {
166
- if( get_option( "cau_db_version" ) != cau_db_version() ) {
167
- return true;
168
- } else {
169
- return false;
170
- }
171
- }
172
-
173
- // Run custom hooks on plugin update
174
- function cau_run_custom_hooks_p() {
175
-
176
- // Check if function exists
177
- if ( ! function_exists( 'get_plugins' ) ) {
178
- require_once ABSPATH . 'wp-admin/includes/plugin.php';
179
- }
180
-
181
- // Create array
182
- $allDates = array();
183
-
184
- // Where to look for plugins
185
- $dirr = plugin_dir_path( __DIR__ );
186
- $listOfAll = get_plugins();
187
-
188
- // Number of updates
189
- $numOfUpdates = 0;
190
-
191
- // Loop trough all plugins
192
- foreach ( $listOfAll as $key => $value ) {
193
-
194
- // Get data
195
- $fullPath = $dirr.'/'.$key;
196
- $fileDate = date ( 'YmdHi', filemtime( $fullPath ) );
197
- $fileTime = date ( 'Hi', filemtime( $fullPath ) );
198
- $updateSched = wp_get_schedule( 'wp_update_plugins' );
199
-
200
- // Check when the last update was
201
- if( $updateSched == 'hourly' ) {
202
- $lastday = date( 'YmdHi', strtotime( '-1 hour', time() ) );
203
- } elseif( $updateSched == 'twicedaily' ) {
204
- $lastday = date( 'YmdHi', strtotime( '-12 hours', time() ) );
205
- } elseif( $updateSched == 'daily' ) {
206
- $lastday = date( 'YmdHi', strtotime( '-1 day', time() ) );
207
- } elseif( $updateSched == 'weekly' ) {
208
- $lastday = date( 'YmdHi', strtotime( '-1 week', time() ) );
209
- } elseif( $updateSched == 'monthly' ) {
210
- $lastday = date( 'YmdHi', strtotime( '-1 month', time() ) );
211
- } else {
212
- $lastday = date( 'YmdHi', strtotime( '-1 month', time() ) );
213
- }
214
-
215
- $update_time = wp_next_scheduled( 'wp_update_plugins' );
216
- $range_start = date( 'Hi', strtotime( '-30 minutes', $update_time ) );
217
- $range_end = date( 'Hi', strtotime( '+30 minutes', $update_time ) );
218
-
219
- if( $fileDate >= $lastday ) {
220
-
221
- // Push to array
222
- array_push( $allDates, $fileDate );
223
-
224
- // Update info
225
- if( $fileTime > $range_start && $fileTime < $range_end ) {
226
- $status = __( 'Automatic', 'companion-auto-update' );
227
- } else {
228
- $status = __( 'Manual', 'companion-auto-update' );
229
- }
230
-
231
- $numOfUpdates++;
232
-
233
- cau_updatePluginInformation( $key, $status );
234
-
235
- }
236
-
237
- }
238
-
239
- // If there have been plugin updates run hook
240
- if( $numOfUpdates >= 1 ) {
241
- do_action( 'cau_after_plugin_update' );
242
- }
243
-
244
- }
245
-
246
- // Run custom hooks on theme update
247
- function cau_run_custom_hooks_t() {
248
-
249
- // Create array
250
- $allDates = array();
251
-
252
- // Where to look for plugins
253
- $dirr = get_theme_root();
254
- $listOfAll = wp_get_themes();
255
-
256
- // Loop trough all plugins
257
- foreach ( $listOfAll as $key => $value) {
258
-
259
- // Get data
260
- $fullPath = $dirr.'/'.$key;
261
- $fileDate = date ( 'YmdHi', filemtime( $fullPath ) );
262
- $fileTime = date ( 'Hi', filemtime( $fullPath ) );
263
- $updateSched = wp_get_schedule( 'wp_update_themes' );
264
-
265
- // Check when the last update was
266
- if( $updateSched == 'hourly' ) {
267
- $lastday = date( 'YmdHi', strtotime( '-1 hour', time() ) );
268
- } elseif( $updateSched == 'twicedaily' ) {
269
- $lastday = date( 'YmdHi', strtotime( '-12 hours', time() ) );
270
- } elseif( $updateSched == 'daily' ) {
271
- $lastday = date( 'YmdHi', strtotime( '-1 day', time() ) );
272
- } elseif( $updateSched == 'weekly' ) {
273
- $lastday = date( 'YmdHi', strtotime( '-1 week', time() ) );
274
- } elseif( $updateSched == 'monthly' ) {
275
- $lastday = date( 'YmdHi', strtotime( '-1 month', time() ) );
276
- } else {
277
- $lastday = date( 'YmdHi', strtotime( '-1 month', time() ) );
278
- }
279
-
280
- $update_time = wp_next_scheduled( 'wp_update_themes' );
281
- $range_start = date( 'Hi', strtotime( '-30 minutes', $update_time ) );
282
- $range_end = date( 'Hi', strtotime( '+30 minutes', $update_time ) );
283
-
284
- if( $fileDate >= $lastday ) {
285
-
286
- // Push to array
287
- array_push( $allDates, $fileDate );
288
-
289
- // Update info
290
- if( $fileTime > $range_start && $fileTime < $range_end ) {
291
- $status = __( 'Automatic', 'companion-auto-update' );
292
- } else {
293
- $status = __( 'Manual', 'companion-auto-update' );
294
- }
295
- cau_updatePluginInformation( $key, $status );
296
-
297
- }
298
-
299
- }
300
-
301
- $totalNum = 0;
302
-
303
- // Count number of updated plugins
304
- foreach ( $allDates as $key => $value ) $totalNum++;
305
-
306
- // If there have been plugin updates run hook
307
- if( $totalNum > 0 ) {
308
- do_action( 'cau_after_theme_update' );
309
- }
310
-
311
- }
312
-
313
- // Run custom hooks on core update
314
- function cau_run_custom_hooks_c() {
315
-
316
- // Create array
317
- $totalNum = 0;
318
-
319
- // Get data
320
- $fullPath = ABSPATH.'wp-includes/version.php';
321
- $fileDate = date ( 'YmdHi', filemtime( $fullPath ) );
322
- $updateSched = wp_get_schedule( 'wp_version_check' );
323
-
324
- // Check when the last update was
325
- if( $updateSched == 'hourly' ) {
326
- $lastday = date( 'YmdHi', strtotime( '-1 hour', time() ) );
327
- } elseif( $updateSched == 'twicedaily' ) {
328
- $lastday = date( 'YmdHi', strtotime( '-12 hours', time() ) );
329
- } elseif( $updateSched == 'daily' ) {
330
- $lastday = date( 'YmdHi', strtotime( '-1 day', time() ) );
331
- } elseif( $updateSched == 'weekly' ) {
332
- $lastday = date( 'YmdHi', strtotime( '-1 week', time() ) );
333
- } elseif( $updateSched == 'monthly' ) {
334
- $lastday = date( 'YmdHi', strtotime( '-1 month', time() ) );
335
- } else {
336
- $lastday = date( 'YmdHi', strtotime( '-1 month', time() ) );
337
- }
338
-
339
- // Check manual or automatic
340
- $update_time = wp_next_scheduled( 'wp_version_check' );
341
- $range_start = date( 'Hi', strtotime( '-30 minutes', $update_time ) );
342
- $range_end = date( 'Hi', strtotime( '+30 minutes', $update_time ) );
343
-
344
- if( $fileDate >= $lastday ) {
345
-
346
- // Update info
347
- if( $fileDate > $range_start && $fileDate < $range_end ) {
348
- $status = __( 'Automatic', 'companion-auto-update' );
349
- } else {
350
- $status = __( 'Manual', 'companion-auto-update' );
351
- }
352
- cau_updatePluginInformation( 'core', $status );
353
-
354
- $totalNum++;
355
-
356
- }
357
-
358
- // If there have been plugin updates run hook
359
- if( $totalNum > 0 ) {
360
- do_action( 'cau_after_core_update' );
361
- }
362
-
363
- }
364
-
365
- // Check if automatic updating is disabled globally
366
- function checkAutomaticUpdaterDisabled() {
367
-
368
- // I mean, I know this can be done waaaay better but I's quite late and I need to push a fix so take it or leave it untill I decide to fix this :)
369
-
370
- if ( defined( 'automatic_updater_disabled' ) ) {
371
- if( doing_filter( 'automatic_updater_disabled' ) ) {
372
- return true;
373
- } elseif( constant( 'automatic_updater_disabled' ) == 'true' ) {
374
- return true;
375
- } elseif( constant( 'automatic_updater_disabled' ) == 'minor' ) {
376
- return true;
377
- } else {
378
- return false;
379
- }
380
-
381
- } else if ( defined( 'AUTOMATIC_UPDATER_DISABLED' ) ) {
382
- if( doing_filter( 'AUTOMATIC_UPDATER_DISABLED' ) ) {
383
- return true;
384
- } elseif( constant( 'AUTOMATIC_UPDATER_DISABLED' ) == 'true' ) {
385
- return true;
386
- } elseif( constant( 'AUTOMATIC_UPDATER_DISABLED' ) == 'minor' ) {
387
- return true;
388
- } else {
389
- return false;
390
- }
391
-
392
- } else {
393
- return false;
394
- }
395
-
396
- }
397
-
398
- // Check if cronjobs are disabled
399
- function checkCronjobsDisabled() {
400
-
401
- if ( defined('DISABLE_WP_CRON') && DISABLE_WP_CRON ) {
402
- return true;
403
- } else {
404
- return false;
405
- }
406
-
407
- }
408
-
409
- // Menu location
410
- function cau_menloc( $after = '' ) {
411
- return 'tools.php'.$after;
412
- }
413
- function cau_url( $tab = '' ) {
414
- return admin_url( cau_menloc( '?page=cau-settings&tab='.$tab ) );
415
- }
416
-
417
- // Get the active tab
418
- function active_tab( $page, $identifier = 'tab' ) {
419
- echo _active_tab( $page, $identifier );
420
- }
421
- function _active_tab( $page, $identifier = 'tab' ) {
422
-
423
- if( !isset( $_GET[ $identifier ] ) ) {
424
- $cur_page = '';
425
- } else {
426
- $cur_page = $_GET[ $identifier ];
427
- }
428
-
429
- if( $page == $cur_page ) {
430
- return 'nav-tab-active';
431
- }
432
-
433
- }
434
-
435
- // Get the active subtab
436
- function active_subtab( $page, $identifier = 'tab' ) {
437
-
438
- if( !isset( $_GET[ $identifier ] ) ) {
439
- $cur_page = '';
440
- } else {
441
- $cur_page = $_GET[ $identifier ];
442
- }
443
-
444
- if( $page == $cur_page ) {
445
- echo 'current';
446
- }
447
-
448
- }
449
-
450
- // List of plugins that should not be updated
451
- function donotupdatelist( $filter = 'plugins' ) {
452
-
453
- // Select correct database row
454
- switch ( $filter ) {
455
- case 'themes':
456
- $db_table = 'notUpdateListTh';
457
- break;
458
- case 'plugins':
459
- $db_table = 'notUpdateList';
460
- break;
461
- default:
462
- $db_table = 'notUpdateList';
463
- break;
464
- }
465
-
466
- // Create list
467
- global $wpdb;
468
- $table_name = $wpdb->prefix."auto_updates";
469
- $config = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = '{$db_table}'");
470
-
471
- $list = $config[0]->onoroff;
472
- $list = explode( ", ", $list );
473
- $returnList = array();
474
-
475
- foreach ( $list as $key ) array_push( $returnList, $key );
476
-
477
- return $returnList;
478
-
479
- }
480
- function plugins_donotupdatelist() {
481
-
482
- // Base array
483
- $array = array();
484
-
485
- // Filtered plugins
486
- $filteredplugins = donotupdatelist( 'plugins' );
487
- foreach ( $filteredplugins as $filteredplugin ) array_push( $array, $filteredplugin );
488
-
489
- // Plugin added to the delay list
490
- $delayedplugins = cau_delayed_updates__formated();
491
- foreach ( $delayedplugins as $delayedplugin ) array_push( $array, $delayedplugin );
492
-
493
- // Return array
494
- return $array;
495
- }
496
- function themes_donotupdatelist() {
497
- return donotupdatelist( 'themes' );
498
- }
499
-
500
- // Show the update log
501
- function cau_fetch_log( $limit, $format = 'simple' ) {
502
-
503
- // Database
504
- global $wpdb;
505
- $updateLog = "update_log";
506
- $updateLogDB = $wpdb->prefix.$updateLog;
507
-
508
- // Filter log
509
- if( isset( $_GET['filter'] ) ) {
510
- $filter = $_GET['filter'];
511
- } else {
512
- $filter = 'all';
513
- }
514
-
515
- switch( $filter ) {
516
-
517
- case 'plugins':
518
- $plugins = true;
519
- $themes = false;
520
- $core = false;
521
- $translations = false;
522
- break;
523
-
524
- case 'themes':
525
- $plugins = false;
526
- $themes = true;
527
- $core = false;
528
- $translations = false;
529
- break;
530
-
531
- case 'translations':
532
- $plugins = false;
533
- $themes = false;
534
- $core = false;
535
- $translations = true;
536
- break;
537
-
538
- default:
539
- $plugins = true;
540
- $themes = true;
541
- $core = true;
542
- $translations = false;
543
- break;
544
- }
545
-
546
- // Create arrays
547
- $pluginNames = array();
548
- $pluginVersion = array();
549
- $pluginDates = array();
550
- $pluginDatesF = array();
551
- $plugslug = array();
552
- $type = array();
553
- $method = array();
554
-
555
- // Date format
556
- $dateFormat = get_option( 'date_format' );
557
-
558
- // PLUGINS
559
- if( $plugins ) {
560
-
561
- // Check if function exists
562
- if ( ! function_exists( 'get_plugins' ) ) {
563
- require_once ABSPATH . 'wp-admin/includes/plugin.php';
564
- }
565
-
566
- // Where to look for plugins
567
- $plugdir = plugin_dir_path( __DIR__ );
568
- $allPlugins = get_plugins();
569
-
570
- // Loop trough all plugins
571
- foreach ( $allPlugins as $key => $value) {
572
-
573
- // Get plugin data
574
- $fullPath = $plugdir.'/'.$key;
575
- $getFile = $path_parts = pathinfo( $fullPath );
576
- $pluginData = get_plugin_data( $fullPath );
577
- $pluginSlug = explode( "/", plugin_basename( $key ) );
578
- $pluginSlug = $pluginSlug[0];
579
-
580
- array_push( $plugslug , $pluginSlug );
581
-
582
- // Automatic or Manual (non-db-version)
583
- $date_tod = date ( 'ydm' );
584
- $fileDay = date ( 'ydm', filemtime( $fullPath ) );
585
- $fileTime = date ( 'Hi', filemtime( $fullPath ) );
586
- $updateSched = wp_next_scheduled( 'wp_update_plugins' );
587
- $range_start = date( 'Hi', strtotime( '-30 minutes', $updateSched ) );
588
- $range_end = date( 'Hi', strtotime( '+30 minutes', $updateSched ) );
589
-
590
- if( $date_tod == $fileDay ) {
591
-
592
- if( $fileTime > $range_start && $fileTime < $range_end ) {
593
- $status = __( 'Automatic', 'companion-auto-update' );
594
- } else {
595
- $status = __( 'Manual', 'companion-auto-update' );
596
- }
597
-
598
- array_push( $method , $status );
599
-
600
- } else {
601
-
602
- // Get info from database
603
- if( cau_check_if_exists( $key, 'slug', $updateLog ) ) {
604
- array_push( $method , cau_get_plugininfo( $key, 'method' ) );
605
- } else {
606
- array_push( $method , '-' );
607
- }
608
-
609
- }
610
-
611
- // Get plugin name
612
- foreach ( $pluginData as $dataKey => $dataValue ) {
613
- if( $dataKey == 'Name') {
614
- array_push( $pluginNames , $dataValue );
615
- }
616
- if( $dataKey == 'Version') {
617
- array_push( $pluginVersion , $dataValue );
618
- }
619
- }
620
-
621
- // Get last update date
622
- $fileDate = date ( 'YmdHi', filemtime( $fullPath ) );
623
- if( $format == 'table' ) {
624
- $fileDateF = date_i18n( $dateFormat, filemtime( $fullPath ) );
625
- $fileDateF .= ' &dash; '.date( 'H:i', filemtime( $fullPath ) );
626
- } else {
627
- $fileDateF = date_i18n( $dateFormat, filemtime( $fullPath ) );
628
- }
629
- array_push( $pluginDates, $fileDate );
630
- array_push( $pluginDatesF, $fileDateF );
631
- array_push( $type, 'Plugin' );
632
-
633
- }
634
-
635
- }
636
-
637
- // THEMES
638
- if( $themes ) {
639
-
640
- // Where to look for themes
641
- $themedir = get_theme_root();
642
- $allThemes = wp_get_themes();
643
-
644
- // Loop trough all themes
645
- foreach ( $allThemes as $key => $value) {
646
-
647
- // Get theme data
648
- $fullPath = $themedir.'/'.$key;
649
- $getFile = $path_parts = pathinfo( $fullPath );
650
-
651
- // Get theme name
652
- $theme_data = wp_get_theme( $path_parts['filename'] );
653
- $themeName = $theme_data->get( 'Name' );
654
- $themeVersion = $theme_data->get( 'Version' );
655
- array_push( $pluginNames , $themeName );
656
- array_push( $pluginVersion , $themeVersion );
657
-
658
- // Automatic or Manual (non-db-version)
659
- $date_tod = date ( 'ydm' );
660
- $fileDay = date ( 'ydm', filemtime( $fullPath ) );
661
- $fileTime = date ( 'Hi', filemtime( $fullPath ) );
662
- $updateSched = wp_next_scheduled( 'wp_update_themes' );
663
- $range_start = date( 'Hi', strtotime( '-30 minutes', $updateSched ) );
664
- $range_end = date( 'Hi', strtotime( '+30 minutes', $updateSched ) );
665
-
666
- if( $date_tod == $fileDay ) {
667
-
668
- if( $fileTime > $range_start && $fileTime < $range_end ) {
669
- $status = __( 'Automatic', 'companion-auto-update' );
670
- } else {
671
- $status = __( 'Manual', 'companion-auto-update' );
672
- }
673
-
674
- array_push( $method , $status );
675
-
676
- } else {
677
-
678
- // Get info from database
679
- if( cau_check_if_exists( $key, 'slug', $updateLog ) ) {
680
- array_push( $method , cau_get_plugininfo( $key, 'method' ) );
681
- } else {
682
- array_push( $method , '-' );
683
- }
684
-
685
- }
686
-
687
- // Get last update date
688
- $fileDate = date( 'YmdHi', filemtime( $fullPath ) );
689
-
690
- if( $format == 'table' ) {
691
- $fileDateF = date_i18n( $dateFormat, filemtime( $fullPath ) );
692
- $fileDateF .= ' &dash; '.date ( 'H:i', filemtime( $fullPath ) );
693
- } else {
694
- $fileDateF = date_i18n( $dateFormat, filemtime( $fullPath ) );
695
- }
696
-
697
- array_push( $pluginDates, $fileDate );
698
- array_push( $pluginDatesF, $fileDateF );
699
- array_push( $type, 'Theme' );
700
- array_push( $plugslug , '' );
701
-
702
- }
703
-
704
- }
705
-
706
- // TRANSLATIONS
707
- if( $translations ) {
708
-
709
- // There is no way (at this time) to check if someone changed this link, so therefore it won't work when it's changed, sorry
710
- $transFolder = get_home_path().'wp-content/languages';
711
- if( file_exists( $transFolder ) ) {
712
-
713
- $allThemTranslations = array();
714
- $allThemTypes = array();
715
-
716
- $pt = __( 'Plugin translations', 'companion-auto-update' );
717
- $tt = __( 'Theme translations', 'companion-auto-update' );
718
- $ct = __( 'Core translations', 'companion-auto-update' );
719
-
720
- // Plugin translations
721
- $files = glob( $transFolder.'/plugins/*.{mo}', GLOB_BRACE );
722
- foreach( $files as $file ) {
723
- array_push( $allThemTranslations, $file );
724
- array_push( $allThemTypes, $pt );
725
- }
726
-
727
- // Theme translations
728
- $files = glob( $transFolder.'/themes/*.{mo}', GLOB_BRACE );
729
- foreach( $files as $file ) {
730
- array_push( $allThemTranslations, $file );
731
- array_push( $allThemTypes, $tt );
732
- }
733
-
734
- // Core translations
735
- $files = glob( $transFolder.'/*.{mo}', GLOB_BRACE );
736
- foreach( $files as $file ) {
737
- array_push( $allThemTranslations, $file );
738
- array_push( $allThemTypes, $ct );
739
- }
740
-
741
- foreach( $allThemTranslations as $key => $trans_file ) {
742
-
743
- $transDate = date( 'YmdHi', filemtime( $trans_file ) );
744
-
745
- if( $format == 'table' ) {
746
- $transDateF = date_i18n( $dateFormat, filemtime( $trans_file ) );
747
- $transDateF .= ' &dash; '.date ( 'H:i', filemtime( $trans_file ) );
748
- } else {
749
- $transDateF = date_i18n( $dateFormat, filemtime( $trans_file ) );
750
- }
751
-
752
- $trans_name = basename( $trans_file );
753
- $trans_name = str_replace( "-", " ", $trans_name );
754
- $trans_name = str_replace( ".mo", "", $trans_name );
755
- $trans_name = str_replace( ".json", "", $trans_name );
756
- $trans_lang = substr( $trans_name, strrpos( $trans_name, " " ) + 1 );
757
- $trans_name = str_replace( $trans_lang, "", $trans_name );
758
- $trans_lang = substr( $trans_lang, strrpos( $trans_lang, "_" ) + 1 );
759
-
760
- // Push
761
- array_push( $pluginNames, ucfirst( $trans_name ).': '.$trans_lang );
762
- array_push( $type, $allThemTypes[$key] );
763
- array_push( $pluginVersion, '-' );
764
- array_push( $pluginDates, $transDate );
765
- array_push( $pluginDatesF, $transDateF );
766
- array_push( $plugslug , '' );
767
- array_push( $method , '-' );
768
-
769
- }
770
-
771
- } else {
772
-
773
- $transDate = date('YmdHi');
774
- $transDateF = 'Could not read translations date.';
775
-
776
- array_push( $pluginNames, 'Translations' );
777
- array_push( $type, $trans_type.' translations' );
778
- array_push( $pluginVersion, '-' );
779
- array_push( $pluginDates, $transDate );
780
- array_push( $pluginDatesF, $transDateF );
781
- array_push( $plugslug , '' );
782
-
783
- // Get info from database
784
- array_push( $method , '-' );
785
-
786
- }
787
-
788
- }
789
-
790
- // CORE
791
- if( $core ) {
792
-
793
- $coreFile = ABSPATH.'wp-includes/version.php';
794
- $updateSched = wp_next_scheduled( 'wp_version_check' );
795
-
796
- if( file_exists( $coreFile ) ) {
797
-
798
- $coreDate = date( 'YmdHi', filemtime( $coreFile ) );
799
-
800
- if( $format == 'table' ) {
801
- $coreDateF = date_i18n( $dateFormat, filemtime( $coreFile ) );
802
- $coreDateF .= ' &dash; '.date ( 'H:i', filemtime( $coreFile ) );
803
- } else {
804
- $coreDateF = date_i18n( $dateFormat, filemtime( $coreFile ) );
805
- }
806
-
807
- // Automatic or Manual (non-db-version)
808
- $date_tod = date ( 'ydm' );
809
- $fileDay = date ( 'ydm', filemtime( $coreFile ) );
810
- $fileTime = date ( 'Hi', filemtime( $coreFile ) );
811
- $update_time = wp_next_scheduled( 'wp_version_check' );
812
- $range_start = date( 'Hi', strtotime( '-30 minutes', $update_time ) );
813
- $range_end = date( 'Hi', strtotime( '+30 minutes', $update_time ) );
814
-
815
- if( $date_tod == $fileDay ) {
816
-
817
- if( $fileTime > $range_start && $fileTime < $range_end ) {
818
- $methodVal = __( 'Automatic', 'companion-auto-update' );
819
- } else {
820
- $methodVal = __( 'Manual', 'companion-auto-update' );
821
- }
822
-
823
- } else {
824
-
825
- // Get info from database
826
- if( cau_check_if_exists( $key, 'slug', $updateLog ) ) {
827
- $methodVal = cau_get_plugininfo( 'core', 'method' );
828
- } else {
829
- $methodVal = '';
830
- }
831
-
832
- }
833
-
834
-
835
- } else {
836
- $coreDate = date('YmdHi');
837
- $coreDateF = 'Could not read core date.';
838
- }
839
-
840
- array_push( $pluginNames, 'WordPress' );
841
- array_push( $type, 'WordPress' );
842
- array_push( $pluginVersion, get_bloginfo( 'version' ) );
843
- array_push( $pluginDates, $coreDate );
844
- array_push( $pluginDatesF, $coreDateF );
845
- array_push( $plugslug , '' );
846
-
847
- // Get info from database
848
- array_push( $method , $methodVal );
849
-
850
- }
851
-
852
- // Sort array by date
853
- arsort( $pluginDates );
854
-
855
- if( $limit == 'all' ) {
856
- $limit = 999;
857
- }
858
-
859
- $listClasses = 'wp-list-table widefat autoupdate autoupdatelog';
860
-
861
- if( $format == 'table' ) {
862
- $listClasses .= ' autoupdatelog striped';
863
- } else {
864
- $listClasses .= ' autoupdatewidget';
865
- }
866
-
867
- echo '<table class="'.$listClasses.'">';
868
-
869
- // Show the last updated plugins
870
- if( $format == 'table' ) {
871
-
872
- echo '<thead>
873
- <tr>
874
- <th><strong>'.__( 'Name', 'companion-auto-update' ).'</strong></th>';
875
- if( !$translations ) echo '<th><strong>'.__( 'To version', 'companion-auto-update' ).'</strong></th>';
876
- echo '<th><strong>'.__( 'Type', 'companion-auto-update' ).'</strong></th>
877
- <th><strong>'.__( 'Last updated on', 'companion-auto-update' ).'</strong></th>
878
- <th><strong>'.__( 'Update method', 'companion-auto-update' ).'</strong></th>
879
- </tr>
880
- </thead>';
881
-
882
- }
883
-
884
- echo '<tbody id="the-list">';
885
-
886
- $loopings = 0;
887
-
888
- foreach ( $pluginDates as $key => $value ) {
889
-
890
- if( $loopings < $limit ) {
891
-
892
- echo '<tr>';
893
-
894
- if( $format == 'table' ) {
895
- $pluginName = $pluginNames[$key];
896
- } else {
897
- $pluginName = substr( $pluginNames[$key], 0, 25);
898
- if( strlen( $pluginNames[$key] ) > 25 ) {
899
- $pluginName .= '...';
900
- }
901
- }
902
-
903
- echo '<td class="column-updatetitle"><p><strong title="'. $pluginNames[$key] .'">'.cau_getChangelogUrl( $type[$key], $pluginNames[$key], $plugslug[$key] ).'</strong></p></td>';
904
-
905
- if( $format == 'table' ) {
906
-
907
- if( $type[$key] == 'Plugin' ) {
908
- $thisType = __( 'Plugin', 'companion-auto-update' );
909
- } else if( $type[$key] == 'Theme' ) {
910
- $thisType = __( 'Theme', 'companion-auto-update' );
911
- } else {
912
- $thisType = $type[$key];
913
- }
914
-
915
- if( !$translations ) echo '<td class="cau_hide_on_mobile column-version" style="min-width: 100px;"><p>'. $pluginVersion[$key] .'</p></td>';
916
- echo '<td class="cau_hide_on_mobile column-description"><p>'. $thisType .'</p></td>';
917
-
918
- }
919
-
920
- echo '<td class="column-date" style="min-width: 100px;"><p>'. $pluginDatesF[$key] .'</p></td>';
921
-
922
- if( $format == 'table' ) {
923
- echo '<td class="column-method"><p>'. $method[$key] .'</p></td>';
924
- }
925
-
926
- echo '</tr>';
927
-
928
- $loopings++;
929
-
930
- }
931
-
932
- }
933
-
934
- echo "</tbody></table>";
935
-
936
- }
937
-
938
- // Get the proper changelog URL
939
- function cau_getChangelogUrl( $type, $name, $plugslug ) {
940
-
941
- switch( $type ) {
942
- case 'WordPress':
943
- $url = '';
944
- break;
945
- case 'Plugin':
946
- $url = admin_url( 'plugin-install.php?tab=plugin-information&plugin='.$plugslug.'&section=changelog&TB_iframe=true&width=772&height=772' );
947
- break;
948
- case 'Theme':
949
- $url = '';
950
- break;
951
- }
952
-
953
- if( !empty( $url ) ) {
954
- return '<a href="'.$url.'" class="thickbox open-plugin-details-modal" aria-label="More information about '.$name.'" data-title="'.$name.'">'.$name.'</a>';
955
- } else {
956
- return $name;
957
- }
958
-
959
- }
960
-
961
- // Only update plugins which are enabled
962
- function cau_dontUpdatePlugins( $update, $item ) {
963
-
964
- $plugins = plugins_donotupdatelist();
965
-
966
- if ( in_array( $item->slug, $plugins ) ) {
967
- return false; // Don't update these plugins
968
- } else {
969
- return true; // Always update these plugins
970
- }
971
-
972
-
973
- }
974
- function cau_dontUpdateThemes( $update, $item ) {
975
-
976
- $themes = themes_donotupdatelist();
977
-
978
- if ( in_array( $item->slug, $themes ) ) {
979
- return false; // Don't update these themes
980
- } else {
981
- return true; // Always update these themes
982
- }
983
-
984
-
985
- }
986
-
987
- // Get plugin information of repository
988
- function cau_plugin_info( $slug, $what ) {
989
-
990
- $slug = sanitize_title( $slug );
991
- $cau_transient_name = 'cau' . $slug;
992
- $cau_info = get_transient( $cau_transient_name );
993
-
994
- if( !function_exists( 'plugins_api' ) ) require_once( ABSPATH.'wp-admin/includes/plugin-install.php' );
995
- $cau_info = plugins_api( 'plugin_information', array( 'slug' => $slug ) );
996
-
997
- if ( ! $cau_info or is_wp_error( $cau_info ) ) {
998
- return false;
999
- }
1000
-
1001
- set_transient( $cau_transient_name, $cau_info, 3600 );
1002
-
1003
- switch ( $what ) {
1004
- case 'versions':
1005
- return $cau_info->versions;
1006
- break;
1007
- case 'version':
1008
- return $cau_info->version;
1009
- break;
1010
- case 'name':
1011
- return $cau_info->name;
1012
- break;
1013
- case 'slug':
1014
- return $cau_info->slug;
1015
- break;
1016
- }
1017
-
1018
- }
1019
-
1020
- // Get list of outdated plugins
1021
- function cau_list_outdated() {
1022
-
1023
- $outdatedList = array();
1024
-
1025
- // Check if function exists
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
-
1032
- $slug = $key;
1033
- $explosion = explode( '/', $slug );
1034
- $actualSlug = array_shift( $explosion );
1035
-
1036
- // Get plugin name
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
- }
1054
-
1055
- return $outdatedList;
1056
-
1057
- }
1058
-
1059
- // Better version compare
1060
- function cau_version_compare( $ver1, $ver2, $operator = null ) {
1061
- $p = '#(\.0+)+($|-)#';
1062
- $ver1 = preg_replace( $p, '', $ver1 );
1063
- $ver2 = preg_replace( $p, '', $ver2 );
1064
- return isset( $operator ) ? version_compare( $ver1, $ver2, $operator ) : version_compare( $ver1, $ver2 );
1065
- }
1066
-
1067
- // Get plugin information of currently installed plugins
1068
- function cau_active_plugin_info( $slug, $what ) {
1069
-
1070
- // Check if function exists
1071
- if ( ! function_exists( 'get_plugins' ) ) {
1072
- require_once ABSPATH . 'wp-admin/includes/plugin.php';
1073
- }
1074
-
1075
- $allPlugins = get_plugins();
1076
-
1077
- foreach ($allPlugins as $key => $value) {
1078
- $thisSlug = explode('/', $key);
1079
- $thisSlugE = $thisSlug[0];
1080
- if( $thisSlug == $slug ) {
1081
-
1082
- if( $what == 'version' ) return $value['Version'];
1083
-
1084
- }
1085
- }
1086
-
1087
- }
1088
-
1089
- // Remove update nag when major updates are disabled
1090
- function cau_hideUpdateNag() {
1091
- if( cau_get_db_value( 'major' ) != 'on' ) {
1092
- remove_action( 'admin_notices', 'update_nag', 3 );
1093
- remove_action( 'network_admin_notices', 'maintenance_nag', 10 );
1094
- }
1095
- }
1096
- add_action( 'admin_head', 'cau_hideUpdateNag', 100 );
1097
-
1098
- // Add more intervals to event schedules
1099
- function cau_addMoreIntervals( $schedules ) {
1100
-
1101
- // Add a weekly interval.
1102
- $schedules['weekly'] = array(
1103
- 'interval' => 604800,
1104
- 'display' => __( 'Every week', 'companion-auto-update' ),
1105
- );
1106
-
1107
- // Add a twice montly interval.
1108
- $schedules['twice_monthly'] = array(
1109
- 'interval' => 1209600,
1110
- 'display' => __( 'Every 2 weeks', 'companion-auto-update' ),
1111
- );
1112
-
1113
- // Add a montly interval.
1114
- $schedules['once_monthly'] = array(
1115
- 'interval' => 2419200,
1116
- 'display' => __( 'Every 4 weeks', 'companion-auto-update' ),
1117
- );
1118
-
1119
- return $schedules;
1120
-
1121
- }
1122
- add_filter( 'cron_schedules', 'cau_addMoreIntervals' );
1123
-
1124
- // Get only unique schedules
1125
- function cau_wp_get_schedules() {
1126
-
1127
- // Start variables
1128
- $availableIntervals = wp_get_schedules();
1129
- $array_unique = array();
1130
- $intervalTimes = array();
1131
- $intervalNames = array();
1132
- $intervalUniques = array();
1133
- $counter = 0;
1134
-
1135
- // Get all intervals
1136
- foreach ( $availableIntervals as $key => $value ) {
1137
-
1138
- // Do a bunch of checks to format them the right way
1139
- foreach ( $value as $display => $interval ) {
1140
-
1141
- if( $display == 'interval' ) {
1142
-
1143
- if( $interval == '86400' ) $key = 'daily'; // Force the daily interval to be called daily, required by a bunch of handles of this plugin
1144
-
1145
- $intervalTimes[$counter] = $key; // Add the backend name (i.e. "once_monthly" or "daily")
1146
- $intervalUniques[$counter] = $interval; // Add the unix timestamp of this interval, used to identify unique items
1147
-
1148
- // Format display name in a proper way
1149
- $numOfMinutes = ($interval/60);
1150
- $identifier = __( 'minutes', 'companion-auto-update' );
1151
-
1152
- // I just know there's an easier way for this, but I can't come up with it and this works so...
1153
- if( $interval >= (60*60) ) {
1154
- $numOfMinutes = ($numOfMinutes/60);
1155
- $identifier = __( 'hours', 'companion-auto-update' );
1156
- }
1157
- if( $interval >= (60*60*24) ) {
1158
- $numOfMinutes = ($numOfMinutes/24);
1159
- $identifier = __( 'days', 'companion-auto-update' );
1160
- }
1161
- if( $interval >= (60*60*24*7) ) {
1162
- $numOfMinutes = ($numOfMinutes/7);
1163
- $identifier = __( 'weeks', 'companion-auto-update' );
1164
- }
1165
- if( $interval >= (60*60*24*7*(52/12)) ) {
1166
- $numOfMinutes = ($numOfMinutes/(52/12));
1167
- $identifier = __( 'months', 'companion-auto-update' );
1168
- }
1169
-
1170
- $display = sprintf( esc_html__( 'Every %s %s', 'companion-auto-update' ), round( $numOfMinutes, 2 ), $identifier ); // Translateble
1171
- $intervalNames[$counter] = $display; // Add the display name (i.e. "Once a month" or "Once Daily")
1172
-
1173
- $counter++; // Make sure the next interval gets a new "key" value
1174
- }
1175
-
1176
- }
1177
-
1178
- }
1179
-
1180
- // Sort the interval from smallest to largest
1181
- asort( $intervalUniques );
1182
-
1183
- // Prevent duplicates
1184
- foreach ( array_unique( $intervalUniques ) as $key => $value ) {
1185
- // $value is the timestamp
1186
- // $intervalTimes[$key] is the backend name
1187
- // $intervalNames[$key] is the display name
1188
- $array_unique[$intervalTimes[$key]] = $intervalNames[$key];
1189
- }
1190
-
1191
- // Return the array
1192
- return $array_unique;
1193
-
1194
- }
1195
-
1196
- // Check if the update log db is empty
1197
- function cau_updateLogDBisEmpty() {
1198
-
1199
- global $wpdb;
1200
- $updateDB = "update_log";
1201
- $updateLog = $wpdb->prefix.$updateDB;
1202
- $row_count = $wpdb->get_var( "SELECT COUNT(*) FROM $updateLog" );
1203
-
1204
- if( $row_count > 0 ) {
1205
- return false;
1206
- } else {
1207
- return true;
1208
- }
1209
- }
1210
-
1211
- // Plugin information to DB
1212
- function cau_savePluginInformation( $method = 'New' ) {
1213
-
1214
- // Check if function exists
1215
- if ( ! function_exists( 'get_plugins' ) ) {
1216
- require_once ABSPATH . 'wp-admin/includes/plugin.php';
1217
- }
1218
-
1219
- // Set variables
1220
- global $wpdb;
1221
- $updateDB = "update_log";
1222
- $updateLog = $wpdb->prefix.$updateDB;
1223
- $allPlugins = get_plugins();
1224
- $allThemes = wp_get_themes();
1225
-
1226
- // Loop trough all themes
1227
- foreach ( $allThemes as $key => $value ) {
1228
- if( !cau_check_if_exists( $key, 'slug', $updateDB ) ) $wpdb->insert( $updateLog, array( 'slug' => $key, 'oldVersion' => '-', 'method' => $method ) );
1229
- }
1230
-
1231
- // Loop trough all plugins
1232
- foreach ( $allPlugins as $key => $value ) {
1233
- if( !cau_check_if_exists( $key, 'slug', $updateDB ) ) $wpdb->insert( $updateLog, array( 'slug' => $key, 'oldVersion' => '-', 'method' => $method ) );
1234
- }
1235
-
1236
- // Core
1237
- if( !cau_check_if_exists( 'core', 'slug', $updateDB ) ) $wpdb->insert( $updateLog, array( 'slug' => 'core', 'oldVersion' => '-', 'method' => $method ) );
1238
-
1239
- }
1240
-
1241
- function cau_updatePluginInformation( $slug, $method = '-', $newVersion = '-' ) {
1242
-
1243
- global $wpdb;
1244
- $updateDB = "update_log";
1245
- $updateLog = $wpdb->prefix.$updateDB;
1246
- $wpdb->query( $wpdb->prepare( "UPDATE $updateLog SET newVersion = '%s', method = %s WHERE slug = '%s'", $newVersion, $method, $slug ) );
1247
-
1248
- }
1249
-
1250
- function cau_siteHealthSignature() {
1251
- return '<p style="font-size: 12px; color: #707070;">'.__( 'This was reported by the Companion Auto Update plugin', 'companion-auto-update' ).'</p>';
1252
- }
1253
-
1254
- function cau_add_siteHealthTest( $tests ) {
1255
- $tests['direct']['cau_disabled'] = array( 'label' => __( 'Companion Auto Update', 'companion-auto-update' ), 'test' => 'cau_disabled_test' );
1256
- return $tests;
1257
- }
1258
- add_filter( 'site_status_tests', 'cau_add_siteHealthTest' );
1259
-
1260
- function cau_disabled_test() {
1261
-
1262
- $result = array(
1263
- 'label' => __( 'Auto updating is enabled', 'companion-auto-update' ),
1264
- 'status' => 'good',
1265
- 'badge' => array(
1266
- 'label' => __( 'Security' ),
1267
- 'color' => 'blue',
1268
- ),
1269
- 'description' => sprintf( '<p>%s</p>', __( "Automatic updating isn't disabled on this site.", 'companion-auto-update' ) ),
1270
- 'actions' => '',
1271
- 'test' => 'cau_disabled',
1272
- );
1273
-
1274
- if ( checkAutomaticUpdaterDisabled() OR !has_filter( 'wp_version_check', 'wp_version_check' ) ) {
1275
- $result['status'] = 'critical';
1276
- $result['label'] = __( 'Auto updating is disabled', 'companion-auto-update' );
1277
- $result['description'] = __( 'Automatic updating is disabled on this site by either WordPress, another plugin or your webhost.', 'companion-auto-update' );
1278
- $result['description'] .= ' '.__( 'For more information about this error check the status page.', 'companion-auto-update' );
1279
- $result['actions'] .= sprintf( '<p><a href="%s">%s</a>', esc_url( cau_url( 'status' ) ), __( 'Check the status page', 'companion-auto-update' ) );
1280
- }
1281
-
1282
- $result['actions'] .= cau_siteHealthSignature();
1283
-
1284
- return $result;
1285
- }
1286
-
1287
- // Check for version control
1288
- function cau_test_is_vcs_checkout( $context ) {
1289
-
1290
- $context_dirs = array( ABSPATH );
1291
- $vcs_dirs = array( '.svn', '.git', '.hg', '.bzr' );
1292
- $check_dirs = array();
1293
- $result = array();
1294
-
1295
- foreach ( $context_dirs as $context_dir ) {
1296
- // Walk up from $context_dir to the root.
1297
- do {
1298
- $check_dirs[] = $context_dir;
1299
-
1300
- // Once we've hit '/' or 'C:\', we need to stop. dirname will keep returning the input here.
1301
- if ( $context_dir == dirname( $context_dir ) )
1302
- break;
1303
-
1304
- // Continue one level at a time.
1305
- } while ( $context_dir = dirname( $context_dir ) );
1306
- }
1307
-
1308
- $check_dirs = array_unique( $check_dirs );
1309
-
1310
- // Search all directories we've found for evidence of version control.
1311
- foreach ( $vcs_dirs as $vcs_dir ) {
1312
- foreach ( $check_dirs as $check_dir ) {
1313
- if ( $checkout = @is_dir( rtrim( $check_dir, '\\/' ) . "/$vcs_dir" ) ) {
1314
- break 2;
1315
- }
1316
- }
1317
- }
1318
-
1319
- if ( $checkout && ! apply_filters( 'automatic_updates_is_vcs_checkout', true, $context ) ) {
1320
- $result['description'] = sprintf( __( 'The folder %s was detected as being under version control (%s), but the %s filter is allowing updates' , 'companion-auto-update' ), "<code>$check_dir</code>", "<code>automatic_updates_is_vcs_checkout</code>" );
1321
- $result['icon'] = 'warning';
1322
- $result['status'] = 'info';
1323
- } else if ( $checkout ) {
1324
- $result['description'] = sprintf( __( 'The folder %s was detected as being under version control (%s)' , 'companion-auto-update' ), "<code>$check_dir</code>", "<code>$vcs_dir</code>" );
1325
- $result['icon'] = 'no';
1326
- $result['status'] = 'disabled';
1327
- } else {
1328
- $result['description'] = __( 'No issues detected' , 'companion-auto-update' );
1329
- $result['icon'] = 'yes-alt';
1330
- $result['status'] = 'enabled';
1331
- }
1332
-
1333
- return $result;
1334
- }
1335
-
1336
- // Check if plugins need to be delayed
1337
- function cau_check_delayed() {
1338
- if( cau_get_db_value( 'update_delay' ) == 'on' ) {
1339
- cau_hold_updates();
1340
- cau_unhold_updates();
1341
- } else {
1342
- cau_unhold_all_updates();
1343
- }
1344
- }
1345
-
1346
- // List of all delayed plugins
1347
- function cau_delayed_updates() {
1348
-
1349
- global $wpdb;
1350
- $plugin_list = array();
1351
- $updateLog = $wpdb->prefix."update_log";
1352
- $put_on_hold = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$updateLog} WHERE put_on_hold <> '%s'", '0' ) );
1353
- foreach ( $put_on_hold as $plugin ) {
1354
- array_push( $plugin_list, $plugin->slug );
1355
- }
1356
- return $plugin_list;
1357
-
1358
- }
1359
-
1360
- // List of all delayed plugins for the update function
1361
- function cau_delayed_updates__formated() {
1362
-
1363
- $plugin_list = array();
1364
- foreach ( cau_delayed_updates() as $plugin ) {
1365
- $explosion = explode( '/', $plugin );
1366
- $short_slug = array_shift( $explosion );
1367
- array_push( $plugin_list, $short_slug );
1368
- }
1369
- return $plugin_list;
1370
-
1371
- }
1372
-
1373
- // Add "put on hold" timestamp to the database if it hasn't been set yet
1374
- function cau_hold_updates() {
1375
-
1376
- require_once( ABSPATH.'wp-admin/includes/plugin-install.php' );
1377
- $plugins = get_plugin_updates();
1378
-
1379
- if ( !empty( $plugins ) ) {
1380
- $list = array();
1381
- foreach ( (array)$plugins as $plugin_file => $plugin_data ) {
1382
- if( !in_array( $plugin_file, cau_delayed_updates() ) ) {
1383
- global $wpdb;
1384
- $updateDB = "update_log";
1385
- $updateLog = $wpdb->prefix.$updateDB;
1386
- $wpdb->query( $wpdb->prepare( "UPDATE $updateLog SET put_on_hold = '%s' WHERE slug = '%s'", strtotime( "now" ), $plugin_file ) );
1387
- }
1388
- }
1389
- }
1390
- }
1391
-
1392
- // Remove plugins from "put on hold" after x days
1393
- function cau_unhold_updates() {
1394
-
1395
- if( cau_get_db_value( 'update_delay_days' ) != '' ) {
1396
- $after_x_days = cau_get_db_value( 'update_delay_days' );
1397
- } else {
1398
- $after_x_days = '2';
1399
- }
1400
-
1401
- global $wpdb;
1402
-
1403
- $today = strtotime( "now" );
1404
- $updateLog = $wpdb->prefix."update_log";
1405
- $put_on_hold = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$updateLog} WHERE put_on_hold <> '%s'", '0' ) );
1406
-
1407
- foreach ( $put_on_hold as $plugin ) {
1408
-
1409
- $plugin_file = $plugin->slug;
1410
- $put_on_hold_date = $plugin->put_on_hold;
1411
- $remove_after = strtotime( '+'.$after_x_days.' days', $put_on_hold_date );
1412
-
1413
- if( $remove_after <= $today ) {
1414
- $wpdb->query( $wpdb->prepare( "UPDATE {$updateLog} SET put_on_hold = '%s' WHERE slug = '%s'", '0', $plugin_file ) );
1415
- }
1416
-
1417
- }
1418
-
1419
- }
1420
-
1421
- // Remove all plugins from "put on hold" if option is disabled
1422
- function cau_unhold_all_updates() {
1423
- global $wpdb;
1424
- $updateLog = $wpdb->prefix."update_log";
1425
- $put_on_hold = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$updateLog} WHERE put_on_hold <> '%s'", '0' ) );
1426
- foreach ( $put_on_hold as $plugin ) {
1427
- $plugin_file = $plugin->slug;
1428
- $wpdb->query( $wpdb->prepare( "UPDATE {$updateLog} SET put_on_hold = '%s' WHERE slug = '%s'", '0', $plugin_file ) );
1429
- }
1430
  }
1
+ <?php
2
+
3
+ // What user rights can edit plugin settings?
4
+ function cau_allowed_user_rights() {
5
+
6
+ // Current user
7
+ $user = wp_get_current_user();
8
+
9
+ // Allow roles
10
+ $allowed_roles = array( 'administrator' );
11
+ if( cau_get_db_value( 'allow_editor' ) == 'on' ) array_push( $allowed_roles, 'editor' );
12
+ if( cau_get_db_value( 'allow_author' ) == 'on' ) array_push( $allowed_roles, 'author' );
13
+
14
+ // Check
15
+ if ( array_intersect( $allowed_roles, $user->roles ) ) {
16
+ return true;
17
+ } else {
18
+ return false;
19
+ }
20
+ }
21
+
22
+ // Get database value
23
+ function cau_get_db_value( $name, $table = 'auto_updates' ) {
24
+
25
+ global $wpdb;
26
+ $table_name = $wpdb->prefix.$table;
27
+ $cau_configs = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$table_name} WHERE name = '%s'", $name ) );
28
+ foreach ( $cau_configs as $config ) return $config->onoroff;
29
+
30
+ }
31
+
32
+ // Get database value
33
+ function cau_get_plugininfo( $check, $field ) {
34
+
35
+ global $wpdb;
36
+ $table_name = $wpdb->prefix.'update_log';
37
+ $cau_configs = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$table_name} WHERE slug = '%s'", $check ) );
38
+ foreach ( $cau_configs as $config ) return $config->$field;
39
+
40
+ }
41
+
42
+ // Get the set timezone
43
+ function cau_get_proper_timezone() {
44
+
45
+ // WP 5.3 adds the wp_timezone_string function
46
+ if ( !function_exists( 'wp_timezone_string' ) ) {
47
+ $timezone = get_option( 'timezone_string' );
48
+ } else {
49
+ $timezone = wp_timezone_string();
50
+ }
51
+
52
+ // Should fix an reported issue
53
+ if( $timezone == '+00:00' ) {
54
+ $timezone = 'UTC';
55
+ }
56
+
57
+ return $timezone;
58
+
59
+ }
60
+
61
+ // Copy of the wp_timezone_string for < 5.3 compat
62
+ if ( !function_exists( 'wp_timezone_string' ) ) {
63
+ function wp_timezone_string() {
64
+ $timezone_string = get_option( 'timezone_string' );
65
+
66
+ if ( $timezone_string ) {
67
+ return $timezone_string;
68
+ }
69
+
70
+ $offset = (float) get_option( 'gmt_offset' );
71
+ $hours = (int) $offset;
72
+ $minutes = ( $offset - $hours );
73
+
74
+ $sign = ( $offset < 0 ) ? '-' : '+';
75
+ $abs_hour = abs( $hours );
76
+ $abs_mins = abs( $minutes * 60 );
77
+ $tz_offset = sprintf( '%s%02d:%02d', $sign, $abs_hour, $abs_mins );
78
+
79
+ return $tz_offset;
80
+ }
81
+ }
82
+
83
+ // List of incompatible plugins
84
+ function cau_incompatiblePluginlist() {
85
+
86
+ // Pluginlist, write as Plugin path => Issue
87
+ $pluginList = array(
88
+ 'better-wp-security/better-wp-security.php' => "<span class='cau_disabled'><span class='dashicons dashicons-no'></span></span> May block auto-updating for everything.",
89
+ 'updraftplus/updraftplus.php' => "<span class='cau_warning'><span class='dashicons dashicons-warning'></span></span> By default this plugin will not be auto-updated. You'll have to do this manually or enable auto-updating in the settings. <u>Causes no issues with other plugins.</u>"
90
+ );
91
+
92
+ return $pluginList;
93
+
94
+ }
95
+ function cau_incompatiblePlugins() {
96
+
97
+ $return = false;
98
+
99
+ foreach ( cau_incompatiblePluginlist() as $key => $value ) {
100
+ if( is_plugin_active( $key ) ) {
101
+ $return = true;
102
+ }
103
+ }
104
+
105
+ return $return;
106
+
107
+ }
108
+
109
+ // Check if has issues
110
+ function cau_pluginHasIssues() {
111
+
112
+ $return = false;
113
+
114
+ if( get_option( 'blog_public' ) == 0 && cau_get_db_value( 'ignore_seo' ) != 'yes' ) {
115
+ $return = true;
116
+ }
117
+
118
+ if( checkAutomaticUpdaterDisabled() ) {
119
+ $return = true;
120
+ }
121
+
122
+ if( checkCronjobsDisabled() && cau_get_db_value( 'ignore_cron' ) != 'yes' ) {
123
+ $return = true;
124
+ }
125
+
126
+ if( cau_incorrectDatabaseVersion() ) {
127
+ $return = true;
128
+ }
129
+
130
+ return $return;
131
+ }
132
+ function cau_pluginIssueLevels() {
133
+
134
+ if( checkAutomaticUpdaterDisabled() ) {
135
+ $level = 'high';
136
+ } else {
137
+ $level = 'low';
138
+ }
139
+
140
+ return $level;
141
+ }
142
+ function cau_pluginIssueCount() {
143
+
144
+ $count = 0;
145
+
146
+ if( get_option( 'blog_public' ) == 0 ) {
147
+ $count++;
148
+ }
149
+ if( checkAutomaticUpdaterDisabled() ) {
150
+ $count++;
151
+ }
152
+ if( checkCronjobsDisabled() ) {
153
+ $count++;
154
+ }
155
+ if( cau_incompatiblePlugins() ) {
156
+ foreach ( cau_incompatiblePluginlist() as $key => $value ) {
157
+ if( is_plugin_active( $key ) ) {
158
+ $count++;
159
+ }
160
+ }
161
+ }
162
+
163
+ return $count;
164
+ }
165
+ function cau_incorrectDatabaseVersion() {
166
+ if( get_option( "cau_db_version" ) != cau_db_version() ) {
167
+ return true;
168
+ } else {
169
+ return false;
170
+ }
171
+ }
172
+
173
+ // Run custom hooks on plugin update
174
+ function cau_run_custom_hooks_p() {
175
+
176
+ // Check if function exists
177
+ if ( ! function_exists( 'get_plugins' ) ) {
178
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
179
+ }
180
+
181
+ // Create array
182
+ $allDates = array();
183
+
184
+ // Where to look for plugins
185
+ $dirr = plugin_dir_path( __DIR__ );
186
+ $listOfAll = get_plugins();
187
+
188
+ // Number of updates
189
+ $numOfUpdates = 0;
190
+
191
+ // Loop trough all plugins
192
+ foreach ( $listOfAll as $key => $value ) {
193
+
194
+ // Get data
195
+ $fullPath = $dirr.'/'.$key;
196
+ $fileDate = date ( 'YmdHi', filemtime( $fullPath ) );
197
+ $fileTime = date ( 'Hi', filemtime( $fullPath ) );
198
+ $updateSched = wp_get_schedule( 'wp_update_plugins' );
199
+
200
+ // Check when the last update was
201
+ if( $updateSched == 'hourly' ) {
202
+ $lastday = date( 'YmdHi', strtotime( '-1 hour', time() ) );
203
+ } elseif( $updateSched == 'twicedaily' ) {
204
+ $lastday = date( 'YmdHi', strtotime( '-12 hours', time() ) );
205
+ } elseif( $updateSched == 'daily' ) {
206
+ $lastday = date( 'YmdHi', strtotime( '-1 day', time() ) );
207
+ } elseif( $updateSched == 'weekly' ) {
208
+ $lastday = date( 'YmdHi', strtotime( '-1 week', time() ) );
209
+ } elseif( $updateSched == 'monthly' ) {
210
+ $lastday = date( 'YmdHi', strtotime( '-1 month', time() ) );
211
+ } else {
212
+ $lastday = date( 'YmdHi', strtotime( '-1 month', time() ) );
213
+ }
214
+
215
+ $update_time = wp_next_scheduled( 'wp_update_plugins' );
216
+ $range_start = date( 'Hi', strtotime( '-30 minutes', $update_time ) );
217
+ $range_end = date( 'Hi', strtotime( '+30 minutes', $update_time ) );
218
+
219
+ if( $fileDate >= $lastday ) {
220
+
221
+ // Push to array
222
+ array_push( $allDates, $fileDate );
223
+
224
+ // Update info
225
+ if( $fileTime > $range_start && $fileTime < $range_end ) {
226
+ $status = __( 'Automatic', 'companion-auto-update' );
227
+ } else {
228
+ $status = __( 'Manual', 'companion-auto-update' );
229
+ }
230
+
231
+ $numOfUpdates++;
232
+
233
+ cau_updatePluginInformation( $key, $status );
234
+
235
+ }
236
+
237
+ }
238
+
239
+ // If there have been plugin updates run hook
240
+ if( $numOfUpdates >= 1 ) {
241
+ do_action( 'cau_after_plugin_update' );
242
+ }
243
+
244
+ }
245
+
246
+ // Run custom hooks on theme update
247
+ function cau_run_custom_hooks_t() {
248
+
249
+ // Create array
250
+ $allDates = array();
251
+
252
+ // Where to look for plugins
253
+ $dirr = get_theme_root();
254
+ $listOfAll = wp_get_themes();
255
+
256
+ // Loop trough all plugins
257
+ foreach ( $listOfAll as $key => $value) {
258
+
259
+ // Get data
260
+ $fullPath = $dirr.'/'.$key;
261
+ $fileDate = date ( 'YmdHi', filemtime( $fullPath ) );
262
+ $fileTime = date ( 'Hi', filemtime( $fullPath ) );
263
+ $updateSched = wp_get_schedule( 'wp_update_themes' );
264
+
265
+ // Check when the last update was
266
+ if( $updateSched == 'hourly' ) {
267
+ $lastday = date( 'YmdHi', strtotime( '-1 hour', time() ) );
268
+ } elseif( $updateSched == 'twicedaily' ) {
269
+ $lastday = date( 'YmdHi', strtotime( '-12 hours', time() ) );
270
+ } elseif( $updateSched == 'daily' ) {
271
+ $lastday = date( 'YmdHi', strtotime( '-1 day', time() ) );
272
+ } elseif( $updateSched == 'weekly' ) {
273
+ $lastday = date( 'YmdHi', strtotime( '-1 week', time() ) );
274
+ } elseif( $updateSched == 'monthly' ) {
275
+ $lastday = date( 'YmdHi', strtotime( '-1 month', time() ) );
276
+ } else {
277
+ $lastday = date( 'YmdHi', strtotime( '-1 month', time() ) );
278
+ }
279
+
280
+ $update_time = wp_next_scheduled( 'wp_update_themes' );
281
+ $range_start = date( 'Hi', strtotime( '-30 minutes', $update_time ) );
282
+ $range_end = date( 'Hi', strtotime( '+30 minutes', $update_time ) );
283
+
284
+ if( $fileDate >= $lastday ) {
285
+
286
+ // Push to array
287
+ array_push( $allDates, $fileDate );
288
+
289
+ // Update info
290
+ if( $fileTime > $range_start && $fileTime < $range_end ) {
291
+ $status = __( 'Automatic', 'companion-auto-update' );
292
+ } else {
293
+ $status = __( 'Manual', 'companion-auto-update' );
294
+ }
295
+ cau_updatePluginInformation( $key, $status );
296
+
297
+ }
298
+
299
+ }
300
+
301
+ $totalNum = 0;
302
+
303
+ // Count number of updated plugins
304
+ foreach ( $allDates as $key => $value ) $totalNum++;
305
+
306
+ // If there have been plugin updates run hook
307
+ if( $totalNum > 0 ) {
308
+ do_action( 'cau_after_theme_update' );
309
+ }
310
+
311
+ }
312
+
313
+ // Run custom hooks on core update
314
+ function cau_run_custom_hooks_c() {
315
+
316
+ // Create array
317
+ $totalNum = 0;
318
+
319
+ // Get data
320
+ $fullPath = ABSPATH.'wp-includes/version.php';
321
+ $fileDate = date ( 'YmdHi', filemtime( $fullPath ) );
322
+ $updateSched = wp_get_schedule( 'wp_version_check' );
323
+
324
+ // Check when the last update was
325
+ if( $updateSched == 'hourly' ) {
326
+ $lastday = date( 'YmdHi', strtotime( '-1 hour', time() ) );
327
+ } elseif( $updateSched == 'twicedaily' ) {
328
+ $lastday = date( 'YmdHi', strtotime( '-12 hours', time() ) );
329
+ } elseif( $updateSched == 'daily' ) {
330
+ $lastday = date( 'YmdHi', strtotime( '-1 day', time() ) );
331
+ } elseif( $updateSched == 'weekly' ) {
332
+ $lastday = date( 'YmdHi', strtotime( '-1 week', time() ) );
333
+ } elseif( $updateSched == 'monthly' ) {
334
+ $lastday = date( 'YmdHi', strtotime( '-1 month', time() ) );
335
+ } else {
336
+ $lastday = date( 'YmdHi', strtotime( '-1 month', time() ) );
337
+ }
338
+
339
+ // Check manual or automatic
340
+ $update_time = wp_next_scheduled( 'wp_version_check' );
341
+ $range_start = date( 'Hi', strtotime( '-30 minutes', $update_time ) );
342
+ $range_end = date( 'Hi', strtotime( '+30 minutes', $update_time ) );
343
+
344
+ if( $fileDate >= $lastday ) {
345
+
346
+ // Update info
347
+ if( $fileDate > $range_start && $fileDate < $range_end ) {
348
+ $status = __( 'Automatic', 'companion-auto-update' );
349
+ } else {
350
+ $status = __( 'Manual', 'companion-auto-update' );
351
+ }
352
+ cau_updatePluginInformation( 'core', $status );
353
+
354
+ $totalNum++;
355
+
356
+ }
357
+
358
+ // If there have been plugin updates run hook
359
+ if( $totalNum > 0 ) {
360
+ do_action( 'cau_after_core_update' );
361
+ }
362
+
363
+ }
364
+
365
+ // Check if automatic updating is disabled globally
366
+ function checkAutomaticUpdaterDisabled() {
367
+
368
+ // I mean, I know this can be done waaaay better but I's quite late and I need to push a fix so take it or leave it untill I decide to fix this :)
369
+
370
+ if ( defined( 'automatic_updater_disabled' ) ) {
371
+ if( doing_filter( 'automatic_updater_disabled' ) ) {
372
+ return true;
373
+ } elseif( constant( 'automatic_updater_disabled' ) == 'true' ) {
374
+ return true;
375
+ } elseif( constant( 'automatic_updater_disabled' ) == 'minor' ) {
376
+ return true;
377
+ } else {
378
+ return false;
379
+ }
380
+
381
+ } else if ( defined( 'AUTOMATIC_UPDATER_DISABLED' ) ) {
382
+ if( doing_filter( 'AUTOMATIC_UPDATER_DISABLED' ) ) {
383
+ return true;
384
+ } elseif( constant( 'AUTOMATIC_UPDATER_DISABLED' ) == 'true' ) {
385
+ return true;
386
+ } elseif( constant( 'AUTOMATIC_UPDATER_DISABLED' ) == 'minor' ) {
387
+ return true;
388
+ } else {
389
+ return false;
390
+ }
391
+
392
+ } else {
393
+ return false;
394
+ }
395
+
396
+ }
397
+
398
+ // Check if cronjobs are disabled
399
+ function checkCronjobsDisabled() {
400
+
401
+ if ( defined('DISABLE_WP_CRON') && DISABLE_WP_CRON ) {
402
+ return true;
403
+ } else {
404
+ return false;
405
+ }
406
+
407
+ }
408
+
409
+ // Menu location
410
+ function cau_menloc( $after = '' ) {
411
+ return 'tools.php'.$after;
412
+ }
413
+ function cau_url( $tab = '' ) {
414
+ return admin_url( cau_menloc( '?page=cau-settings&tab='.$tab ) );
415
+ }
416
+
417
+ // Get the active tab
418
+ function active_tab( $page, $identifier = 'tab' ) {
419
+ echo _active_tab( $page, $identifier );
420
+ }
421
+ function _active_tab( $page, $identifier = 'tab' ) {
422
+
423
+ if( !isset( $_GET[ $identifier ] ) ) {
424
+ $cur_page = '';
425
+ } else {
426
+ $cur_page = $_GET[ $identifier ];
427
+ }
428
+
429
+ if( $page == $cur_page ) {
430
+ return 'nav-tab-active';
431
+ }
432
+
433
+ }
434
+
435
+ // Get the active subtab
436
+ function active_subtab( $page, $identifier = 'tab' ) {
437
+
438
+ if( !isset( $_GET[ $identifier ] ) ) {
439
+ $cur_page = '';
440
+ } else {
441
+ $cur_page = $_GET[ $identifier ];
442
+ }
443
+
444
+ if( $page == $cur_page ) {
445
+ echo 'current';
446
+ }
447
+
448
+ }
449
+
450
+ // List of plugins that should not be updated
451
+ function donotupdatelist( $filter = 'plugins' ) {
452
+
453
+ // Select correct database row
454
+ switch ( $filter ) {
455
+ case 'themes':
456
+ $db_table = 'notUpdateListTh';
457
+ break;
458
+ case 'plugins':
459
+ $db_table = 'notUpdateList';
460
+ break;
461
+ default:
462
+ $db_table = 'notUpdateList';
463
+ break;
464
+ }
465
+
466
+ // Create list
467
+ global $wpdb;
468
+ $table_name = $wpdb->prefix."auto_updates";
469
+ $config = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = '{$db_table}'");
470
+
471
+ $list = $config[0]->onoroff;
472
+ $list = explode( ", ", $list );
473
+ $returnList = array();
474
+
475
+ foreach ( $list as $key ) array_push( $returnList, $key );
476
+
477
+ return $returnList;
478
+
479
+ }
480
+ function plugins_donotupdatelist() {
481
+
482
+ // Base array
483
+ $array = array();
484
+
485
+ // Filtered plugins
486
+ $filteredplugins = donotupdatelist( 'plugins' );
487
+ foreach ( $filteredplugins as $filteredplugin ) array_push( $array, $filteredplugin );
488
+
489
+ // Plugin added to the delay list
490
+ $delayedplugins = cau_delayed_updates__formated();
491
+ foreach ( $delayedplugins as $delayedplugin ) array_push( $array, $delayedplugin );
492
+
493
+ // Return array
494
+ return $array;
495
+ }
496
+ function themes_donotupdatelist() {
497
+ return donotupdatelist( 'themes' );
498
+ }
499
+
500
+ // Show the update log
501
+ function cau_fetch_log( $limit, $format = 'simple' ) {
502
+
503
+ // Database
504
+ global $wpdb;
505
+ $updateLog = "update_log";
506
+ $updateLogDB = $wpdb->prefix.$updateLog;
507
+
508
+ // Filter log
509
+ if( isset( $_GET['filter'] ) ) {
510
+ $filter = $_GET['filter'];
511
+ } else {
512
+ $filter = 'all';
513
+ }
514
+
515
+ switch( $filter ) {
516
+
517
+ case 'plugins':
518
+ $plugins = true;
519
+ $themes = false;
520
+ $core = false;
521
+ $translations = false;
522
+ break;
523
+
524
+ case 'themes':
525
+ $plugins = false;
526
+ $themes = true;
527
+ $core = false;
528
+ $translations = false;
529
+ break;
530
+
531
+ case 'translations':
532
+ $plugins = false;
533
+ $themes = false;
534
+ $core = false;
535
+ $translations = true;
536
+ break;
537
+
538
+ default:
539
+ $plugins = true;
540
+ $themes = true;
541
+ $core = true;
542
+ $translations = false;
543
+ break;
544
+ }
545
+
546
+ // Create arrays
547
+ $pluginNames = array();
548
+ $pluginVersion = array();
549
+ $pluginDates = array();
550
+ $pluginDatesF = array();
551
+ $plugslug = array();
552
+ $type = array();
553
+ $method = array();
554
+
555
+ // Date format
556
+ $dateFormat = get_option( 'date_format' );
557
+
558
+ // PLUGINS
559
+ if( $plugins ) {
560
+
561
+ // Check if function exists
562
+ if ( ! function_exists( 'get_plugins' ) ) {
563
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
564
+ }
565
+
566
+ // Where to look for plugins
567
+ $plugdir = plugin_dir_path( __DIR__ );
568
+ $allPlugins = get_plugins();
569
+
570
+ // Loop trough all plugins
571
+ foreach ( $allPlugins as $key => $value) {
572
+
573
+ // Get plugin data
574
+ $fullPath = $plugdir.'/'.$key;
575
+ $getFile = $path_parts = pathinfo( $fullPath );
576
+ $pluginData = get_plugin_data( $fullPath );
577
+ $pluginSlug = explode( "/", plugin_basename( $key ) );
578
+ $pluginSlug = $pluginSlug[0];
579
+
580
+ array_push( $plugslug , $pluginSlug );
581
+
582
+ // Automatic or Manual (non-db-version)
583
+ $date_tod = date ( 'ydm' );
584
+ $fileDay = date ( 'ydm', filemtime( $fullPath ) );
585
+ $fileTime = date ( 'Hi', filemtime( $fullPath ) );
586
+ $updateSched = wp_next_scheduled( 'wp_update_plugins' );
587
+ $range_start = date( 'Hi', strtotime( '-30 minutes', $updateSched ) );
588
+ $range_end = date( 'Hi', strtotime( '+30 minutes', $updateSched ) );
589
+
590
+ if( $date_tod == $fileDay ) {
591
+
592
+ if( $fileTime > $range_start && $fileTime < $range_end ) {
593
+ $status = __( 'Automatic', 'companion-auto-update' );
594
+ } else {
595
+ $status = __( 'Manual', 'companion-auto-update' );
596
+ }
597
+
598
+ array_push( $method , $status );
599
+
600
+ } else {
601
+
602
+ // Get info from database
603
+ if( cau_check_if_exists( $key, 'slug', $updateLog ) ) {
604
+ array_push( $method , cau_get_plugininfo( $key, 'method' ) );
605
+ } else {
606
+ array_push( $method , '-' );
607
+ }
608
+
609
+ }
610
+
611
+ // Get plugin name
612
+ foreach ( $pluginData as $dataKey => $dataValue ) {
613
+ if( $dataKey == 'Name') {
614
+ array_push( $pluginNames , $dataValue );
615
+ }
616
+ if( $dataKey == 'Version') {
617
+ array_push( $pluginVersion , $dataValue );
618
+ }
619
+ }
620
+
621
+ // Get last update date
622
+ $fileDate = date ( 'YmdHi', filemtime( $fullPath ) );
623
+ if( $format == 'table' ) {
624
+ $fileDateF = date_i18n( $dateFormat, filemtime( $fullPath ) );
625
+ $fileDateF .= ' &dash; '.date( 'H:i', filemtime( $fullPath ) );
626
+ } else {
627
+ $fileDateF = date_i18n( $dateFormat, filemtime( $fullPath ) );
628
+ }
629
+ array_push( $pluginDates, $fileDate );
630
+ array_push( $pluginDatesF, $fileDateF );
631
+ array_push( $type, 'Plugin' );
632
+
633
+ }
634
+
635
+ }
636
+
637
+ // THEMES
638
+ if( $themes ) {
639
+
640
+ // Where to look for themes
641
+ $themedir = get_theme_root();
642
+ $allThemes = wp_get_themes();
643
+
644
+ // Loop trough all themes
645
+ foreach ( $allThemes as $key => $value) {
646
+
647
+ // Get theme data
648
+ $fullPath = $themedir.'/'.$key;
649
+ $getFile = $path_parts = pathinfo( $fullPath );
650
+
651
+ // Get theme name
652
+ $theme_data = wp_get_theme( $path_parts['filename'] );
653
+ $themeName = $theme_data->get( 'Name' );
654
+ $themeVersion = $theme_data->get( 'Version' );
655
+ array_push( $pluginNames , $themeName );
656
+ array_push( $pluginVersion , $themeVersion );
657
+
658
+ // Automatic or Manual (non-db-version)
659
+ $date_tod = date ( 'ydm' );
660
+ $fileDay = date ( 'ydm', filemtime( $fullPath ) );
661
+ $fileTime = date ( 'Hi', filemtime( $fullPath ) );
662
+ $updateSched = wp_next_scheduled( 'wp_update_themes' );
663
+ $range_start = date( 'Hi', strtotime( '-30 minutes', $updateSched ) );
664
+ $range_end = date( 'Hi', strtotime( '+30 minutes', $updateSched ) );
665
+
666
+ if( $date_tod == $fileDay ) {
667
+
668
+ if( $fileTime > $range_start && $fileTime < $range_end ) {
669
+ $status = __( 'Automatic', 'companion-auto-update' );
670
+ } else {
671
+ $status = __( 'Manual', 'companion-auto-update' );
672
+ }
673
+
674
+ array_push( $method , $status );
675
+
676
+ } else {
677
+
678
+ // Get info from database
679
+ if( cau_check_if_exists( $key, 'slug', $updateLog ) ) {
680
+ array_push( $method , cau_get_plugininfo( $key, 'method' ) );
681
+ } else {
682
+ array_push( $method , '-' );
683
+ }
684
+
685
+ }
686
+
687
+ // Get last update date
688
+ $fileDate = date( 'YmdHi', filemtime( $fullPath ) );
689
+
690
+ if( $format == 'table' ) {
691
+ $fileDateF = date_i18n( $dateFormat, filemtime( $fullPath ) );
692
+ $fileDateF .= ' &dash; '.date ( 'H:i', filemtime( $fullPath ) );
693
+ } else {
694
+ $fileDateF = date_i18n( $dateFormat, filemtime( $fullPath ) );
695
+ }
696
+
697
+ array_push( $pluginDates, $fileDate );
698
+ array_push( $pluginDatesF, $fileDateF );
699
+ array_push( $type, 'Theme' );
700
+ array_push( $plugslug , '' );
701
+
702
+ }
703
+
704
+ }
705
+
706
+ // TRANSLATIONS
707
+ if( $translations ) {
708
+
709
+ // There is no way (at this time) to check if someone changed this link, so therefore it won't work when it's changed, sorry
710
+ $transFolder = get_home_path().'wp-content/languages';
711
+ if( file_exists( $transFolder ) ) {
712
+
713
+ $allThemTranslations = array();
714
+ $allThemTypes = array();
715
+
716
+ $pt = __( 'Plugin translations', 'companion-auto-update' );
717
+ $tt = __( 'Theme translations', 'companion-auto-update' );
718
+ $ct = __( 'Core translations', 'companion-auto-update' );
719
+
720
+ // Plugin translations
721
+ $files = glob( $transFolder.'/plugins/*.{mo}', GLOB_BRACE );
722
+ foreach( $files as $file ) {
723
+ array_push( $allThemTranslations, $file );
724
+ array_push( $allThemTypes, $pt );
725
+ }
726
+
727
+ // Theme translations
728
+ $files = glob( $transFolder.'/themes/*.{mo}', GLOB_BRACE );
729
+ foreach( $files as $file ) {
730
+ array_push( $allThemTranslations, $file );
731
+ array_push( $allThemTypes, $tt );
732
+ }
733
+
734
+ // Core translations
735
+ $files = glob( $transFolder.'/*.{mo}', GLOB_BRACE );
736
+ foreach( $files as $file ) {
737
+ array_push( $allThemTranslations, $file );
738
+ array_push( $allThemTypes, $ct );
739
+ }
740
+
741
+ foreach( $allThemTranslations as $key => $trans_file ) {
742
+
743
+ $transDate = date( 'YmdHi', filemtime( $trans_file ) );
744
+
745
+ if( $format == 'table' ) {
746
+ $transDateF = date_i18n( $dateFormat, filemtime( $trans_file ) );
747
+ $transDateF .= ' &dash; '.date ( 'H:i', filemtime( $trans_file ) );
748
+ } else {
749
+ $transDateF = date_i18n( $dateFormat, filemtime( $trans_file ) );
750
+ }
751
+
752
+ $trans_name = basename( $trans_file );
753
+ $trans_name = str_replace( "-", " ", $trans_name );
754
+ $trans_name = str_replace( ".mo", "", $trans_name );
755
+ $trans_name = str_replace( ".json", "", $trans_name );
756
+ $trans_lang = substr( $trans_name, strrpos( $trans_name, " " ) + 1 );
757
+ $trans_name = str_replace( $trans_lang, "", $trans_name );
758
+ $trans_lang = substr( $trans_lang, strrpos( $trans_lang, "_" ) + 1 );
759
+
760
+ // Push
761
+ array_push( $pluginNames, ucfirst( $trans_name ).': '.$trans_lang );
762
+ array_push( $type, $allThemTypes[$key] );
763
+ array_push( $pluginVersion, '-' );
764
+ array_push( $pluginDates, $transDate );
765
+ array_push( $pluginDatesF, $transDateF );
766
+ array_push( $plugslug , '' );
767
+ array_push( $method , '-' );
768
+
769
+ }
770
+
771
+ } else {
772
+
773
+ $transDate = date('YmdHi');
774
+ $transDateF = 'Could not read translations date.';
775
+
776
+ array_push( $pluginNames, 'Translations' );
777
+ array_push( $type, $trans_type.' translations' );
778
+ array_push( $pluginVersion, '-' );
779
+ array_push( $pluginDates, $transDate );
780
+ array_push( $pluginDatesF, $transDateF );
781
+ array_push( $plugslug , '' );
782
+
783
+ // Get info from database
784
+ array_push( $method , '-' );
785
+
786
+ }
787
+
788
+ }
789
+
790
+ // CORE
791
+ if( $core ) {
792
+
793
+ $coreFile = ABSPATH.'wp-includes/version.php';
794
+ $updateSched = wp_next_scheduled( 'wp_version_check' );
795
+
796
+ if( file_exists( $coreFile ) ) {
797
+
798
+ $coreDate = date( 'YmdHi', filemtime( $coreFile ) );
799
+
800
+ if( $format == 'table' ) {
801
+ $coreDateF = date_i18n( $dateFormat, filemtime( $coreFile ) );
802
+ $coreDateF .= ' &dash; '.date ( 'H:i', filemtime( $coreFile ) );
803
+ } else {
804
+ $coreDateF = date_i18n( $dateFormat, filemtime( $coreFile ) );
805
+ }
806
+
807
+ // Automatic or Manual (non-db-version)
808
+ $date_tod = date ( 'ydm' );
809
+ $fileDay = date ( 'ydm', filemtime( $coreFile ) );
810
+ $fileTime = date ( 'Hi', filemtime( $coreFile ) );
811
+ $update_time = wp_next_scheduled( 'wp_version_check' );
812
+ $range_start = date( 'Hi', strtotime( '-30 minutes', $update_time ) );
813
+ $range_end = date( 'Hi', strtotime( '+30 minutes', $update_time ) );
814
+
815
+ if( $date_tod == $fileDay ) {
816
+
817
+ if( $fileTime > $range_start && $fileTime < $range_end ) {
818
+ $methodVal = __( 'Automatic', 'companion-auto-update' );
819
+ } else {
820
+ $methodVal = __( 'Manual', 'companion-auto-update' );
821
+ }
822
+
823
+ } else {
824
+
825
+ // Get info from database
826
+ if( cau_check_if_exists( $key, 'slug', $updateLog ) ) {
827
+ $methodVal = cau_get_plugininfo( 'core', 'method' );
828
+ } else {
829
+ $methodVal = '';
830
+ }
831
+
832
+ }
833
+
834
+
835
+ } else {
836
+ $coreDate = date('YmdHi');
837
+ $coreDateF = 'Could not read core date.';
838
+ }
839
+
840
+ array_push( $pluginNames, 'WordPress' );
841
+ array_push( $type, 'WordPress' );
842
+ array_push( $pluginVersion, get_bloginfo( 'version' ) );
843
+ array_push( $pluginDates, $coreDate );
844
+ array_push( $pluginDatesF, $coreDateF );
845
+ array_push( $plugslug , '' );
846
+
847
+ // Get info from database
848
+ array_push( $method , $methodVal );
849
+
850
+ }
851
+
852
+ // Sort array by date
853
+ arsort( $pluginDates );
854
+
855
+ if( $limit == 'all' ) {
856
+ $limit = 999;
857
+ }
858
+
859
+ $listClasses = 'wp-list-table widefat autoupdate autoupdatelog';
860
+
861
+ if( $format == 'table' ) {
862
+ $listClasses .= ' autoupdatelog striped';
863
+ } else {
864
+ $listClasses .= ' autoupdatewidget';
865
+ }
866
+
867
+ echo '<table class="'.$listClasses.'">';
868
+
869
+ // Show the last updated plugins
870
+ if( $format == 'table' ) {
871
+
872
+ echo '<thead>
873
+ <tr>
874
+ <th><strong>'.__( 'Name', 'companion-auto-update' ).'</strong></th>';
875
+ if( !$translations ) echo '<th><strong>'.__( 'To version', 'companion-auto-update' ).'</strong></th>';
876
+ echo '<th><strong>'.__( 'Type', 'companion-auto-update' ).'</strong></th>
877
+ <th><strong>'.__( 'Last updated on', 'companion-auto-update' ).'</strong></th>
878
+ <th><strong>'.__( 'Update method', 'companion-auto-update' ).'</strong></th>
879
+ </tr>
880
+ </thead>';
881
+
882
+ }
883
+
884
+ echo '<tbody id="the-list">';
885
+
886
+ $loopings = 0;
887
+
888
+ foreach ( $pluginDates as $key => $value ) {
889
+
890
+ if( $loopings < $limit ) {
891
+
892
+ echo '<tr>';
893
+
894
+ if( $format == 'table' ) {
895
+ $pluginName = $pluginNames[$key];
896
+ } else {
897
+ $pluginName = substr( $pluginNames[$key], 0, 25);
898
+ if( strlen( $pluginNames[$key] ) > 25 ) {
899
+ $pluginName .= '...';
900
+ }
901
+ }
902
+
903
+ echo '<td class="column-updatetitle"><p><strong title="'. $pluginNames[$key] .'">'.cau_getChangelogUrl( $type[$key], $pluginNames[$key], $plugslug[$key] ).'</strong></p></td>';
904
+
905
+ if( $format == 'table' ) {
906
+
907
+ if( $type[$key] == 'Plugin' ) {
908
+ $thisType = __( 'Plugin', 'companion-auto-update' );
909
+ } else if( $type[$key] == 'Theme' ) {
910
+ $thisType = __( 'Theme', 'companion-auto-update' );
911
+ } else {
912
+ $thisType = $type[$key];
913
+ }
914
+
915
+ if( !$translations ) echo '<td class="cau_hide_on_mobile column-version" style="min-width: 100px;"><p>'. $pluginVersion[$key] .'</p></td>';
916
+ echo '<td class="cau_hide_on_mobile column-description"><p>'. $thisType .'</p></td>';
917
+
918
+ }
919
+
920
+ echo '<td class="column-date" style="min-width: 100px;"><p>'. $pluginDatesF[$key] .'</p></td>';
921
+
922
+ if( $format == 'table' ) {
923
+ echo '<td class="column-method"><p>'. $method[$key] .'</p></td>';
924
+ }
925
+
926
+ echo '</tr>';
927
+
928
+ $loopings++;
929
+
930
+ }
931
+
932
+ }
933
+
934
+ echo "</tbody></table>";
935
+
936
+ }
937
+
938
+ // Get the proper changelog URL
939
+ function cau_getChangelogUrl( $type, $name, $plugslug ) {
940
+
941
+ switch( $type ) {
942
+ case 'WordPress':
943
+ $url = '';
944
+ break;
945
+ case 'Plugin':
946
+ $url = admin_url( 'plugin-install.php?tab=plugin-information&plugin='.$plugslug.'&section=changelog&TB_iframe=true&width=772&height=772' );
947
+ break;
948
+ case 'Theme':
949
+ $url = '';
950
+ break;
951
+ }
952
+
953
+ if( !empty( $url ) ) {
954
+ return '<a href="'.$url.'" class="thickbox open-plugin-details-modal" aria-label="More information about '.$name.'" data-title="'.$name.'">'.$name.'</a>';
955
+ } else {
956
+ return $name;
957
+ }
958
+
959
+ }
960
+
961
+ // Only update plugins which are enabled
962
+ function cau_dontUpdatePlugins( $update, $item ) {
963
+
964
+ $plugins = plugins_donotupdatelist();
965
+
966
+ if ( in_array( $item->slug, $plugins ) ) {
967
+ return false; // Don't update these plugins
968
+ } else {
969
+ return true; // Always update these plugins
970
+ }
971
+
972
+
973
+ }
974
+ function cau_dontUpdateThemes( $update, $item ) {
975
+
976
+ $themes = themes_donotupdatelist();
977
+
978
+ if ( in_array( $item->slug, $themes ) ) {
979
+ return false; // Don't update these themes
980
+ } else {
981
+ return true; // Always update these themes
982
+ }
983
+
984
+
985
+ }
986
+
987
+ // Get plugin information of repository
988
+ function cau_plugin_info( $slug, $what ) {
989
+
990
+ $slug = sanitize_title( $slug );
991
+ $cau_transient_name = 'cau' . $slug;
992
+ $cau_info = get_transient( $cau_transient_name );
993
+
994
+ if( !function_exists( 'plugins_api' ) ) require_once( ABSPATH.'wp-admin/includes/plugin-install.php' );
995
+ $cau_info = plugins_api( 'plugin_information', array( 'slug' => $slug ) );
996
+
997
+ if ( ! $cau_info or is_wp_error( $cau_info ) ) {
998
+ return false;
999
+ }
1000
+
1001
+ set_transient( $cau_transient_name, $cau_info, 3600 );
1002
+
1003
+ switch ( $what ) {
1004
+ case 'versions':
1005
+ return $cau_info->versions;
1006
+ break;
1007
+ case 'version':
1008
+ return $cau_info->version;
1009
+ break;
1010
+ case 'name':
1011
+ return $cau_info->name;
1012
+ break;
1013
+ case 'slug':
1014
+ return $cau_info->slug;
1015
+ break;
1016
+ }
1017
+
1018
+ }
1019
+
1020
+ // Get list of outdated plugins
1021
+ function cau_list_outdated() {
1022
+
1023
+ $outdatedList = array();
1024
+
1025
+ // Check if function exists
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
+
1032
+ $slug = $key;
1033
+ $explosion = explode( '/', $slug );
1034
+ $actualSlug = array_shift( $explosion );
1035
+
1036
+ // Get plugin name
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
+ }
1054
+
1055
+ return $outdatedList;
1056
+
1057
+ }
1058
+
1059
+ // Better version compare
1060
+ function cau_version_compare( $ver1, $ver2, $operator = null ) {
1061
+ $p = '#(\.0+)+($|-)#';
1062
+ $ver1 = preg_replace( $p, '', $ver1 );
1063
+ $ver2 = preg_replace( $p, '', $ver2 );
1064
+ return isset( $operator ) ? version_compare( $ver1, $ver2, $operator ) : version_compare( $ver1, $ver2 );
1065
+ }
1066
+
1067
+ // Get plugin information of currently installed plugins
1068
+ function cau_active_plugin_info( $slug, $what ) {
1069
+
1070
+ // Check if function exists
1071
+ if ( ! function_exists( 'get_plugins' ) ) {
1072
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
1073
+ }
1074
+
1075
+ $allPlugins = get_plugins();
1076
+
1077
+ foreach ($allPlugins as $key => $value) {
1078
+ $thisSlug = explode('/', $key);
1079
+ $thisSlugE = $thisSlug[0];
1080
+ if( $thisSlug == $slug ) {
1081
+
1082
+ if( $what == 'version' ) return $value['Version'];
1083
+
1084
+ }
1085
+ }
1086
+
1087
+ }
1088
+
1089
+ // Remove update nag when major updates are disabled
1090
+ function cau_hideUpdateNag() {
1091
+ if( cau_get_db_value( 'major' ) != 'on' ) {
1092
+ remove_action( 'admin_notices', 'update_nag', 3 );
1093
+ remove_action( 'network_admin_notices', 'maintenance_nag', 10 );
1094
+ }
1095
+ }
1096
+ add_action( 'admin_head', 'cau_hideUpdateNag', 100 );
1097
+
1098
+ // Add more intervals to event schedules
1099
+ function cau_addMoreIntervals( $schedules ) {
1100
+
1101
+ // Add a weekly interval.
1102
+ $schedules['weekly'] = array(
1103
+ 'interval' => 604800,
1104
+ 'display' => __( 'Every week', 'companion-auto-update' ),
1105
+ );
1106
+
1107
+ // Add a twice montly interval.
1108
+ $schedules['twice_monthly'] = array(
1109
+ 'interval' => 1209600,
1110
+ 'display' => __( 'Every 2 weeks', 'companion-auto-update' ),
1111
+ );
1112
+
1113
+ // Add a montly interval.
1114
+ $schedules['once_monthly'] = array(
1115
+ 'interval' => 2419200,
1116
+ 'display' => __( 'Every 4 weeks', 'companion-auto-update' ),
1117
+ );
1118
+
1119
+ return $schedules;
1120
+
1121
+ }
1122
+ add_filter( 'cron_schedules', 'cau_addMoreIntervals' );
1123
+
1124
+ // Get only unique schedules
1125
+ function cau_wp_get_schedules() {
1126
+
1127
+ // Start variables
1128
+ $availableIntervals = wp_get_schedules();
1129
+ $array_unique = array();
1130
+ $intervalTimes = array();
1131
+ $intervalNames = array();
1132
+ $intervalUniques = array();
1133
+ $counter = 0;
1134
+
1135
+ // Get all intervals
1136
+ foreach ( $availableIntervals as $key => $value ) {
1137
+
1138
+ // Do a bunch of checks to format them the right way
1139
+ foreach ( $value as $display => $interval ) {
1140
+
1141
+ if( $display == 'interval' ) {
1142
+
1143
+ if( $interval == '86400' ) $key = 'daily'; // Force the daily interval to be called daily, required by a bunch of handles of this plugin
1144
+
1145
+ $intervalTimes[$counter] = $key; // Add the backend name (i.e. "once_monthly" or "daily")
1146
+ $intervalUniques[$counter] = $interval; // Add the unix timestamp of this interval, used to identify unique items
1147
+
1148
+ // Format display name in a proper way
1149
+ $numOfMinutes = ($interval/60);
1150
+ $identifier = __( 'minutes', 'companion-auto-update' );
1151
+
1152
+ // I just know there's an easier way for this, but I can't come up with it and this works so...
1153
+ if( $interval >= (60*60) ) {
1154
+ $numOfMinutes = ($numOfMinutes/60);
1155
+ $identifier = __( 'hours', 'companion-auto-update' );
1156
+ }
1157
+ if( $interval >= (60*60*24) ) {
1158
+ $numOfMinutes = ($numOfMinutes/24);
1159
+ $identifier = __( 'days', 'companion-auto-update' );
1160
+ }
1161
+ if( $interval >= (60*60*24*7) ) {
1162
+ $numOfMinutes = ($numOfMinutes/7);
1163
+ $identifier = __( 'weeks', 'companion-auto-update' );
1164
+ }
1165
+ if( $interval >= (60*60*24*7*(52/12)) ) {
1166
+ $numOfMinutes = ($numOfMinutes/(52/12));
1167
+ $identifier = __( 'months', 'companion-auto-update' );
1168
+ }
1169
+
1170
+ $display = sprintf( esc_html__( 'Every %s %s', 'companion-auto-update' ), round( $numOfMinutes, 2 ), $identifier ); // Translateble
1171
+ $intervalNames[$counter] = $display; // Add the display name (i.e. "Once a month" or "Once Daily")
1172
+
1173
+ $counter++; // Make sure the next interval gets a new "key" value
1174
+ }
1175
+
1176
+ }
1177
+
1178
+ }
1179
+
1180
+ // Sort the interval from smallest to largest
1181
+ asort( $intervalUniques );
1182
+
1183
+ // Prevent duplicates
1184
+ foreach ( array_unique( $intervalUniques ) as $key => $value ) {
1185
+ // $value is the timestamp
1186
+ // $intervalTimes[$key] is the backend name
1187
+ // $intervalNames[$key] is the display name
1188
+ $array_unique[$intervalTimes[$key]] = $intervalNames[$key];
1189
+ }
1190
+
1191
+ // Return the array
1192
+ return $array_unique;
1193
+
1194
+ }
1195
+
1196
+ // Check if the update log db is empty
1197
+ function cau_updateLogDBisEmpty() {
1198
+
1199
+ global $wpdb;
1200
+ $updateDB = "update_log";
1201
+ $updateLog = $wpdb->prefix.$updateDB;
1202
+ $row_count = $wpdb->get_var( "SELECT COUNT(*) FROM $updateLog" );
1203
+
1204
+ if( $row_count > 0 ) {
1205
+ return false;
1206
+ } else {
1207
+ return true;
1208
+ }
1209
+ }
1210
+
1211
+ // Plugin information to DB
1212
+ function cau_savePluginInformation( $method = 'New' ) {
1213
+
1214
+ // Check if function exists
1215
+ if ( ! function_exists( 'get_plugins' ) ) {
1216
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
1217
+ }
1218
+
1219
+ // Set variables
1220
+ global $wpdb;
1221
+ $updateDB = "update_log";
1222
+ $updateLog = $wpdb->prefix.$updateDB;
1223
+ $allPlugins = get_plugins();
1224
+ $allThemes = wp_get_themes();
1225
+
1226
+ // Loop trough all themes
1227
+ foreach ( $allThemes as $key => $value ) {
1228
+ if( !cau_check_if_exists( $key, 'slug', $updateDB ) ) $wpdb->insert( $updateLog, array( 'slug' => $key, 'oldVersion' => '-', 'method' => $method ) );
1229
+ }
1230
+
1231
+ // Loop trough all plugins
1232
+ foreach ( $allPlugins as $key => $value ) {
1233
+ if( !cau_check_if_exists( $key, 'slug', $updateDB ) ) $wpdb->insert( $updateLog, array( 'slug' => $key, 'oldVersion' => '-', 'method' => $method ) );
1234
+ }
1235
+
1236
+ // Core
1237
+ if( !cau_check_if_exists( 'core', 'slug', $updateDB ) ) $wpdb->insert( $updateLog, array( 'slug' => 'core', 'oldVersion' => '-', 'method' => $method ) );
1238
+
1239
+ }
1240
+
1241
+ function cau_updatePluginInformation( $slug, $method = '-', $newVersion = '-' ) {
1242
+
1243
+ global $wpdb;
1244
+ $updateDB = "update_log";
1245
+ $updateLog = $wpdb->prefix.$updateDB;
1246
+ $wpdb->query( $wpdb->prepare( "UPDATE $updateLog SET newVersion = '%s', method = %s WHERE slug = '%s'", $newVersion, $method, $slug ) );
1247
+
1248
+ }
1249
+
1250
+ function cau_siteHealthSignature() {
1251
+ return '<p style="font-size: 12px; color: #707070;">'.__( 'This was reported by the Companion Auto Update plugin', 'companion-auto-update' ).'</p>';
1252
+ }
1253
+
1254
+ function cau_add_siteHealthTest( $tests ) {
1255
+ $tests['direct']['cau_disabled'] = array( 'label' => __( 'Companion Auto Update', 'companion-auto-update' ), 'test' => 'cau_disabled_test' );
1256
+ return $tests;
1257
+ }
1258
+ add_filter( 'site_status_tests', 'cau_add_siteHealthTest' );
1259
+
1260
+ function cau_disabled_test() {
1261
+
1262
+ $result = array(
1263
+ 'label' => __( 'Auto updating is enabled', 'companion-auto-update' ),
1264
+ 'status' => 'good',
1265
+ 'badge' => array(
1266
+ 'label' => __( 'Security' ),
1267
+ 'color' => 'blue',
1268
+ ),
1269
+ 'description' => sprintf( '<p>%s</p>', __( "Automatic updating isn't disabled on this site.", 'companion-auto-update' ) ),
1270
+ 'actions' => '',
1271
+ 'test' => 'cau_disabled',
1272
+ );
1273
+
1274
+ if ( checkAutomaticUpdaterDisabled() OR !has_filter( 'wp_version_check', 'wp_version_check' ) ) {
1275
+ $result['status'] = 'critical';
1276
+ $result['label'] = __( 'Auto updating is disabled', 'companion-auto-update' );
1277
+ $result['description'] = __( 'Automatic updating is disabled on this site by either WordPress, another plugin or your webhost.', 'companion-auto-update' );
1278
+ $result['description'] .= ' '.__( 'For more information about this error check the status page.', 'companion-auto-update' );
1279
+ $result['actions'] .= sprintf( '<p><a href="%s">%s</a>', esc_url( cau_url( 'status' ) ), __( 'Check the status page', 'companion-auto-update' ) );
1280
+ }
1281
+
1282
+ $result['actions'] .= cau_siteHealthSignature();
1283
+
1284
+ return $result;
1285
+ }
1286
+
1287
+ // Check for version control
1288
+ function cau_test_is_vcs_checkout( $context ) {
1289
+
1290
+ $context_dirs = array( ABSPATH );
1291
+ $vcs_dirs = array( '.svn', '.git', '.hg', '.bzr' );
1292
+ $check_dirs = array();
1293
+ $result = array();
1294
+
1295
+ foreach ( $context_dirs as $context_dir ) {
1296
+ // Walk up from $context_dir to the root.
1297
+ do {
1298
+ $check_dirs[] = $context_dir;
1299
+
1300
+ // Once we've hit '/' or 'C:\', we need to stop. dirname will keep returning the input here.
1301
+ if ( $context_dir == dirname( $context_dir ) )
1302
+ break;
1303
+
1304
+ // Continue one level at a time.
1305
+ } while ( $context_dir = dirname( $context_dir ) );
1306
+ }
1307
+
1308
+ $check_dirs = array_unique( $check_dirs );
1309
+
1310
+ // Search all directories we've found for evidence of version control.
1311
+ foreach ( $vcs_dirs as $vcs_dir ) {
1312
+ foreach ( $check_dirs as $check_dir ) {
1313
+ if ( $checkout = @is_dir( rtrim( $check_dir, '\\/' ) . "/$vcs_dir" ) ) {
1314
+ break 2;
1315
+ }
1316
+ }
1317
+ }
1318
+
1319
+ if ( $checkout && ! apply_filters( 'automatic_updates_is_vcs_checkout', true, $context ) ) {
1320
+ $result['description'] = sprintf( __( 'The folder %s was detected as being under version control (%s), but the %s filter is allowing updates' , 'companion-auto-update' ), "<code>$check_dir</code>", "<code>automatic_updates_is_vcs_checkout</code>" );
1321
+ $result['icon'] = 'warning';
1322
+ $result['status'] = 'info';
1323
+ } else if ( $checkout ) {
1324
+ $result['description'] = sprintf( __( 'The folder %s was detected as being under version control (%s)' , 'companion-auto-update' ), "<code>$check_dir</code>", "<code>$vcs_dir</code>" );
1325
+ $result['icon'] = 'no';
1326
+ $result['status'] = 'disabled';
1327
+ } else {
1328
+ $result['description'] = __( 'No issues detected' , 'companion-auto-update' );
1329
+ $result['icon'] = 'yes-alt';
1330
+ $result['status'] = 'enabled';
1331
+ }
1332
+
1333
+ return $result;
1334
+ }
1335
+
1336
+ // Check if plugins need to be delayed
1337
+ function cau_check_delayed() {
1338
+ if( cau_get_db_value( 'update_delay' ) == 'on' ) {
1339
+ cau_hold_updates();
1340
+ cau_unhold_updates();
1341
+ } else {
1342
+ cau_unhold_all_updates();
1343
+ }
1344
+ }
1345
+
1346
+ // List of all delayed plugins
1347
+ function cau_delayed_updates() {
1348
+
1349
+ global $wpdb;
1350
+ $plugin_list = array();
1351
+ $updateLog = $wpdb->prefix."update_log";
1352
+ $put_on_hold = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$updateLog} WHERE put_on_hold <> '%s'", '0' ) );
1353
+ foreach ( $put_on_hold as $plugin ) {
1354
+ array_push( $plugin_list, $plugin->slug );
1355
+ }
1356
+ return $plugin_list;
1357
+
1358
+ }
1359
+
1360
+ // List of all delayed plugins for the update function
1361
+ function cau_delayed_updates__formated() {
1362
+
1363
+ $plugin_list = array();
1364
+ foreach ( cau_delayed_updates() as $plugin ) {
1365
+ $explosion = explode( '/', $plugin );
1366
+ $short_slug = array_shift( $explosion );
1367
+ array_push( $plugin_list, $short_slug );
1368
+ }
1369
+ return $plugin_list;
1370
+
1371
+ }
1372
+
1373
+ // Add "put on hold" timestamp to the database if it hasn't been set yet
1374
+ function cau_hold_updates() {
1375
+
1376
+ require_once( ABSPATH.'wp-admin/includes/plugin-install.php' );
1377
+ $plugins = get_plugin_updates();
1378
+
1379
+ if ( !empty( $plugins ) ) {
1380
+ $list = array();
1381
+ foreach ( (array)$plugins as $plugin_file => $plugin_data ) {
1382
+ if( !in_array( $plugin_file, cau_delayed_updates() ) ) {
1383
+ global $wpdb;
1384
+ $updateDB = "update_log";
1385
+ $updateLog = $wpdb->prefix.$updateDB;
1386
+ $wpdb->query( $wpdb->prepare( "UPDATE $updateLog SET put_on_hold = '%s' WHERE slug = '%s'", strtotime( "now" ), $plugin_file ) );
1387
+ }
1388
+ }
1389
+ }
1390
+ }
1391
+
1392
+ // Remove plugins from "put on hold" after x days
1393
+ function cau_unhold_updates() {
1394
+
1395
+ if( cau_get_db_value( 'update_delay_days' ) != '' ) {
1396
+ $after_x_days = cau_get_db_value( 'update_delay_days' );
1397
+ } else {
1398
+ $after_x_days = '2';
1399
+ }
1400
+
1401
+ global $wpdb;
1402
+
1403
+ $today = strtotime( "now" );
1404
+ $updateLog = $wpdb->prefix."update_log";
1405
+ $put_on_hold = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$updateLog} WHERE put_on_hold <> '%s'", '0' ) );
1406
+
1407
+ foreach ( $put_on_hold as $plugin ) {
1408
+
1409
+ $plugin_file = $plugin->slug;
1410
+ $put_on_hold_date = $plugin->put_on_hold;
1411
+ $remove_after = strtotime( '+'.$after_x_days.' days', $put_on_hold_date );
1412
+
1413
+ if( $remove_after <= $today ) {
1414
+ $wpdb->query( $wpdb->prepare( "UPDATE {$updateLog} SET put_on_hold = '%s' WHERE slug = '%s'", '0', $plugin_file ) );
1415
+ }
1416
+
1417
+ }
1418
+
1419
+ }
1420
+
1421
+ // Remove all plugins from "put on hold" if option is disabled
1422
+ function cau_unhold_all_updates() {
1423
+ global $wpdb;
1424
+ $updateLog = $wpdb->prefix."update_log";
1425
+ $put_on_hold = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$updateLog} WHERE put_on_hold <> '%s'", '0' ) );
1426
+ foreach ( $put_on_hold as $plugin ) {
1427
+ $plugin_file = $plugin->slug;
1428
+ $wpdb->query( $wpdb->prepare( "UPDATE {$updateLog} SET put_on_hold = '%s' WHERE slug = '%s'", '0', $plugin_file ) );
1429
+ }
1430
  }
companion-auto-update.php CHANGED
@@ -1,465 +1,466 @@
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.0
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.7.2';
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
-
172
- // Advanced
173
- if( !cau_check_if_exists( 'allow_administrator' ) ) $wpdb->insert( $table_name, array( 'name' => 'allow_administrator', 'onoroff' => 'on' ) );
174
- if( !cau_check_if_exists( 'allow_editor' ) ) $wpdb->insert( $table_name, array( 'name' => 'allow_editor', 'onoroff' => '' ) );
175
- if( !cau_check_if_exists( 'allow_author' ) ) $wpdb->insert( $table_name, array( 'name' => 'allow_author', 'onoroff' => '' ) );
176
- if( !cau_check_if_exists( 'ignore_seo' ) ) $wpdb->insert( $table_name, array( 'name' => 'ignore_seo', 'onoroff' => '' ) );
177
- if( !cau_check_if_exists( 'ignore_cron' ) ) $wpdb->insert( $table_name, array( 'name' => 'ignore_cron', 'onoroff' => '' ) );
178
- if( !cau_check_if_exists( 'advanced_info_emails' ) ) $wpdb->insert( $table_name, array( 'name' => 'advanced_info_emails', 'onoroff' => '' ) );
179
- if( !cau_check_if_exists( 'update_delay' ) ) $wpdb->insert( $table_name, array( 'name' => 'update_delay', 'onoroff' => '' ) );
180
- if( !cau_check_if_exists( 'update_delay_days' ) ) $wpdb->insert( $table_name, array( 'name' => 'update_delay_days', 'onoroff' => '' ) );
181
-
182
- }
183
- register_activation_hook( __FILE__, 'cau_install' );
184
-
185
- // Clear everything on deactivation
186
- function cau_remove() {
187
-
188
- // Delete tables
189
- global $wpdb;
190
- $autoupdates = $wpdb->prefix."auto_updates";
191
- $updateLog = $wpdb->prefix."update_log";
192
- $wpdb->query( "DROP TABLE IF EXISTS $autoupdates" );
193
- $wpdb->query( "DROP TABLE IF EXISTS $updateLog" );
194
-
195
- // Clear schedules
196
- wp_clear_scheduled_hook( 'cau_set_schedule_mail' );
197
- wp_clear_scheduled_hook( 'cau_custom_hooks_plugins' );
198
- wp_clear_scheduled_hook( 'cau_custom_hooks_themes' );
199
- wp_clear_scheduled_hook( 'cau_log_updater' );
200
-
201
- // Restore WordPress default update functionality
202
- add_filter( 'plugins_auto_update_enabled', '__return_true' );
203
- add_filter( 'themes_auto_update_enabled', '__return_true' );
204
- add_filter( 'auto_plugin_update_send_email', '__return_true' );
205
- add_filter( 'auto_theme_update_send_email', '__return_true' );
206
- }
207
- register_deactivation_hook( __FILE__, 'cau_remove' );
208
-
209
- // Update
210
- function cau_update_db_check() {
211
-
212
- $cau_db_version = cau_db_version();
213
-
214
- if ( get_site_option( 'cau_db_version' ) != $cau_db_version ) {
215
-
216
- cau_database_creation();
217
-
218
- // In 3.7.2 we've added $wpdb->get_charset_collate
219
- if( get_site_option( 'cau_db_version' ) < '3.7.2' ) {
220
-
221
- global $wpdb;
222
- $autoupdates = $wpdb->prefix."auto_updates";
223
- $updateLog = $wpdb->prefix."update_log";
224
- $db_charset = constant( 'DB_CHARSET' );
225
- $wpdb->query( "ALTER TABLE $autoupdates CONVERT TO CHARACTER SET $db_charset" );
226
- $wpdb->query( "ALTER TABLE $updateLog CONVERT TO CHARACTER SET $db_charset" );
227
-
228
- }
229
-
230
- update_option( "cau_db_version", $cau_db_version );
231
- }
232
-
233
- }
234
- add_action( 'upgrader_process_complete', 'cau_update_db_check' );
235
-
236
- // Manual update
237
- function cau_manual_update() {
238
- cau_update_db_check();
239
- }
240
-
241
- // Load custom functions
242
- require_once( plugin_dir_path( __FILE__ ) . 'cau_functions.php' );
243
-
244
- // Add plugin to menu
245
- function register_cau_menu_page() {
246
- 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' );
247
- }
248
- add_action( 'admin_menu', 'register_cau_menu_page' );
249
-
250
- // Settings page
251
- function cau_frontend() { ?>
252
-
253
- <div class='wrap cau_content_wrap cau_content'>
254
-
255
- <h1 class="wp-heading-inline"><?php _e( 'Companion Auto Update', 'companion-auto-update' ); ?></h1>
256
-
257
- <hr class="wp-header-end">
258
-
259
- <?php
260
-
261
- // Make sure the correct timezone is used
262
- date_default_timezone_set( cau_get_proper_timezone() );
263
-
264
- // Allow only access to these pages
265
- $allowedPages = array(
266
- 'dashboard' => __( 'Dashboard' ),
267
- 'pluginlist' => __( 'Update filter', 'companion-auto-update' ),
268
- 'log' => __( 'Update log', 'companion-auto-update' ),
269
- 'status' => __( 'Status', 'companion-auto-update' ),
270
- );
271
-
272
- // Show subtabs
273
- echo "<h2 class='nav-tab-wrapper wp-clearfix'>";
274
- foreach ( $allowedPages as $page => $title ) {
275
- echo "<a href='".cau_url( $page )."' id='tab-".$page."' class='nav-tab "._active_tab( $page )."'>".$title;
276
- if( $page == 'status' ) {
277
- if( cau_pluginHasIssues() ) {
278
- echo "<span class='cau_melding level-".cau_pluginIssueLevels()."'></span>";
279
- } else {
280
- echo "<span class='cau_melding level-okay'></span>";
281
- }
282
- }
283
- echo "</a>";
284
- }
285
- echo "</h2>";
286
-
287
- // Show page content
288
- if( !isset( $_GET['tab'] ) ) {
289
- $requestedPage = 'dashboard';
290
- echo "<script>jQuery('#tab-dashboard').addClass('nav-tab-active');</script>"; // Set active tab class
291
- } else {
292
- $requestedPage = sanitize_key( $_GET['tab'] );
293
- }
294
-
295
- if( array_key_exists( $requestedPage, $allowedPages ) ) {
296
- require_once( plugin_dir_path( __FILE__ ) . 'admin/'.$requestedPage.'.php' );
297
- } else {
298
- wp_die( 'You\'re not allowed to view <strong>'.$requestedPage.'</strong>.' );
299
- }
300
-
301
- ?>
302
-
303
- </div>
304
-
305
- <?php }
306
-
307
- // Add a widget to the dashboard.
308
- function cau_add_widget() {
309
- if ( cau_allowed_user_rights() ) wp_add_dashboard_widget( 'cau-update-log', __('Update log', 'companion-auto-update'), 'cau_widget' );
310
- }
311
- add_action( 'wp_dashboard_setup', 'cau_add_widget' );
312
-
313
- function cau_widget() {
314
-
315
- 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>';
316
- 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>';
317
- cau_fetch_log( '7' );
318
- echo '<p>
319
- <a href="'.cau_url( 'log' ).'">'.__('View full changelog', 'companion-auto-update').'</a>
320
- <span class="cau_divide">|</span>
321
- <a href="'.cau_url( 'dashboard' ).'">'.__( 'Settings' ).'</a>
322
- </p>';
323
-
324
- }
325
-
326
- // Load admin styles
327
- function load_cau_global_styles( $hook ) {
328
-
329
- // Plugin scripts
330
- wp_enqueue_style( 'cau_admin_styles', plugins_url( 'backend/style.css' , __FILE__ ) );
331
-
332
- // Check for issues
333
- wp_enqueue_style( 'cau_warning_styles', plugins_url( 'backend/warningbar.css' , __FILE__ ) );
334
-
335
- }
336
- add_action( 'admin_enqueue_scripts', 'load_cau_global_styles', 99 );
337
-
338
- // Load admin styles
339
- function load_cau_page_styles( $hook ) {
340
-
341
- // Only load on plugins' pages
342
- if( $hook != 'tools_page_cau-settings' && $hook != 'index_page_cau-settings' ) return;
343
-
344
- // WordPress scripts we need
345
- wp_enqueue_style( 'thickbox' );
346
- wp_enqueue_script( 'thickbox' );
347
- wp_enqueue_script( 'plugin-install' );
348
-
349
- }
350
- add_action( 'admin_enqueue_scripts', 'load_cau_page_styles', 100 );
351
-
352
- // Send e-mails
353
- require_once( plugin_dir_path( __FILE__ ) . 'cau_emails.php' );
354
-
355
- // Add settings link on plugin page
356
- function cau_settings_link( $links ) {
357
-
358
- $settings_link = '<a href="'.cau_url( 'dashboard' ).'">'.__( 'Settings' ).'</a>';
359
- $settings_link2 = '<a href="https://translate.wordpress.org/projects/wp-plugins/companion-auto-update">'.__( 'Help us translate', 'companion-auto-update' ).'</a>';
360
- $settings_link3 = '<a href="'.cau_donateUrl().'">'.__( 'Donate to help development', 'companion-auto-update' ).'</a>';
361
-
362
- array_unshift( $links, $settings_link2 );
363
- array_unshift( $links, $settings_link3 );
364
- if( cau_allowed_user_rights() ) array_unshift( $links, $settings_link );
365
-
366
- return $links;
367
-
368
- }
369
- $plugin = plugin_basename(__FILE__);
370
- add_filter( "plugin_action_links_$plugin", "cau_settings_link" );
371
-
372
- // Auto Update Class
373
- class CAU_auto_update {
374
-
375
- public function __construct() {
376
-
377
- // Enable Update filters
378
- add_action( 'plugins_loaded', array( &$this, 'CAU_auto_update_filters' ), 1 );
379
-
380
- }
381
-
382
- public function CAU_auto_update_filters() {
383
-
384
- global $wpdb;
385
- $table_name = $wpdb->prefix . "auto_updates";
386
-
387
- // Disable WP emails
388
- add_filter( 'auto_plugin_update_send_email', '__return_false' ); // Plugin updates
389
- add_filter( 'auto_theme_update_send_email', '__return_false' ); // Theme updates
390
-
391
- // Enable for major updates
392
- $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'major'");
393
- foreach ( $configs as $config ) {
394
- if( $config->onoroff == 'on' ) add_filter( 'allow_major_auto_core_updates', '__return_true', 1 ); // Turn on
395
- else add_filter( 'allow_major_auto_core_updates', '__return_false', 1 ); // Turn off
396
- }
397
-
398
- // Enable for minor updates
399
- $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'minor'");
400
- foreach ( $configs as $config ) {
401
- if( $config->onoroff == 'on' ) add_filter( 'allow_minor_auto_core_updates', '__return_true', 1 ); // Turn on
402
- else add_filter( 'allow_minor_auto_core_updates', '__return_false', 1 ); // Turn off
403
- }
404
-
405
- // Enable for plugins
406
- $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'plugins'");
407
- foreach ( $configs as $config ) {
408
- if( $config->onoroff == 'on' ) add_filter( 'auto_update_plugin', 'cau_dontUpdatePlugins', 10, 2 ); // Turn on
409
- else add_filter( 'auto_update_plugin', '__return_false', 1 ); // Turn off
410
- }
411
-
412
- // Enable for themes
413
- $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'themes'");
414
- foreach ( $configs as $config ) {
415
- if( $config->onoroff == 'on' ) add_filter( 'auto_update_theme', '__return_true' ); // Turn on
416
- else add_filter( 'auto_update_theme', '__return_false', 1 ); // Turn off
417
- }
418
-
419
- // Enable for translation files
420
- $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'translations'");
421
- foreach ( $configs as $config ) {
422
- if( $config->onoroff == 'on' ) add_filter( 'auto_update_translation', '__return_true', 1 ); // Turn on
423
- else add_filter( 'auto_update_translation', '__return_false', 1 ); // Turn off
424
- }
425
-
426
- // WP Email Config
427
- $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'wpemails'");
428
- foreach ( $configs as $config ) {
429
- if( $config->onoroff == 'on' ) {
430
- add_filter( 'auto_core_update_send_email', '__return_true' ); // Core updates
431
- } else {
432
- add_filter( 'auto_core_update_send_email', '__return_false' ); // Core updates
433
- }
434
- }
435
-
436
-
437
- }
438
-
439
- }
440
- new CAU_auto_update();
441
-
442
- // Check for issues
443
- function cau_checkForIssues( $admin_bar ) {
444
-
445
- if( cau_pluginHasIssues() && is_admin() ) {
446
-
447
- if( cau_pluginIssueLevels() == 'high' ) {
448
- $cauWaningBarTitle = __( 'Companion Auto Update ran into a critical error. View the status log for more info.', 'companion-auto-update' );
449
-
450
- $admin_bar->add_menu( array(
451
- 'id' => 'cau-has-issues',
452
- 'title' => '<span class="ab-icon"></span><span class="cau-level-'.cau_pluginIssueLevels().'">'.cau_pluginIssueCount().'</span>',
453
- 'href' => cau_url( 'status' ),
454
- 'meta' => array(
455
- 'target' => '_self',
456
- 'title' => $cauWaningBarTitle,
457
- ),
458
- ));
459
-
460
- }
461
-
462
- }
463
-
464
- }
465
- 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.1
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 );
index.php CHANGED
@@ -1,2 +1,2 @@
1
- <?php
2
  # Silence is golden.
1
+ <?php
2
  # Silence is golden.
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.6
7
  Requires PHP: 5.1
8
- Stable tag: 3.8.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -81,7 +81,11 @@ So obviously, some of you wondered what the difference would be between the defa
81
 
82
  == Changelog ==
83
 
84
- = 3.8.0 (January 14, 2020) =
 
 
 
 
85
  * New: Better handling of plugins with an unknown WP version
86
  * New: More intervals for notifications
87
  * Fix: Call to undefined function errors
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.1
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.1 (June 4, 2021) =
85
+ * New: Be notified when we need your help updating to a new database version [Feature Request](https://wordpress.org/support/topic/feature-request-839/)
86
+ * Tweak: Made some under the hood performance improvements
87
+
88
+ = 3.8.0 (January 14, 2021) =
89
  * New: Better handling of plugins with an unknown WP version
90
  * New: More intervals for notifications
91
  * Fix: Call to undefined function errors