• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

equalizedigital / accessibility-checker / 25876266860

14 May 2026 05:55PM UTC coverage: 57.515% (-0.05%) from 57.564%
25876266860

push

github

web-flow
Merge pull request #1695 from equalizedigital/release/1.41.0

[Backport] Release v1.41.0

15 of 47 new or added lines in 2 files covered. (31.91%)

4 existing lines in 1 file now uncovered.

5499 of 9561 relevant lines covered (57.51%)

4.52 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

21.47
/admin/class-admin-notices.php
1
<?php
2
/**
3
 * Class file for admin notices
4
 *
5
 * @package Accessibility_Checker
6
 */
7

8
namespace EDAC\Admin;
9

10
use EqualizeDigital\AccessibilityChecker\Fixes\FixesManager;
11

12
if ( ! defined( 'ABSPATH' ) ) {
6✔
13
        exit;
×
14
}
15

16
/**
17
 * Class that handles admin notices
18
 */
19
class Admin_Notices {
20

21
        /**
22
         * Initialize the class and set its properties.
23
         */
24
        public function __construct() {
25
        }
28✔
26

27
        /**
28
         * Initialize class hooks.
29
         *
30
         * @return void
31
         */
32
        public function init_hooks() {
33

34
                add_action( 'in_admin_header', [ $this, 'edac_remove_admin_notices' ], 1000 );
4✔
35
                add_action( 'in_admin_header', [ $this, 'hook_notices' ], 1001 );
4✔
36
                // Ajax handlers for notices.
37
                add_action( 'wp_ajax_edac_black_friday_notice_ajax', [ $this, 'edac_black_friday_notice_ajax' ] );
4✔
38
                add_action( 'wp_ajax_edac_gaad_presale_notice_ajax', [ $this, 'edac_gaad_presale_notice_ajax' ] );
4✔
39
                add_action( 'wp_ajax_edac_gaad_sale_notice_ajax', [ $this, 'edac_gaad_sale_notice_ajax' ] );
4✔
40
                add_action( 'wp_ajax_edac_review_notice_ajax', [ $this, 'edac_review_notice_ajax' ] );
4✔
41
                // Save fixes transient on save.
42
                add_action( 'updated_option', [ $this, 'set_fixes_transient_on_save' ] );
4✔
43
        }
44

45
        /**
46
         * Hook Notices
47
         *
48
         * @since 1.9.3
49
         *
50
         * @return void
51
         */
52
        public function hook_notices() {
53
                if ( ! Helpers::current_user_can_see_widgets_and_notices() ) {
×
54
                        return;
×
55
                }
56

57
                add_action( 'admin_notices', [ $this, 'edac_black_friday_notice' ] );
×
NEW
58
                add_action( 'admin_notices', [ $this, 'edac_gaad_presale_notice' ] );
×
NEW
59
                add_action( 'admin_notices', [ $this, 'edac_gaad_sale_notice' ] );
×
UNCOV
60
                add_action( 'admin_notices', [ $this, 'edac_review_notice' ] );
×
61
        }
62

63
        /**
64
         * Remove Admin Notices
65
         *
66
         * @return void
67
         */
68
        public function edac_remove_admin_notices() {
69

70
                $current_screen = get_current_screen();
2✔
71
                if ( ! $current_screen || ! isset( $current_screen->id ) ) {
2✔
72
                        return;
2✔
73
                }
74
                $screens = [
×
75
                        'toplevel_page_accessibility_checker',
×
76
                        'accessibility-checker_page_accessibility_checker_issues',
×
77
                        'accessibility-checker_page_accessibility_checker_ignored',
×
78
                        'accessibility-checker_page_accessibility_checker_settings',
×
79
                ];
×
80

81
                /**
82
                 * Filter the screens where admin notices should be removed.
83
                 *
84
                 * @since 1.14.0
85
                 *
86
                 * @param array $screens The screens where admin notices should be removed.
87
                 */
88
                $screens = apply_filters( 'edac_filter_remove_admin_notices_screens', $screens );
×
89
                if ( ! is_array( $screens ) ) {
×
90
                        $screens = [];
×
91
                }
92

93
                if ( in_array( $current_screen->id, $screens, true ) ) {
×
94
                        remove_all_actions( 'admin_notices' );
×
95
                        remove_all_actions( 'all_admin_notices' );
×
96
                }
97
        }
98

99
        /**
100
         * Black Friday Admin Notice
101
         *
102
         * @return void
103
         */
104
        public function edac_black_friday_notice() {
105

106
                // Check if Accessibility Checker Pro is active.
107
                if ( defined( 'EDACP_VERSION' ) ) {
×
108
                        return;
×
109
                }
110

111
                // Check if the notice has been dismissed.
112
                if ( absint( get_option( 'edac_black_friday_2025_notice_dismiss', 0 ) ) ) {
×
113
                        return;
×
114
                }
115

116
                // Show from November 24 to December 03.
117
                $current_date = date_i18n( 'Ymd' ); // Use date_i18n for localization.
×
118
                $start_date   = '20251124';
×
119
                $end_date     = '20251203';
×
120

121
                if ( $current_date >= $start_date && $current_date <= $end_date ) {
×
122

123
                        // Get the promotional message from a separate function/file.
124
                        $message = $this->edac_get_black_friday_message();
×
125

126
                        // Output the message with appropriate sanitization.
127
                        echo wp_kses_post( $message );
×
128

129
                }
130
        }
131

132
        /**
133
         * Get Black Friday Promo Message
134
         *
135
         * @return string
136
         */
137
        public function edac_get_black_friday_message() {
138

139
                // Construct the promotional message.
140
                $message  = '<div class="edac_black_friday_notice notice notice-info is-dismissible">';
4✔
141
                $message .= '<p><strong>' . esc_html__( '🎉 Black Friday special! 🎉', 'accessibility-checker' ) . '</strong><br />';
4✔
142
                $message .= esc_html__( 'Upgrade to a paid version of Accessibility Checker from November 24th to December 3rd and get 30% off! Full site scanning, site-wide open issues report, ignore logs, and more.', 'accessibility-checker' ) . '<br />';
4✔
143
                $message .= '<a class="button button-primary" href="' . esc_url( edac_link_wrapper( 'https://my.equalizedigital.com/support/pre-sale-questions/', 'admin-notice', 'BlackFriday25-presale', false ) ) . '">' . esc_html__( 'Ask a Pre-Sale Question', 'accessibility-checker' ) . '</a> ';
4✔
144
                $message .= '<a class="button button-primary" href="' . esc_url( edac_link_wrapper( 'https://equalizedigital.com/accessibility-checker/pricing/', 'admin-notice', 'BlackFriday25-pricing', false ) ) . '">' . esc_html__( 'Upgrade Now', 'accessibility-checker' ) . '</a></p>';
4✔
145
                $message .= '</div>';
4✔
146

147
                return $message;
4✔
148
        }
149

150
        /**
151
         * Black Friday Admin Notice Ajax
152
         *
153
         * @return void
154
         *
155
         *  - '-1' means that nonce could not be varified
156
         *  - '-2' means that update option wasn't successful
157
         */
158
        public function edac_black_friday_notice_ajax() {
159

160
                // nonce security.
161
                if ( ! isset( $_REQUEST['nonce'] ) || ! wp_verify_nonce( sanitize_key( $_REQUEST['nonce'] ), 'ajax-nonce' ) ) {
×
162

163
                        $error = new \WP_Error( '-1', __( 'Permission Denied', 'accessibility-checker' ) );
×
164
                        wp_send_json_error( $error );
×
165

166
                }
167

168
                $results = update_option( 'edac_black_friday_2025_notice_dismiss', true );
×
169
                // Delete old options if they exist.
170
                delete_option( 'edac_black_friday_2024_notice_dismiss' );
×
171
                delete_option( 'edac_black_friday_2023_notice_dismiss' );
×
172

173
                if ( ! $results ) {
×
174

175
                        $error = new \WP_Error( '-2', __( 'Update option wasn\'t successful', 'accessibility-checker' ) );
×
176
                        wp_send_json_error( $error );
×
177

178
                }
179

180
                wp_send_json_success( wp_json_encode( $results ) );
×
181
        }
182

183
        /**
184
         * GAAD Pre-Sale Notice
185
         *
186
         * Displays May 13–19 to build awareness of Global Accessibility Awareness Day
187
         * and tease the upcoming flash sale.
188
         *
189
         * @return void
190
         */
191
        public function edac_gaad_presale_notice() {
192

193
                // Check if the notice has been dismissed.
NEW
194
                if ( absint( get_option( 'edac_gaad_presale_notice_dismiss_2026', 0 ) ) ) {
×
195
                        return;
×
196
                }
197

UNCOV
198
                $current_date = gmdate( 'Y-m-d' );
×
NEW
199
                $start_date   = '2026-05-13';
×
NEW
200
                $end_date     = '2026-05-19';
×
201

NEW
202
                if ( $current_date >= $start_date && $current_date <= $end_date ) {
×
NEW
203
                        echo wp_kses_post( $this->edac_get_gaad_presale_message() );
×
204
                }
205
        }
206

207
        /**
208
         * Get GAAD Pre-Sale Message
209
         *
210
         * Awareness-focused copy shown May 13–19 before the sale goes live.
211
         *
212
         * @return string
213
         */
214
        public function edac_get_gaad_presale_message() {
215

216
                $message  = '<div class="edac_gaad_presale_notice notice notice-info is-dismissible">';
6✔
217
                $message .= '<p><strong>' . esc_html__( '⚡️ Global Accessibility Awareness Day Flash Sale', 'accessibility-checker' ) . '</strong><br />';
6✔
218

219
                if ( defined( 'EDACP_VERSION' ) && edac_is_pro() ) {
6✔
NEW
220
                        $message .= esc_html__( 'Starting May 20th: Save 15% on accessibility courses and ArchiveWP with coupon code ', 'accessibility-checker' ) . '<code>GAAD2026</code>.<br />';
×
NEW
221
                        $message .= esc_html__( '3 days only • May 20–22', 'accessibility-checker' ) . '</p><p>';
×
NEW
222
                        $message .= '<a class="button button-primary" href="' . esc_url( edac_link_wrapper( 'https://equalizedigital.com/archivewp/', 'admin-notice', 'GAAD2026-archivewp-pre', false ) ) . '">' . esc_html__( 'View ArchiveWP Pricing', 'accessibility-checker' ) . '</a> ';
×
NEW
223
                        $message .= '<a class="button button-primary" href="' . esc_url( edac_link_wrapper( 'https://equalizedigital.com/learn/courses/', 'admin-notice', 'GAAD2026-courses-pre', false ) ) . '">' . esc_html__( 'View Course Pricing', 'accessibility-checker' ) . '</a></p>';
×
224
                } else {
225
                        $message .= esc_html__( 'Starting May 20th: Save 15% on Accessibility Checker Pro with coupon code ', 'accessibility-checker' ) . '<code>GAAD2026</code>.<br />';
6✔
226
                        $message .= esc_html__( '3 days only • May 20–22', 'accessibility-checker' ) . '</p><p>';
6✔
227
                        $message .= '<a class="button button-primary" href="' . esc_url( edac_link_wrapper( 'https://equalizedigital.com/accessibility-checker/pricing/', 'admin-notice', 'GAAD2026-pricing-pre', false ) ) . '">' . esc_html__( 'View Pricing', 'accessibility-checker' ) . '</a></p>';
6✔
228
                }
229

230
                $message .= '</div>';
6✔
231

232
                return $message;
6✔
233
        }
234

235
        /**
236
         * GAAD Pre-Sale Notice Ajax
237
         *
238
         * @return void
239
         *
240
         *  - '-1' means that nonce could not be verified
241
         *  - '-2' means that update option wasn't successful
242
         */
243
        public function edac_gaad_presale_notice_ajax() {
244

NEW
245
                if ( ! isset( $_REQUEST['nonce'] ) || ! wp_verify_nonce( sanitize_key( $_REQUEST['nonce'] ), 'ajax-nonce' ) ) {
×
NEW
246
                        $error = new \WP_Error( '-1', __( 'Permission Denied', 'accessibility-checker' ) );
×
NEW
247
                        wp_send_json_error( $error );
×
248
                }
249

NEW
250
                $results = update_option( 'edac_gaad_presale_notice_dismiss_2026', true );
×
251

NEW
252
                if ( ! $results ) {
×
NEW
253
                        $error = new \WP_Error( '-2', __( 'Update option wasn\'t successful', 'accessibility-checker' ) );
×
NEW
254
                        wp_send_json_error( $error );
×
255
                }
256

NEW
257
                wp_send_json_success( wp_json_encode( $results ) );
×
258
        }
259

260
        /**
261
         * GAAD Sale Notice
262
         *
263
         * Displays May 20–22 during the active flash sale.
264
         *
265
         * @return void
266
         */
267
        public function edac_gaad_sale_notice() {
268

269
                // Check if the notice has been dismissed.
NEW
270
                if ( absint( get_option( 'edac_gaad_sale_notice_dismiss_2026', 0 ) ) ) {
×
NEW
271
                        return;
×
272
                }
273

NEW
274
                $current_date = gmdate( 'Y-m-d' );
×
NEW
275
                $start_date   = '2026-05-20';
×
NEW
276
                $end_date     = '2026-05-22';
×
277

NEW
278
                if ( $current_date >= $start_date && $current_date <= $end_date ) {
×
NEW
279
                        echo wp_kses_post( $this->edac_get_gaad_sale_message() );
×
280
                }
281
        }
282

283
        /**
284
         * Get GAAD Sale Message
285
         *
286
         * Urgency-focused copy shown May 20–22 while the sale is live.
287
         *
288
         * @return string
289
         */
290
        public function edac_get_gaad_sale_message() {
291

292
                $message  = '<div class="edac_gaad_sale_notice notice notice-info is-dismissible">';
6✔
293
                $message .= '<p><strong>' . esc_html__( '⚡️ Global Accessibility Awareness Day Flash Sale', 'accessibility-checker' ) . '</strong><br />';
6✔
294

295
                if ( defined( 'EDACP_VERSION' ) && edac_is_pro() ) {
6✔
NEW
296
                        $message .= esc_html__( 'Save 15% on accessibility courses and ArchiveWP with coupon code ', 'accessibility-checker' ) . '<code>GAAD2026</code>.<br />';
×
NEW
297
                        $message .= esc_html__( 'Limited-time offer • Ends May 22nd', 'accessibility-checker' ) . '</p><p>';
×
NEW
298
                        $message .= '<a class="button button-primary" href="' . esc_url( edac_link_wrapper( 'https://equalizedigital.com/archivewp/?discount=GAAD2026&pro=true', 'admin-notice', 'GAAD2026-archivewp', false ) ) . '">' . esc_html__( 'View ArchiveWP Pricing', 'accessibility-checker' ) . '</a> ';
×
NEW
299
                        $message .= '<a class="button button-primary" href="' . esc_url( edac_link_wrapper( 'https://equalizedigital.com/learn/courses/?discount=GAAD2026&pro=true', 'admin-notice', 'GAAD2026-courses', false ) ) . '">' . esc_html__( 'View Course Pricing', 'accessibility-checker' ) . '</a></p>';
×
300
                } else {
301
                        $message .= esc_html__( '3 days only: Save 15% when you upgrade to Accessibility Checker Pro with coupon code ', 'accessibility-checker' ) . '<code>GAAD2026</code>.<br />';
6✔
302
                        $message .= esc_html__( 'Limited-time offer • Ends May 22nd', 'accessibility-checker' ) . '</p><p>';
6✔
303
                        $message .= '<a class="button button-primary" href="' . esc_url( edac_link_wrapper( 'https://equalizedigital.com/accessibility-checker/pricing/?discount=GAAD2026', 'admin-notice', 'GAAD2026-pricing', false ) ) . '">' . esc_html__( 'Upgrade Now', 'accessibility-checker' ) . '</a></p>';
6✔
304
                }
305

306
                $message .= '</div>';
6✔
307

308
                return $message;
6✔
309
        }
310

311
        /**
312
         * GAAD Sale Notice Ajax
313
         *
314
         * @return void
315
         *
316
         *  - '-1' means that nonce could not be verified
317
         *  - '-2' means that update option wasn't successful
318
         */
319
        public function edac_gaad_sale_notice_ajax() {
320

UNCOV
321
                if ( ! isset( $_REQUEST['nonce'] ) || ! wp_verify_nonce( sanitize_key( $_REQUEST['nonce'] ), 'ajax-nonce' ) ) {
×
322
                        $error = new \WP_Error( '-1', __( 'Permission Denied', 'accessibility-checker' ) );
×
323
                        wp_send_json_error( $error );
×
324
                }
325

NEW
326
                $results = update_option( 'edac_gaad_sale_notice_dismiss_2026', true );
×
327
                // Delete old option keys if they exist.
NEW
328
                delete_option( 'edac_gaad_notice_dismiss_2026' );
×
329
                delete_option( 'edac_gaad_notice_dismiss_2025' );
×
330
                delete_option( 'edac_gaad_notice_dismiss_2024' );
×
331
                delete_option( 'edac_gaad_notice_dismiss' );
×
332

333
                if ( ! $results ) {
×
UNCOV
334
                        $error = new \WP_Error( '-2', __( 'Update option wasn\'t successful', 'accessibility-checker' ) );
×
335
                        wp_send_json_error( $error );
×
336

337
                }
338

339
                wp_send_json_success( wp_json_encode( $results ) );
×
340
        }
341

342
        /**
343
         * Review Admin Notice
344
         *
345
         * @return void
346
         */
347
        public function edac_review_notice() {
348

349
                $option             = 'edac_review_notice';
×
350
                $edac_review_notice = get_option( $option );
×
351

352
                // exit if option is set to stop.
353
                if ( 'stop' === $edac_review_notice ) {
×
354
                        return;
×
355
                }
356

357
                $transient                   = 'edac_review_notice_reminder';
×
358
                $edac_review_notice_reminder = get_transient( $transient );
×
359

360
                // first time if notice has never been shown wait 14 days.
361
                if ( false === $edac_review_notice_reminder && empty( $edac_review_notice ) ) {
×
362
                        // if option isn't set and plugin has been active for more than 14 days show notice. This is for current users.
363
                        if ( edac_days_active() > 14 ) {
×
364
                                update_option( $option, 'play' );
×
365
                        } else {
366
                                // if plugin has been active less than 14 days set transient for 14 days.
367
                                set_transient( $transient, true, 14 * DAY_IN_SECONDS );
×
368
                                // set option to pause.
369
                                update_option( $option, 'pause' );
×
370
                        }
371
                }
372

373
                // if transient has expired and option is set to pause update option to play.
374
                if ( false === $edac_review_notice_reminder && 'pause' === $edac_review_notice ) {
×
375
                        update_option( $option, 'play' );
×
376
                }
377

378
                // if option is not set to play exit.
379
                if ( get_option( $option ) !== 'play' ) {
×
380
                        return;
×
381
                }
382

383
                ?>
384
                <div class="notice notice-info edac-review-notice">
×
385
                        <p>
×
386
                                <?php esc_html_e( "Hello! Thank you for using Accessibility Checker as part of your accessibility toolkit. Since you've been using it for a while, would you please write a 5-star review of Accessibility Checker in the WordPress plugin directory? This will help increase our visibility so more people can learn about the importance of web accessibility. Thanks so much!", 'accessibility-checker' ); ?>
×
387
                        </p>
×
388
                        <p>
×
389
                                <button class="edac-review-notice-review button button-small button-primary"><?php esc_html_e( 'Write A Review', 'accessibility-checker' ); ?></button>
×
390
                                <button class="edac-review-notice-remind button button-small"><?php esc_html_e( 'Remind Me In Two Weeks', 'accessibility-checker' ); ?></button>
×
391
                                <button class="edac-review-notice-dismiss button button-small"><?php esc_html_e( 'Never Ask Again', 'accessibility-checker' ); ?></button>
×
392
                        </p>
393
                </div>
394
                <?php
395
        }
396

397
        /**
398
         * Review Admin Notice Ajax
399
         *
400
         * @return void
401
         *
402
         *  - '-1' means that nonce could not be varified
403
         *  - '-2' means that the review action value was not specified
404
         *  - '-3' means that update option wasn't successful
405
         */
406
        public function edac_review_notice_ajax() {
407

408
                // nonce security.
409
                if ( ! isset( $_REQUEST['nonce'] ) || ! wp_verify_nonce( sanitize_key( $_REQUEST['nonce'] ), 'ajax-nonce' ) ) {
×
410

411
                        $error = new \WP_Error( '-1', __( 'Permission Denied', 'accessibility-checker' ) );
×
412
                        wp_send_json_error( $error );
×
413

414
                }
415

416
                if ( ! isset( $_REQUEST['review_action'] ) ) {
×
417

418
                        $error = new \WP_Error( '-2', __( 'The review action value was not set', 'accessibility-checker' ) );
×
419
                        wp_send_json_error( $error );
×
420

421
                }
422

423
                $review_action = sanitize_text_field( wp_unslash( $_REQUEST['review_action'] ) );
×
424
                $results       = update_option( 'edac_review_notice', $review_action );
×
425
                if ( ! $results ) {
×
426
                        $results = get_option( 'edac_review_notice' ) === $review_action;
×
427
                }
428

429
                if ( 'pause' === $review_action ) {
×
430
                        set_transient( 'edac_review_notice_reminder', true, 14 * DAY_IN_SECONDS );
×
431
                }
432

433
                if ( ! $results ) {
×
434

435
                        $error = new \WP_Error( '-3', __( 'Update option wasn\'t successful', 'accessibility-checker' ) );
×
436
                        wp_send_json_error( $error );
×
437

438
                }
439

440
                wp_send_json_success( wp_json_encode( $results ) );
×
441
        }
442

443

444
        /**
445
         * Save a transient to indicate that the fixes settings have been updated.
446
         *
447
         * @param string $option    The option name that was saved.
448
         *
449
         * @return void
450
         */
451
        public function set_fixes_transient_on_save( $option ) {
452
                if ( ! class_exists( 'EqualizeDigital\AccessibilityChecker\Fixes\FixesManager' ) ) {
×
453
                        return;
×
454
                }
455
                $fixes_settings = FixesManager::get_instance()->get_fixes_settings();
×
456
                $options_keys   = [];
×
457
                foreach ( $fixes_settings as $fix ) {
×
458
                        $options_keys = array_merge( $options_keys, array_keys( $fix['fields'] ) );
×
459
                }
460
                if ( in_array( $option, $options_keys, true ) ) {
×
461
                        // Set a custom transient as a flag.
462
                        set_transient( 'edac_fixes_settings_saved', true, 60 );
×
463
                }
464
        }
465
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc