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 | Companion Auto Update |
Version | 3.8.1 |
Comparing to | |
See all releases |
Code changes from version 3.8.0 to 3.8.1
- admin/dashboard.php +572 -558
- backend/style.css +566 -546
- cau_emails.php +510 -480
- cau_functions.php +1429 -1429
- companion-auto-update.php +466 -465
- index.php +1 -1
- 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' ).' –</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' ).' –</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 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
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 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
$wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = '
|
51 |
-
$wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = '
|
52 |
-
$wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = '
|
53 |
-
$wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = '
|
54 |
-
$wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = '
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
$
|
61 |
-
$
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
$
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
$
|
78 |
-
$
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
wp_clear_scheduled_hook('
|
87 |
-
wp_clear_scheduled_hook('
|
88 |
-
wp_clear_scheduled_hook('
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
$
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
wp_schedule_event(
|
109 |
-
wp_schedule_event(
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
$
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
wp_schedule_event(
|
130 |
-
wp_schedule_event(
|
131 |
-
|
132 |
-
}
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
$
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
$
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
$
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
}
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
<
|
205 |
-
<
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
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 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
<
|
278 |
-
|
279 |
-
|
280 |
-
<
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
<
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
<
|
291 |
-
|
292 |
-
|
293 |
-
<
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
<
|
300 |
-
|
301 |
-
|
302 |
-
<
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
<
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
<option value='
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
<
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
<
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
</
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
</div>
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
</
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
<div class="welcome-column welcome-column.welcome-column-half">
|
484 |
-
<h3 class="support-sidebar-title"><?php _e( '
|
485 |
-
<ul class="support-sidebar-list">
|
486 |
-
<li><a href="https://codeermeneer.nl/
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
<
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
<
|
516 |
-
<a
|
517 |
-
|
518 |
-
|
519 |
-
</
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
<
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
var
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
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' ).' –</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' ).' –</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> |
|
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 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
color: #9178B7;
|
153 |
-
}
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
}
|
171 |
-
.cau
|
172 |
-
|
173 |
-
}
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
.cau_content .
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
}
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
table.
|
253 |
-
|
254 |
-
}
|
255 |
-
table.
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
.
|
262 |
-
|
263 |
-
}
|
264 |
-
.
|
265 |
-
color: #
|
266 |
-
}
|
267 |
-
.
|
268 |
-
|
269 |
-
}
|
270 |
-
|
271 |
-
/*
|
272 |
-
table.
|
273 |
-
|
274 |
-
}
|
275 |
-
table.
|
276 |
-
|
277 |
-
}
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
}
|
314 |
-
.cau_content #the-list input[type="checkbox"]:not(:checked)
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
}
|
324 |
-
.cau_content #the-list input[type="checkbox"]:not(:checked) + label
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
}
|
334 |
-
.cau_content #the-list input[type="checkbox"]:not(:checked) + label:before {
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
background:
|
340 |
-
border
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
}
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
}
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
.
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
}
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
}
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
width:
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
.
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
}
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
}
|
535 |
-
table.cau_status_list.
|
536 |
-
display:
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
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 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
}
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
$
|
70 |
-
|
71 |
-
//
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
$text
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
$text .= $break;
|
149 |
-
$text .=
|
150 |
-
|
151 |
-
$
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
$
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
}
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
$
|
277 |
-
$
|
278 |
-
$
|
279 |
-
|
280 |
-
|
281 |
-
$
|
282 |
-
|
283 |
-
$
|
284 |
-
|
285 |
-
// Where to look for
|
286 |
-
$
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
// Get
|
301 |
-
$
|
302 |
-
$
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
$
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
}
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
$
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
$
|
424 |
-
}
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
//
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
//
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
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 .= ' ‐ '.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 .= ' ‐ '.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 .= ' ‐ '.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 .= ' ‐ '.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.'§ion=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 .= ' ‐ '.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 .= ' ‐ '.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 .= ' ‐ '.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 .= ' ‐ '.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.'§ion=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.
|
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.
|
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 |
-
|
173 |
-
|
174 |
-
if( !cau_check_if_exists( '
|
175 |
-
if( !cau_check_if_exists( '
|
176 |
-
if( !cau_check_if_exists( '
|
177 |
-
if( !cau_check_if_exists( '
|
178 |
-
if( !cau_check_if_exists( '
|
179 |
-
if( !cau_check_if_exists( '
|
180 |
-
if( !cau_check_if_exists( '
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
$
|
192 |
-
$wpdb->
|
193 |
-
$wpdb->query( "DROP TABLE IF EXISTS $
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
wp_clear_scheduled_hook( '
|
198 |
-
wp_clear_scheduled_hook( '
|
199 |
-
wp_clear_scheduled_hook( '
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
add_filter( '
|
204 |
-
add_filter( '
|
205 |
-
add_filter( '
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
$
|
224 |
-
|
225 |
-
$
|
226 |
-
$wpdb->query( "ALTER TABLE $
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
'
|
268 |
-
'
|
269 |
-
'
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
echo '<
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
<
|
321 |
-
<
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
wp_enqueue_script( '
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
$
|
360 |
-
$
|
361 |
-
|
362 |
-
|
363 |
-
array_unshift( $links, $
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
add_filter( '
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
'
|
453 |
-
'
|
454 |
-
'
|
455 |
-
|
456 |
-
'
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
|
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.
|
7 |
Requires PHP: 5.1
|
8 |
-
Stable tag: 3.8.
|
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.
|
|
|
|
|
|
|
|
|
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
|