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

equalizedigital / accessibility-checker / 24890141022

24 Apr 2026 12:44PM UTC coverage: 57.715% (+0.2%) from 57.472%
24890141022

push

github

web-flow
Merge pull request #1671 from equalizedigital/release/1.40.0

[Backport] Release v1.40.0

20 of 63 new or added lines in 4 files covered. (31.75%)

2 existing lines in 1 file now uncovered.

5476 of 9488 relevant lines covered (57.72%)

4.51 hits per line

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

19.15
/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' ) ) {
4✔
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
        }
20✔
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 );
2✔
35
                add_action( 'in_admin_header', [ $this, 'hook_notices' ], 1001 );
2✔
36
                // Ajax handlers for notices.
37
                add_action( 'wp_ajax_edac_black_friday_notice_ajax', [ $this, 'edac_black_friday_notice_ajax' ] );
2✔
38
                add_action( 'wp_ajax_edac_gaad_notice_ajax', [ $this, 'edac_gaad_notice_ajax' ] );
2✔
39
                add_action( 'wp_ajax_edac_review_notice_ajax', [ $this, 'edac_review_notice_ajax' ] );
2✔
40
                // Save fixes transient on save.
41
                add_action( 'updated_option', [ $this, 'set_fixes_transient_on_save' ] );
2✔
42
        }
43

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

56
                add_action( 'admin_notices', [ $this, 'edac_black_friday_notice' ] );
×
57
                add_action( 'admin_notices', [ $this, 'edac_gaad_notice' ] );
×
58
                add_action( 'admin_notices', [ $this, 'edac_review_notice' ] );
×
59
        }
60

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

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

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

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

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

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

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

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

119
                if ( $current_date >= $start_date && $current_date <= $end_date ) {
×
120

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

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

127
                }
128
        }
129

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

137
                // Construct the promotional message.
138
                $message  = '<div class="edac_black_friday_notice notice notice-info is-dismissible">';
4✔
139
                $message .= '<p><strong>' . esc_html__( '🎉 Black Friday special! 🎉', 'accessibility-checker' ) . '</strong><br />';
4✔
140
                $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✔
141
                $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✔
142
                $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✔
143
                $message .= '</div>';
4✔
144

145
                return $message;
4✔
146
        }
147

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

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

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

164
                }
165

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

171
                if ( ! $results ) {
×
172

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

176
                }
177

178
                wp_send_json_success( wp_json_encode( $results ) );
×
179
        }
180

181
        /**
182
         * GAAD Notice
183
         *
184
         * @return void
185
         */
186
        public function edac_gaad_notice() {
187

188
                // Define constants for start and end dates.
189
                // The banner appears on May 13 (one week early) to build anticipation; the actual sale runs May 20-22.
NEW
190
                define( 'EDAC_GAAD_NOTICE_START_DATE', '2026-05-13' );
×
NEW
191
                define( 'EDAC_GAAD_NOTICE_END_DATE', '2026-05-22' );
×
192

193
                // Get the value of the 'edac_gaad_notice_dismiss' option and sanitize it.
NEW
194
                $dismissed = absint( get_option( 'edac_gaad_notice_dismiss_2026', 0 ) );
×
195

196
                // Check if the notice has been dismissed.
197
                if ( $dismissed ) {
×
198
                        return;
×
199
                }
200

201
                // Get the current date in the 'Y-m-d' format.
202
                $current_date = gmdate( 'Y-m-d' );
×
203

204
                // Check if the current date is within the specified range.
205
                if ( $current_date >= EDAC_GAAD_NOTICE_START_DATE && $current_date <= EDAC_GAAD_NOTICE_END_DATE ) {
×
206

207
                        // Get the promotional message from a separate function/file.
208
                        $message = $this->edac_get_gaad_promo_message();
×
209

210
                        // Output the message with appropriate sanitization.
211
                        echo wp_kses_post( $message );
×
212

213
                }
214
        }
215

216
        /**
217
         * Get GAAD Promo Message
218
         *
219
         * @return string
220
         */
221
        public function edac_get_gaad_promo_message() {
222

223
                // Construct the promotional message.
224
                $message = '<div class="edac_gaad_notice notice notice-info is-dismissible">';
8✔
225

226
                $message .= '<p><strong>' . esc_html__( '⚡️ Global Accessibility Awareness Day Flash Sale', 'accessibility-checker' ) . '</strong><br />';
8✔
227

228
                if ( defined( 'EDACP_VERSION' ) && edac_is_pro() ) {
8✔
229
                        // Message for users who already have Accessibility Checker Pro active (valid license).
NEW
230
                        $message .= sprintf(
×
231
                                /* translators: 1: opening anchor tag for accessibility courses link, 2: closing anchor tag, 3: opening anchor tag for ArchiveWP link, 4: closing anchor tag */
NEW
232
                                esc_html__( '3 days only: Save 15%% on %1$saccessibility courses%2$s and Equalize Digital\'s %3$sArchiveWP plugin%4$s. Go further with accessibility.', 'accessibility-checker' ),
×
NEW
233
                                '<a href="' . esc_url( edac_link_wrapper( 'https://equalizedigital.com/learn/courses/', 'admin-notice', 'GAAD2026-courses', false ) ) . '">',
×
NEW
234
                                '</a>',
×
NEW
235
                                '<a href="' . esc_url( edac_link_wrapper( 'https://equalizedigital.com/archivewp/', 'admin-notice', 'GAAD2026-archivewp', false ) ) . '">',
×
NEW
236
                                '</a>'
×
NEW
237
                        ) . '<br />';
×
NEW
238
                        $message .= esc_html__( 'Limited-time offer • May 20–22 • Use coupon code ', 'accessibility-checker' ) . '<code>GAAD2026</code><br />';
×
NEW
239
                        $message .= '<a class="button button-primary" href="' . esc_url( edac_link_wrapper( 'https://equalizedigital.com/', 'admin-notice', 'GAAD2026-grab-deal', false ) ) . '">' . esc_html__( 'Grab the Deal Before It Ends', 'accessibility-checker' ) . '</a></p>';
×
240
                } else {
241
                        // Message for users who do not have Accessibility Checker Pro active.
242
                        $message .= esc_html__( '3 days only: Save 15% when you upgrade to Accessibility Checker Pro with coupon code', 'accessibility-checker' );
8✔
243
                        $message .= '<code>GAAD2026</code>.</br>';
8✔
244
                        $message .= esc_html__( 'Limited-time offer • May 20–22', 'accessibility-checker' ) . '<br />';
8✔
245
                        $message .= '<a class="button button-primary" href="' . esc_url( edac_link_wrapper( 'https://equalizedigital.com/accessibility-checker/pricing/', 'admin-notice', 'GAAD2026-pricing', false ) ) . '">' . esc_html__( 'Upgrade Now', 'accessibility-checker' ) . '</a></p>';
8✔
246
                }
247

248
                $message .= '</div>';
8✔
249

250
                return $message;
8✔
251
        }
252

253
        /**
254
         * GAAD Admin Notice Ajax
255
         *
256
         * @return void
257
         *
258
         *  - '-1' means that nonce could not be varified
259
         *  - '-2' means that update option wasn't successful
260
         */
261
        public function edac_gaad_notice_ajax() {
262

263
                // nonce security.
264
                if ( ! isset( $_REQUEST['nonce'] ) || ! wp_verify_nonce( sanitize_key( $_REQUEST['nonce'] ), 'ajax-nonce' ) ) {
×
265

266
                        $error = new \WP_Error( '-1', __( 'Permission Denied', 'accessibility-checker' ) );
×
267
                        wp_send_json_error( $error );
×
268

269
                }
270

NEW
271
                $results = update_option( 'edac_gaad_notice_dismiss_2026', true );
×
272
                // Delete old meta keys if they exist.
NEW
273
                delete_option( 'edac_gaad_notice_dismiss_2025' );
×
274
                delete_option( 'edac_gaad_notice_dismiss_2024' );
×
275
                delete_option( 'edac_gaad_notice_dismiss' );
×
276

277
                if ( ! $results ) {
×
278

279
                        $error = new \WP_Error( '-2', __( 'Update option wasn\'t successful', 'accessibility-checker' ) );
×
280
                        wp_send_json_error( $error );
×
281

282
                }
283

284
                wp_send_json_success( wp_json_encode( $results ) );
×
285
        }
286

287
        /**
288
         * Review Admin Notice
289
         *
290
         * @return void
291
         */
292
        public function edac_review_notice() {
293

294
                $option             = 'edac_review_notice';
×
295
                $edac_review_notice = get_option( $option );
×
296

297
                // exit if option is set to stop.
298
                if ( 'stop' === $edac_review_notice ) {
×
299
                        return;
×
300
                }
301

302
                $transient                   = 'edac_review_notice_reminder';
×
303
                $edac_review_notice_reminder = get_transient( $transient );
×
304

305
                // first time if notice has never been shown wait 14 days.
306
                if ( false === $edac_review_notice_reminder && empty( $edac_review_notice ) ) {
×
307
                        // if option isn't set and plugin has been active for more than 14 days show notice. This is for current users.
308
                        if ( edac_days_active() > 14 ) {
×
309
                                update_option( $option, 'play' );
×
310
                        } else {
311
                                // if plugin has been active less than 14 days set transient for 14 days.
312
                                set_transient( $transient, true, 14 * DAY_IN_SECONDS );
×
313
                                // set option to pause.
314
                                update_option( $option, 'pause' );
×
315
                        }
316
                }
317

318
                // if transient has expired and option is set to pause update option to play.
319
                if ( false === $edac_review_notice_reminder && 'pause' === $edac_review_notice ) {
×
320
                        update_option( $option, 'play' );
×
321
                }
322

323
                // if option is not set to play exit.
324
                if ( get_option( $option ) !== 'play' ) {
×
325
                        return;
×
326
                }
327

328
                ?>
329
                <div class="notice notice-info edac-review-notice">
×
330
                        <p>
×
331
                                <?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' ); ?>
×
332
                        </p>
×
333
                        <p>
×
334
                                <button class="edac-review-notice-review button button-small button-primary"><?php esc_html_e( 'Write A Review', 'accessibility-checker' ); ?></button>
×
335
                                <button class="edac-review-notice-remind button button-small"><?php esc_html_e( 'Remind Me In Two Weeks', 'accessibility-checker' ); ?></button>
×
336
                                <button class="edac-review-notice-dismiss button button-small"><?php esc_html_e( 'Never Ask Again', 'accessibility-checker' ); ?></button>
×
337
                        </p>
338
                </div>
339
                <?php
340
        }
341

342
        /**
343
         * Review Admin Notice Ajax
344
         *
345
         * @return void
346
         *
347
         *  - '-1' means that nonce could not be varified
348
         *  - '-2' means that the review action value was not specified
349
         *  - '-3' means that update option wasn't successful
350
         */
351
        public function edac_review_notice_ajax() {
352

353
                // nonce security.
354
                if ( ! isset( $_REQUEST['nonce'] ) || ! wp_verify_nonce( sanitize_key( $_REQUEST['nonce'] ), 'ajax-nonce' ) ) {
×
355

356
                        $error = new \WP_Error( '-1', __( 'Permission Denied', 'accessibility-checker' ) );
×
357
                        wp_send_json_error( $error );
×
358

359
                }
360

361
                if ( ! isset( $_REQUEST['review_action'] ) ) {
×
362

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

366
                }
367

368
                $review_action = sanitize_text_field( wp_unslash( $_REQUEST['review_action'] ) );
×
369
                $results       = update_option( 'edac_review_notice', $review_action );
×
370
                if ( ! $results ) {
×
371
                        $results = get_option( 'edac_review_notice' ) === $review_action;
×
372
                }
373

374
                if ( 'pause' === $review_action ) {
×
375
                        set_transient( 'edac_review_notice_reminder', true, 14 * DAY_IN_SECONDS );
×
376
                }
377

378
                if ( ! $results ) {
×
379

380
                        $error = new \WP_Error( '-3', __( 'Update option wasn\'t successful', 'accessibility-checker' ) );
×
381
                        wp_send_json_error( $error );
×
382

383
                }
384

385
                wp_send_json_success( wp_json_encode( $results ) );
×
386
        }
387

388

389
        /**
390
         * Save a transient to indicate that the fixes settings have been updated.
391
         *
392
         * @param string $option    The option name that was saved.
393
         *
394
         * @return void
395
         */
396
        public function set_fixes_transient_on_save( $option ) {
397
                if ( ! class_exists( 'EqualizeDigital\AccessibilityChecker\Fixes\FixesManager' ) ) {
×
398
                        return;
×
399
                }
400
                $fixes_settings = FixesManager::get_instance()->get_fixes_settings();
×
401
                $options_keys   = [];
×
402
                foreach ( $fixes_settings as $fix ) {
×
403
                        $options_keys = array_merge( $options_keys, array_keys( $fix['fields'] ) );
×
404
                }
405
                if ( in_array( $option, $options_keys, true ) ) {
×
406
                        // Set a custom transient as a flag.
407
                        set_transient( 'edac_fixes_settings_saved', true, 60 );
×
408
                }
409
        }
410
}
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