1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
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
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
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
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
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
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
|
<?php defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
/** * Class that handles the admin notices. * * @since 1.6.10 * @author Grégory Viguier */ class Imagify_Notices extends Imagify_Notices_Deprecated {
/** * Class version. * * @var string */ const VERSION = '1.0.1';
/** * Name of the transient storing temporary notices. * * @var string */ const TEMPORARY_NOTICES_TRANSIENT_NAME = 'imagify_temporary_notices';
/** * Name of the user meta that stores the dismissed notice IDs. * * @var string */ const DISMISS_META_NAME = '_imagify_ignore_notices';
/** * Action used in the nonce to dismiss a notice. * * @var string */ const DISMISS_NONCE_ACTION = 'imagify-dismiss-notice';
/** * Action used in the nonce to deactivate a plugin. * * @var string */ const DEACTIVATE_PLUGIN_NONCE_ACTION = 'imagify-deactivate-plugin';
/** * List of notice IDs. * They correspond to method names and IDs stored in the "dismissed" transient. * Only use "-" character, not "_". * * @var array */ protected static $notice_ids = array( // This warning is displayed when the API key is empty. Dismissible. 'welcome-steps', // This warning is displayed when the API key is wrong. Dismissible. 'wrong-api-key', // This warning is displayed if some plugins are active. NOT dismissible. 'plugins-to-deactivate', // This notice is displayed when external HTTP requests are blocked via the WP_HTTP_BLOCK_EXTERNAL constant. Dismissible. 'http-block-external', // This warning is displayed when the grid view is active on the library. Dismissible. 'grid-view', // This warning is displayed to warn the user that the quota is almost consumed for the current month. Dismissible. 'almost-over-quota', // This warning is displayed if the backup folder is not writable. NOT dismissible. 'backup-folder-not-writable', // This notice is displayed to rate the plugin after 100 optimizations & 7 days after the first installation. Dismissible. 'rating', // Add a message about WP Rocket on the "Bulk Optimization" screen. Dismissible. 'wp-rocket', );
/** * List of user capabilities to use for each notice. * Default value 'manage' is not listed. * * @var array */ protected static $capabilities = array( 'grid-view' => 'optimize', 'backup-folder-not-writable' => 'bulk-optimize', 'rating' => 'bulk-optimize', 'wp-rocket' => 'bulk-optimize', );
/** * List of plugins that conflict with Imagify. * * @var array */ protected static $conflicting_plugins = array( 'wp-smush' => 'wp-smushit/wp-smush.php', // WP Smush. 'wp-smush-pro' => 'wp-smush-pro/wp-smush.php', // WP Smush Pro. 'kraken' => 'kraken-image-optimizer/kraken.php', // Kraken.io. 'tinypng' => 'tiny-compress-images/tiny-compress-images.php', // TinyPNG. 'shortpixel' => 'shortpixel-image-optimiser/wp-shortpixel.php', // Shortpixel. 'ewww' => 'ewww-image-optimizer/ewww-image-optimizer.php', // EWWW Image Optimizer. 'ewww-cloud' => 'ewww-image-optimizer-cloud/ewww-image-optimizer-cloud.php', // EWWW Image Optimizer Cloud. 'imagerecycle' => 'imagerecycle-pdf-image-compression/wp-image-recycle.php', // ImageRecycle. );
/** * The single instance of the class. * * @var object */ protected static $_instance;
/** * The constructor. * * @return void */ protected function __construct() {}
/** ----------------------------------------------------------------------------------------- */ /** INIT ==================================================================================== */ /** ----------------------------------------------------------------------------------------- */
/** * Get the main Instance. * * @since 1.6.10 * @author Grégory Viguier * * @return object Main instance. */ public static function get_instance() { if ( ! isset( self::$_instance ) ) { self::$_instance = new self(); }
return self::$_instance; }
/** * Launch the hooks. * * @since 1.6.10 * @author Grégory Viguier */ public function init() { // For generic purpose. add_action( 'all_admin_notices', array( $this, 'render_notices' ) ); add_action( 'wp_ajax_imagify_dismiss_notice', array( $this, 'admin_post_dismiss_notice' ) ); add_action( 'admin_post_imagify_dismiss_notice', array( $this, 'admin_post_dismiss_notice' ) ); // For specific notices. add_action( 'imagify_dismiss_notice', array( $this, 'clear_scheduled_rating' ) ); add_action( 'admin_post_imagify_deactivate_plugin', array( $this, 'deactivate_plugin' ) ); add_action( 'imagify_not_almost_over_quota_anymore', array( $this, 'renew_almost_over_quota_notice' ) ); }
/** ----------------------------------------------------------------------------------------- */ /** HOOKS =================================================================================== */ /** ----------------------------------------------------------------------------------------- */
/** * Maybe display some notices. * * @since 1.6.10 * @author Grégory Viguier */ public function render_notices() { foreach ( $this->get_notice_ids() as $notice_id ) { // Get the name of the method that will tell if this notice should be displayed. $callback = 'display_' . str_replace( '-', '_', $notice_id );
if ( ! method_exists( $this, $callback ) ) { continue; }
$data = call_user_func( array( $this, $callback ) );
if ( $data ) { // The notice must be displayed: render the view. Imagify_Views::get_instance()->print_template( 'notice-' . $notice_id, $data ); } }
// Temporary notices. $this->render_temporary_notices(); }
/** * Process a dismissed notice. * * @since 1.6.10 * @author Grégory Viguier * @see _do_admin_post_imagify_dismiss_notice() */ public function admin_post_dismiss_notice() { imagify_check_nonce( self::DISMISS_NONCE_ACTION );
$notice = ! empty( $_GET['notice'] ) ? esc_html( wp_unslash( $_GET['notice'] ) ) : false; $notices = $this->get_notice_ids(); $notices = array_flip( $notices );
if ( ! $notice || ! isset( $notices[ $notice ] ) || ! $this->user_can( $notice ) ) { imagify_die(); }
self::dismiss_notice( $notice );
/** * Fires when a notice is dismissed. * * @since 1.4.2 * * @param int $notice The notice slug */ do_action( 'imagify_dismiss_notice', $notice );
imagify_maybe_redirect(); wp_send_json_success(); }
/** * Stop the rating cron when the notice is dismissed. * * @since 1.6.10 * @author Grégory Viguier * @see _imagify_clear_scheduled_rating() * * @param string $notice The notice name. */ public function clear_scheduled_rating( $notice ) { if ( 'rating' === $notice ) { set_site_transient( 'do_imagify_rating_cron', 'no' ); Imagify_Cron_Rating::get_instance()->unschedule_event(); } }
/** * Disable a plugin which can be in conflict with Imagify. * * @since 1.6.10 * @author Grégory Viguier * @see _imagify_deactivate_plugin() */ public function deactivate_plugin() { imagify_check_nonce( self::DEACTIVATE_PLUGIN_NONCE_ACTION );
if ( empty( $_GET['plugin'] ) || ! $this->user_can( 'plugins-to-deactivate' ) ) { imagify_die(); }
$plugin = esc_html( wp_unslash( $_GET['plugin'] ) ); $plugins = $this->get_conflicting_plugins(); $plugins = array_flip( $plugins );
if ( empty( $plugins[ $plugin ] ) ) { imagify_die(); }
deactivate_plugins( $plugin );
imagify_maybe_redirect(); wp_send_json_success(); }
/** * Renew the "almost-over-quota" notice when the consumed quota percent decreases back below 80%. * * @since 1.7 * @author Grégory Viguier */ public function renew_almost_over_quota_notice() { global $wpdb;
$results = $wpdb->get_results( $wpdb->prepare( "SELECT umeta_id, user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value LIKE %s", self::DISMISS_META_NAME, '%almost-over-quota%' ) );
if ( ! $results ) { return; }
// Prevent multiple queries to the DB by caching user metas. $not_cached = array();
foreach ( $results as $result ) { if ( ! wp_cache_get( $result->umeta_id, 'user_meta' ) ) { $not_cached[] = $result->umeta_id; } }
if ( $not_cached ) { update_meta_cache( 'user', $not_cached ); }
// Renew the notice for all users. foreach ( $results as $result ) { self::renew_notice( 'almost-over-quota', $result->user_id ); } }
/** ----------------------------------------------------------------------------------------- */ /** NOTICES ================================================================================= */ /** ----------------------------------------------------------------------------------------- */
/** * Tell if the 'welcome-steps' notice should be displayed. * * @since 1.6.10 * @author Grégory Viguier * * @return bool */ public function display_welcome_steps() { static $display;
if ( isset( $display ) ) { return $display; }
$display = false;
if ( ! $this->user_can( 'welcome-steps' ) ) { return $display; }
if ( imagify_is_screen( 'imagify-settings' ) ) { return $display; }
if ( self::notice_is_dismissed( 'welcome-steps' ) || get_imagify_option( 'api_key' ) ) { return $display; }
$display = true; return $display; }
/** * Tell if the 'wrong-api-key' notice should be displayed. * * @since 1.6.10 * @author Grégory Viguier * * @return bool */ public function display_wrong_api_key() { static $display;
if ( isset( $display ) ) { return $display; }
$display = false;
if ( ! $this->user_can( 'wrong-api-key' ) ) { return $display; }
if ( ! imagify_is_screen( 'bulk' ) ) { return $display; }
if ( self::notice_is_dismissed( 'wrong-api-key' ) || ! get_imagify_option( 'api_key' ) || Imagify_Requirements::is_api_key_valid() ) { return $display; }
$display = true; return $display; }
/** * Tell if the 'plugins-to-deactivate' notice should be displayed. * * @since 1.6.10 * @author Grégory Viguier * * @return array An array of plugins to deactivate. */ public function display_plugins_to_deactivate() { static $display;
if ( isset( $display ) ) { return $display; }
if ( ! $this->user_can( 'plugins-to-deactivate' ) ) { $display = false; return $display; }
$display = $this->get_conflicting_plugins(); return $display; }
/** * Tell if the 'plugins-to-deactivate' notice should be displayed. * * @since 1.6.10 * @author Grégory Viguier * * @return bool */ public function display_http_block_external() { static $display;
if ( isset( $display ) ) { return $display; }
$display = false;
if ( ! $this->user_can( 'http-block-external' ) ) { return $display; }
if ( imagify_is_screen( 'imagify-settings' ) ) { return $display; }
if ( self::notice_is_dismissed( 'http-block-external' ) || ! Imagify_Requirements::is_imagify_blocked() ) { return $display; }
$display = true; return $display; }
/** * Tell if the 'grid-view' notice should be displayed. * * @since 1.6.10 * @author Grégory Viguier * * @return bool */ public function display_grid_view() { global $wp_version; static $display;
if ( isset( $display ) ) { return $display; }
$display = false;
if ( ! $this->user_can( 'grid-view' ) ) { return $display; }
if ( ! imagify_is_screen( 'library' ) ) { return $display; }
$media_library_mode = get_user_option( 'media_library_mode', get_current_user_id() );
if ( 'list' === $media_library_mode || self::notice_is_dismissed( 'grid-view' ) || version_compare( $wp_version, '4.0' ) < 0 ) { return $display; }
// Don't display the notice if the API key isn't valid. if ( ! Imagify_Requirements::is_api_key_valid() ) { return $display; }
$display = true; return $display; }
/** * Tell if the 'almost-over-quota' notice should be displayed. * * @since 1.7.0 * @author Geoffrey Crofte * * @return bool|object An Imagify user object. False otherwise. */ public function display_almost_over_quota() { static $display;
if ( isset( $display ) ) { return $display; }
$display = false;
if ( ! $this->user_can( 'almost-over-quota' ) ) { return $display; }
if ( ! imagify_is_screen( 'imagify-settings' ) && ! imagify_is_screen( 'bulk' ) ) { return $display; }
if ( self::notice_is_dismissed( 'almost-over-quota' ) ) { return $display; }
$user = new Imagify_User();
// Don't display the notice if the user's unconsumed quota is superior to 20%. if ( $user->get_percent_unconsumed_quota() > 20 ) { return $display; }
$display = $user; return $display; }
/** * Tell if the 'backup-folder-not-writable' notice should be displayed. * * @since 1.6.10 * @author Grégory Viguier * * @return bool */ public function display_backup_folder_not_writable() { global $post_id; static $display;
if ( isset( $display ) ) { return $display; }
$display = false;
if ( ! $this->user_can( 'backup-folder-not-writable' ) ) { return $display; }
// Every places where images can be optimized, automatically or not (+ the settings page). if ( ! imagify_is_screen( 'imagify-settings' ) && ! imagify_is_screen( 'library' ) && ! imagify_is_screen( 'upload' ) && ! imagify_is_screen( 'bulk' ) && ! imagify_is_screen( 'media-modal' ) ) { return $display; }
if ( ! get_imagify_option( 'backup' ) ) { return $display; }
if ( Imagify_Requirements::attachments_backup_dir_is_writable() ) { return $display; }
$display = true; return $display; }
/** * Tell if the 'rating' notice should be displayed. * * @since 1.6.10 * @author Grégory Viguier * * @return bool|int */ public function display_rating() { static $display;
if ( isset( $display ) ) { return $display; }
$display = false;
if ( ! $this->user_can( 'rating' ) ) { return $display; }
if ( ! imagify_is_screen( 'bulk' ) && ! imagify_is_screen( 'library' ) && ! imagify_is_screen( 'upload' ) ) { return $display; }
if ( self::notice_is_dismissed( 'rating' ) ) { return $display; }
$user_images_count = (int) get_site_transient( 'imagify_user_images_count' );
if ( ! $user_images_count || get_site_transient( 'imagify_seen_rating_notice' ) ) { return $display; }
$display = $user_images_count; return $display; }
/** * Tell if the 'wp-rocket' notice should be displayed. * * @since 1.6.10 * @author Grégory Viguier * * @return bool */ public function display_wp_rocket() { static $display;
if ( isset( $display ) ) { return $display; }
$display = false;
if ( ! $this->user_can( 'wp-rocket' ) ) { return $display; }
if ( ! imagify_is_screen( 'bulk' ) ) { return $display; }
if ( defined( 'WP_ROCKET_VERSION' ) || self::notice_is_dismissed( 'wp-rocket' ) ) { return $display; }
$display = true; return $display; }
/** ----------------------------------------------------------------------------------------- */ /** TEMPORARY NOTICES ======================================================================= */ /** ----------------------------------------------------------------------------------------- */
/** * Maybe display some notices. * * @since 1.7 * @access public * @author Grégory Viguier */ public function render_temporary_notices() { if ( is_network_admin() ) { $notices = $this->get_network_temporary_notices(); } else { $notices = $this->get_site_temporary_notices(); }
if ( ! $notices ) { return; }
$views = Imagify_Views::get_instance();
foreach ( $notices as $i => $notice_data ) { $notices[ $i ]['type'] = ! empty( $notice_data['type'] ) ? $notice_data['type'] : 'error'; }
$views->print_template( 'notice-temporary', $notices ); }
/** * Get temporary notices for the network. * * @since 1.7 * @access public * @author Grégory Viguier * * @return array */ public function get_network_temporary_notices() { $notices = get_site_transient( self::TEMPORARY_NOTICES_TRANSIENT_NAME );
if ( false === $notices ) { return array(); }
delete_site_transient( self::TEMPORARY_NOTICES_TRANSIENT_NAME );
return $notices && is_array( $notices ) ? $notices : array(); }
/** * Create a temporary notice for the network. * * @since 1.7 * @access public * @author Grégory Viguier * * @param array|object|string $notice_data Some data, with the message to display. */ public function add_network_temporary_notice( $notice_data ) { $notices = get_site_transient( self::TEMPORARY_NOTICES_TRANSIENT_NAME ); $notices = is_array( $notices ) ? $notices : array();
if ( is_wp_error( $notice_data ) ) { $notice_data = $notice_data->get_error_messages(); $notice_data = implode( '<br/>', $notice_data ); }
if ( is_string( $notice_data ) ) { $notice_data = array( 'message' => $notice_data, ); } elseif ( is_object( $notice_data ) ) { $notice_data = (array) $notice_data; }
if ( ! is_array( $notice_data ) || empty( $notice_data['message'] ) ) { return; }
$notices[] = $notice_data;
set_site_transient( self::TEMPORARY_NOTICES_TRANSIENT_NAME, $notices, 30 ); }
/** * Get temporary notices for the current site. * * @since 1.7 * @access public * @author Grégory Viguier * * @return array */ public function get_site_temporary_notices() { $notices = get_transient( self::TEMPORARY_NOTICES_TRANSIENT_NAME );
if ( false === $notices ) { return array(); }
delete_transient( self::TEMPORARY_NOTICES_TRANSIENT_NAME );
return $notices && is_array( $notices ) ? $notices : array(); }
/** * Create a temporary notice for the current site. * * @since 1.7 * @access public * @author Grégory Viguier * * @param array|string $notice_data Some data, with the message to display. */ public function add_site_temporary_notice( $notice_data ) { $notices = get_transient( self::TEMPORARY_NOTICES_TRANSIENT_NAME ); $notices = is_array( $notices ) ? $notices : array();
if ( is_string( $notice_data ) ) { $notice_data = array( 'message' => $notice_data, ); } elseif ( is_object( $notice_data ) ) { $notice_data = (array) $notice_data; }
if ( ! is_array( $notice_data ) || empty( $notice_data['message'] ) ) { return; }
$notices[] = $notice_data;
set_transient( self::TEMPORARY_NOTICES_TRANSIENT_NAME, $notices, 30 ); }
/** ----------------------------------------------------------------------------------------- */ /** PUBLIC TOOLS ============================================================================ */ /** ----------------------------------------------------------------------------------------- */
/** * Renew a dismissed Imagify notice. * * @since 1.6.10 * @author Grégory Viguier * * @param string $notice A notice ID. * @param int $user_id A user ID. */ public static function renew_notice( $notice, $user_id = 0 ) { $user_id = $user_id ? (int) $user_id : get_current_user_id(); $notices = get_user_meta( $user_id, self::DISMISS_META_NAME, true ); $notices = $notices && is_array( $notices ) ? array_flip( $notices ) : array();
if ( ! isset( $notices[ $notice ] ) ) { return; }
unset( $notices[ $notice ] ); $notices = array_flip( $notices ); $notices = array_filter( $notices ); $notices = array_values( $notices );
update_user_meta( $user_id, self::DISMISS_META_NAME, $notices ); }
/** * Dismiss an Imagify notice. * * @since 1.6.10 * @author Grégory Viguier * @see imagify_dismiss_notice() * * @param string $notice A notice ID. * @param int $user_id A user ID. */ public static function dismiss_notice( $notice, $user_id = 0 ) { $user_id = $user_id ? (int) $user_id : get_current_user_id(); $notices = get_user_meta( $user_id, self::DISMISS_META_NAME, true ); $notices = $notices && is_array( $notices ) ? array_flip( $notices ) : array();
if ( isset( $notices[ $notice ] ) ) { return; }
$notices = array_flip( $notices ); $notices[] = $notice; $notices = array_filter( $notices ); $notices = array_values( $notices );
update_user_meta( $user_id, self::DISMISS_META_NAME, $notices ); }
/** * Tell if an Imagify notice is dismissed. * * @since 1.6.10 * @author Grégory Viguier * @see imagify_notice_is_dismissed() * * @param string $notice A notice ID. * @param int $user_id A user ID. * @return bool */ public static function notice_is_dismissed( $notice, $user_id = 0 ) { $user_id = $user_id ? (int) $user_id : get_current_user_id(); $notices = get_user_meta( $user_id, self::DISMISS_META_NAME, true ); $notices = $notices && is_array( $notices ) ? array_flip( $notices ) : array();
return isset( $notices[ $notice ] ); }
/** * Tell if one or more notices will be displayed later in the page. * * @since 1.6.10 * @author Grégory Viguier * * @return bool */ public function has_notices() { foreach ( self::$notice_ids as $notice_id ) { $callback = 'display_' . str_replace( '-', '_', $notice_id );
if ( method_exists( $this, $callback ) && call_user_func( array( $this, $callback ) ) ) { return true; } }
return false; }
/** ----------------------------------------------------------------------------------------- */ /** INTERNAL TOOLS ========================================================================== */ /** ----------------------------------------------------------------------------------------- */
/** * Get all notice IDs. * * @since 1.6.10 * @author Grégory Viguier */ protected function get_notice_ids() { /** * Filter the notices Imagify can display. * * @since 1.6.10 * @author Grégory Viguier * * @param array $notice_ids An array of notice "IDs". */ return apply_filters( 'imagify_notices', self::$notice_ids ); }
/** * Tell if the current user can see the notices. * Notice IDs that are not listed in self::$capabilities are assumed as 'manage'. * * @since 1.6.10 * @author Grégory Viguier * * @param string $notice_id A notice ID. * @return bool */ protected function user_can( $notice_id ) { $capability = isset( self::$capabilities[ $notice_id ] ) ? self::$capabilities[ $notice_id ] : 'manage';
return imagify_get_context( 'wp' )->current_user_can( $capability ); }
/** * Get a list of plugins that can conflict with Imagify. * * @since 1.6.10 * @author Grégory Viguier * * @return array */ protected function get_conflicting_plugins() { /** * Filter the recommended plugins to deactivate to prevent conflicts. * * @since 1.0 * * @param string $plugins List of recommended plugins to deactivate. */ $plugins = apply_filters( 'imagify_plugins_to_deactivate', self::$conflicting_plugins );
return array_filter( $plugins, 'is_plugin_active' ); } }
|