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

equalizedigital / accessibility-checker / 22024231170

14 Feb 2026 09:04PM UTC coverage: 57.263%. First build
22024231170

Pull #1413

github

web-flow
Merge c07f857fb into 1cbcfbf9b
Pull Request #1413: Fix loopback helper warning on DNS AAAA failures

27 of 81 new or added lines in 24 files covered. (33.33%)

4147 of 7242 relevant lines covered (57.26%)

3.47 hits per line

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

17.32
/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' ) ) {
2✔
NEW
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
        }
14✔
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();
×
69
                $screens        = [
×
70
                        'toplevel_page_accessibility_checker',
×
71
                        'accessibility-checker_page_accessibility_checker_issues',
×
72
                        'accessibility-checker_page_accessibility_checker_ignored',
×
73
                        'accessibility-checker_page_accessibility_checker_settings',
×
74
                ];
×
75

76
                /**
77
                 * Filter the screens where admin notices should be removed.
78
                 *
79
                 * @since 1.14.0
80
                 *
81
                 * @param array $screens The screens where admin notices should be removed.
82
                 */
83
                $screens = apply_filters( 'edac_filter_remove_admin_notices_screens', $screens );
×
84

85
                if ( in_array( $current_screen->id, $screens, true ) ) {
×
86
                        remove_all_actions( 'admin_notices' );
×
87
                        remove_all_actions( 'all_admin_notices' );
×
88
                }
89
        }
90

91
        /**
92
         * Black Friday Admin Notice
93
         *
94
         * @return void
95
         */
96
        public function edac_black_friday_notice() {
97

98
                // Check if Accessibility Checker Pro is active.
99
                if ( defined( 'EDACP_VERSION' ) ) {
×
100
                        return;
×
101
                }
102

103
                // Check if the notice has been dismissed.
104
                if ( absint( get_option( 'edac_black_friday_2025_notice_dismiss', 0 ) ) ) {
×
105
                        return;
×
106
                }
107

108
                // Show from November 24 to December 03.
109
                $current_date = date_i18n( 'Ymd' ); // Use date_i18n for localization.
×
110
                $start_date   = '20251124';
×
111
                $end_date     = '20251203';
×
112

113
                if ( $current_date >= $start_date && $current_date <= $end_date ) {
×
114

115
                        // Get the promotional message from a separate function/file.
116
                        $message = $this->edac_get_black_friday_message();
×
117

118
                        // Output the message with appropriate sanitization.
119
                        echo wp_kses_post( $message );
×
120

121
                }
122
        }
123

124
        /**
125
         * Get Black Friday Promo Message
126
         *
127
         * @return string
128
         */
129
        public function edac_get_black_friday_message() {
130

131
                // Construct the promotional message.
132
                $message  = '<div class="edac_black_friday_notice notice notice-info is-dismissible">';
4✔
133
                $message .= '<p><strong>' . esc_html__( '🎉 Black Friday special! 🎉', 'accessibility-checker' ) . '</strong><br />';
4✔
134
                $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✔
135
                $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✔
136
                $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✔
137
                $message .= '</div>';
4✔
138

139
                return $message;
4✔
140
        }
141

142
        /**
143
         * Black Friday Admin Notice Ajax
144
         *
145
         * @return void
146
         *
147
         *  - '-1' means that nonce could not be varified
148
         *  - '-2' means that update option wasn't successful
149
         */
150
        public function edac_black_friday_notice_ajax() {
151

152
                // nonce security.
153
                if ( ! isset( $_REQUEST['nonce'] ) || ! wp_verify_nonce( sanitize_key( $_REQUEST['nonce'] ), 'ajax-nonce' ) ) {
×
154

155
                        $error = new \WP_Error( '-1', __( 'Permission Denied', 'accessibility-checker' ) );
×
156
                        wp_send_json_error( $error );
×
157

158
                }
159

160
                $results = update_option( 'edac_black_friday_2025_notice_dismiss', true );
×
161
                // Delete old options if they exist.
162
                delete_option( 'edac_black_friday_2024_notice_dismiss' );
×
163
                delete_option( 'edac_black_friday_2023_notice_dismiss' );
×
164

165
                if ( ! $results ) {
×
166

167
                        $error = new \WP_Error( '-2', __( 'Update option wasn\'t successful', 'accessibility-checker' ) );
×
168
                        wp_send_json_error( $error );
×
169

170
                }
171

172
                wp_send_json_success( wp_json_encode( $results ) );
×
173
        }
174

175
        /**
176
         * GAAD Notice
177
         *
178
         * @return void
179
         */
180
        public function edac_gaad_notice() {
181

182
                // Define constants for start and end dates.
183
                define( 'EDAC_GAAD_NOTICE_START_DATE', '2025-05-13' );
×
184
                define( 'EDAC_GAAD_NOTICE_END_DATE', '2025-05-21' );
×
185

186
                // Check if Accessibility Checker Pro is active.
187
                if ( defined( 'EDACP_VERSION' ) ) {
×
188
                        return;
×
189
                }
190

191
                // Get the value of the 'edac_gaad_notice_dismiss' option and sanitize it.
192
                $dismissed = absint( get_option( 'edac_gaad_notice_dismiss_2025', 0 ) );
×
193

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

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

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

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

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

211
                }
212
        }
213

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

221
                // Construct the promotional message.
222
                $message  = '<div class="edac_gaad_notice notice notice-info is-dismissible">';
4✔
223
                $message .= '<p><strong>' . esc_html__( '🎉 Get 25% off Accessibility Checker Pro in honor of Global Accessibility Awareness Day! 🎉', 'accessibility-checker' ) . '</strong><br />';
4✔
224
                $message .= esc_html__( 'Use coupon code GAAD25 from May 13th-May 21st to get access to full-site scanning and other pro features at a special discount. Not sure if upgrading is right for you?', 'accessibility-checker' ) . '<br />';
4✔
225
                $message .= '<a class="button button-primary" href="' . esc_url( edac_link_wrapper( 'https://equalizedigital.com/contact/', 'admin-notice', 'GAAD25-presale', false ) ) . '">' . esc_html__( 'Ask a Pre-Sale Question', 'accessibility-checker' ) . '</a> ';
4✔
226
                $message .= '<a class="button button-primary" href="' . esc_url( edac_link_wrapper( 'https://equalizedigital.com/accessibility-checker/pricing/', 'admin-notice', 'GAAD25-pricing', false ) ) . '">' . esc_html__( 'Upgrade Now', 'accessibility-checker' ) . '</a></p>';
4✔
227
                $message .= '</div>';
4✔
228

229
                return $message;
4✔
230
        }
231

232
        /**
233
         * GAAD Admin Notice Ajax
234
         *
235
         * @return void
236
         *
237
         *  - '-1' means that nonce could not be varified
238
         *  - '-2' means that update option wasn't successful
239
         */
240
        public function edac_gaad_notice_ajax() {
241

242
                // nonce security.
243
                if ( ! isset( $_REQUEST['nonce'] ) || ! wp_verify_nonce( sanitize_key( $_REQUEST['nonce'] ), 'ajax-nonce' ) ) {
×
244

245
                        $error = new \WP_Error( '-1', __( 'Permission Denied', 'accessibility-checker' ) );
×
246
                        wp_send_json_error( $error );
×
247

248
                }
249

250
                $results = update_option( 'edac_gaad_notice_dismiss_2025', true );
×
251
                // Delete old meta keys if they exist.
252
                delete_option( 'edac_gaad_notice_dismiss_2024' );
×
253
                delete_option( 'edac_gaad_notice_dismiss' );
×
254

255
                if ( ! $results ) {
×
256

257
                        $error = new \WP_Error( '-2', __( 'Update option wasn\'t successful', 'accessibility-checker' ) );
×
258
                        wp_send_json_error( $error );
×
259

260
                }
261

262
                wp_send_json_success( wp_json_encode( $results ) );
×
263
        }
264

265
        /**
266
         * Review Admin Notice
267
         *
268
         * @return void
269
         */
270
        public function edac_review_notice() {
271

272
                $option             = 'edac_review_notice';
×
273
                $edac_review_notice = get_option( $option );
×
274

275
                // exit if option is set to stop.
276
                if ( 'stop' === $edac_review_notice ) {
×
277
                        return;
×
278
                }
279

280
                $transient                   = 'edac_review_notice_reminder';
×
281
                $edac_review_notice_reminder = get_transient( $transient );
×
282

283
                // first time if notice has never been shown wait 14 days.
284
                if ( false === $edac_review_notice_reminder && empty( $edac_review_notice ) ) {
×
285
                        // if option isn't set and plugin has been active for more than 14 days show notice. This is for current users.
286
                        if ( edac_days_active() > 14 ) {
×
287
                                update_option( $option, 'play' );
×
288
                        } else {
289
                                // if plugin has been active less than 14 days set transient for 14 days.
290
                                set_transient( $transient, true, 14 * DAY_IN_SECONDS );
×
291
                                // set option to pause.
292
                                update_option( $option, 'pause' );
×
293
                        }
294
                }
295

296
                // if transient has expired and option is set to pause update option to play.
297
                if ( false === $edac_review_notice_reminder && 'pause' === $edac_review_notice ) {
×
298
                        update_option( $option, 'play' );
×
299
                }
300

301
                // if option is not set to play exit.
302
                if ( get_option( $option ) !== 'play' ) {
×
303
                        return;
×
304
                }
305

306
                ?>
307
                <div class="notice notice-info edac-review-notice">
×
308
                        <p>
×
309
                                <?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' ); ?>
×
310
                        </p>
×
311
                        <p>
×
312
                                <button class="edac-review-notice-review button button-small button-primary"><?php esc_html_e( 'Write A Review', 'accessibility-checker' ); ?></button>
×
313
                                <button class="edac-review-notice-remind button button-small"><?php esc_html_e( 'Remind Me In Two Weeks', 'accessibility-checker' ); ?></button>
×
314
                                <button class="edac-review-notice-dismiss button button-small"><?php esc_html_e( 'Never Ask Again', 'accessibility-checker' ); ?></button>
×
315
                        </p>
316
                </div>
317
                <?php
318
        }
319

320
        /**
321
         * Review Admin Notice Ajax
322
         *
323
         * @return void
324
         *
325
         *  - '-1' means that nonce could not be varified
326
         *  - '-2' means that the review action value was not specified
327
         *  - '-3' means that update option wasn't successful
328
         */
329
        public function edac_review_notice_ajax() {
330

331
                // nonce security.
332
                if ( ! isset( $_REQUEST['nonce'] ) || ! wp_verify_nonce( sanitize_key( $_REQUEST['nonce'] ), 'ajax-nonce' ) ) {
×
333

334
                        $error = new \WP_Error( '-1', __( 'Permission Denied', 'accessibility-checker' ) );
×
335
                        wp_send_json_error( $error );
×
336

337
                }
338

339
                if ( ! isset( $_REQUEST['review_action'] ) ) {
×
340

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

344
                }
345

346
                $review_action = sanitize_text_field( wp_unslash( $_REQUEST['review_action'] ) );
×
347
                $results       = update_option( 'edac_review_notice', $review_action );
×
348
                if ( ! $results ) {
×
349
                        $results = get_option( 'edac_review_notice' ) === $review_action;
×
350
                }
351

352
                if ( 'pause' === $review_action ) {
×
353
                        set_transient( 'edac_review_notice_reminder', true, 14 * DAY_IN_SECONDS );
×
354
                }
355

356
                if ( ! $results ) {
×
357

358
                        $error = new \WP_Error( '-3', __( 'Update option wasn\'t successful', 'accessibility-checker' ) );
×
359
                        wp_send_json_error( $error );
×
360

361
                }
362

363
                wp_send_json_success( wp_json_encode( $results ) );
×
364
        }
365

366

367
        /**
368
         * Save a transient to indicate that the fixes settings have been updated.
369
         *
370
         * @param string $option    The option name that was saved.
371
         *
372
         * @return void
373
         */
374
        public function set_fixes_transient_on_save( $option ) {
375
                if ( ! class_exists( 'EqualizeDigital\AccessibilityChecker\Fixes\FixesManager' ) ) {
×
376
                        return;
×
377
                }
378
                $fixes_settings = FixesManager::get_instance()->get_fixes_settings();
×
379
                $options_keys   = [];
×
380
                foreach ( $fixes_settings as $fix ) {
×
381
                        $options_keys = array_merge( $options_keys, array_keys( $fix['fields'] ) );
×
382
                }
383
                if ( in_array( $option, $options_keys, true ) ) {
×
384
                        // Set a custom transient as a flag.
385
                        set_transient( 'edac_fixes_settings_saved', true, 60 );
×
386
                }
387
        }
388
}
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