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

equalizedigital / accessibility-checker / 17471903338

04 Sep 2025 05:29PM UTC coverage: 59.267% (+0.01%) from 59.256%
17471903338

push

github

web-flow
Merge pull request #1220 from equalizedigital/william/tweak/some-request-handlers-and-callbacks

Use a specifically named ajax request for frontend highlighter

4 of 68 new or added lines in 4 files covered. (5.88%)

4 existing lines in 2 files now uncovered.

4122 of 6955 relevant lines covered (59.27%)

3.52 hits per line

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

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

8
namespace EDAC\Admin;
9

10
use EDAC\Admin\OptIn\Email_Opt_In;
11
use EDAC\Inc\Summary_Generator;
12
use EqualizeDigital\AccessibilityChecker\Admin\AdminPage\FixesPage;
13
use EqualizeDigital\AccessibilityChecker\Fixes\FixesManager;
14

15
/**
16
 * Class that handles ajax requests.
17
 */
18
class Ajax {
19

20
        /**
21
         * Constructor function for the class.
22
         */
23
        public function __construct() {
24
        }
×
25

26
        /**
27
         * Initialize hooks.
28
         *
29
         * @return void
30
         */
31
        public function init_hooks() {
32
                add_action( 'wp_ajax_edac_summary_ajax', [ $this, 'summary' ] );
×
33
                add_action( 'wp_ajax_edac_details_ajax', [ $this, 'details' ] );
×
34
                add_action( 'wp_ajax_edac_readability_ajax', [ $this, 'readability' ] );
×
35
                add_action( 'wp_ajax_edac_insert_ignore_data', [ $this, 'add_ignore' ] );
×
36
                add_action( 'wp_ajax_edac_update_simplified_summary', [ $this, 'simplified_summary' ] );
×
37
                add_action( 'wp_ajax_edac_dismiss_welcome_cta_ajax', [ $this, 'dismiss_welcome_cta' ] );
×
38
                add_action( 'wp_ajax_edac_dismiss_dashboard_cta_ajax', [ $this, 'dismiss_dashboard_cta' ] );
×
39
                ( new Email_Opt_In() )->register_ajax_handlers();
×
40
        }
41

42
        /**
43
         * Summary Ajax
44
         *
45
         * @return void
46
         *
47
         *  - '-1' means that nonce could not be varified
48
         *  - '-2' means that the post ID was not specified
49
         *  - '-3' means that there isn't any summary data to return
50
         *  - '-5' means that the user does not have permission to view this information for this post
51
         */
52
        public function summary() {
53

54
                // nonce security.
55
                if ( ! isset( $_REQUEST['nonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_REQUEST['nonce'] ) ), 'ajax-nonce' ) ) {
×
NEW
56
                        wp_send_json_error( new \WP_Error( '-1', __( 'Permission Denied', 'accessibility-checker' ) ) );
×
57
                }
58

59
                if ( ! isset( $_REQUEST['post_id'] ) ) {
×
NEW
60
                        wp_send_json_error( new \WP_Error( '-2', __( 'The post ID was not set', 'accessibility-checker' ) ) );
×
61
                }
62

NEW
63
                if ( ! current_user_can( 'edit_post', (int) $_REQUEST['post_id'] ) ) {
×
NEW
64
                        wp_send_json_error( new \WP_Error( '-5', __( 'You do not have permission to view this information for this post.', 'accessibility-checker' ) ) );
×
65
                }
66

67
                $html            = [];
×
68
                $html['content'] = '';
×
69

UNCOV
70
                $post_id                   = (int) $_REQUEST['post_id'];
×
71
                $summary                   = ( new Summary_Generator( $post_id ) )->generate_summary();
×
72
                $simplified_summary_text   = '';
×
73
                $simplified_summary_prompt = get_option( 'edac_simplified_summary_prompt' );
×
74
                $simplified_summary        = get_post_meta( $post_id, '_edac_simplified_summary', true ) ? get_post_meta( $post_id, '_edac_simplified_summary', true ) : '';
×
75

76
                $simplified_summary_grade = 0;
×
77
                if ( class_exists( 'DaveChild\TextStatistics\TextStatistics' ) ) {
×
78
                        $text_statistics          = new \DaveChild\TextStatistics\TextStatistics();
×
79
                        $simplified_summary_grade = (int) floor( $text_statistics->fleschKincaidGradeLevel( $simplified_summary ) );
×
80
                }
81
                $simplified_summary_grade_failed = ( $simplified_summary_grade > 9 ) ? true : false;
×
82

83
                $simplified_summary_text = esc_html__( 'A Simplified summary has not been included for this content.', 'accessibility-checker' );
×
84
                if ( 'none' !== $simplified_summary_prompt ) {
×
85
                        if ( $summary['content_grade'] <= 9 ) {
×
86
                                $simplified_summary_text = esc_html__( 'Your content has a reading level at or below 9th grade and does not require a simplified summary.', 'accessibility-checker' );
×
87
                        } elseif ( $summary['simplified_summary'] ) {
×
88
                                if ( $simplified_summary_grade_failed ) {
×
89
                                        $simplified_summary_text = esc_html__( 'The reading level of the simplified summary is too high.', 'accessibility-checker' );
×
90
                                } else {
91
                                        $simplified_summary_text = esc_html__( 'A simplified summary has been included for this content.', 'accessibility-checker' );
×
92
                                }
93
                        }
94
                }
95

96
                $html['content'] .= '<ul class="edac-summary-grid">';
×
97

98
                        $html['content'] .= '<li class="edac-summary-total" aria-label="' . $summary['passed_tests'] . '% Passed Tests">';
×
99

100
                                $html['content'] .= '<div class="edac-summary-total-progress-circle ' . ( ( $summary['passed_tests'] > 50 ) ? ' over50' : '' ) . '">
×
101
                                        <div class="edac-summary-total-progress-circle-label">
102
                                                <div class="edac-panel-number">' . $summary['passed_tests'] . '%</div>
×
103
                                                <div class="edac-panel-number-label">Passed Tests<sup><a href="#edac-summary-disclaimer" aria-label="About passed tests.">*</a></sup></div>
104
                                        </div>
105
                                        <div class="left-half-clipper">
106
                                                <div class="first50-bar"></div>
107
                                                <div class="value-bar" style="transform: rotate(' . $summary['passed_tests'] * 3.6 . 'deg);"></div>
×
108
                                        </div>
109
                                </div>';
×
110

111
                                $html['content'] .= '<div class="edac-summary-total-mobile">
×
112
                                        <div class="edac-panel-number">' . $summary['passed_tests'] . '%</div>
×
113
                                        <div class="edac-panel-number-label">Passed Tests<sup><a href="#edac-summary-disclaimer" aria-label="About passed tests.">*</a></sup></div>
114
                                        <div class="edac-summary-total-mobile-bar"><span style="width:' . ( $summary['passed_tests'] ) . '%;"></span></div>
×
115
                                </div>';
×
116

117
                        $html['content'] .= '</li>';
×
118

119
                        // if this is a virtual page, we don't show the readability section.
120
                        $is_virtual_page = edac_is_virtual_page( $post_id );
×
121

122
                        $html['content'] .= '
×
123
                                ' . edac_generate_summary_stat(
×
124
                                'edac-summary-errors',
×
125
                                $summary['errors'],
×
126
                                /* translators: %s: Number of errors */
NEW
127
                                sprintf( _n( '%s Error', '%s Errors', $summary['errors'], 'accessibility-checker' ), $summary['errors'] )
×
128
                        ) . '
×
129
                                ' . edac_generate_summary_stat(
×
130
                                'edac-summary-contrast',
×
131
                                $summary['contrast_errors'],
×
132
                                /* translators: %s: Number of contrast errors */
NEW
133
                                sprintf( _n( '%s Contrast Error', '%s Contrast Errors', $summary['contrast_errors'], 'accessibility-checker' ), $summary['contrast_errors'] )
×
134
                        ) . '
×
135
                                ' . edac_generate_summary_stat(
×
136
                                'edac-summary-warnings',
×
137
                                $summary['warnings'],
×
138
                                /* translators: %s: Number of warnings */
NEW
139
                                sprintf( _n( '%s Warning', '%s Warnings', $summary['warnings'], 'accessibility-checker' ), $summary['warnings'] )
×
140
                        ) . '
×
141
                                ' . edac_generate_summary_stat(
×
142
                                'edac-summary-ignored',
×
143
                                $summary['ignored'],
×
144
                                /* translators: %s: Number of ignored items */
NEW
145
                                sprintf( _n( '%s Ignored Item', '%s Ignored Items', $summary['ignored'], 'accessibility-checker' ), $summary['ignored'] )
×
146
                        ) . '
×
147

148
                </ul>
149
                <div class="edac-summary-readability" ' . ( $is_virtual_page ? 'style="display: none;"' : '' ) . '>
×
150
                        <div class="edac-summary-readability-level">
151
                                <div><img src="' . EDAC_PLUGIN_URL . 'assets/images/readability-icon-navy.png" alt="" width="54"></div>
×
152
                                <div class="edac-panel-number' . ( ( (int) $summary['content_grade'] <= 9 || 'none' === $simplified_summary_prompt ) ? ' passed-text-color' : ' failed-text-color' ) . '">
×
153
                                        ' . $summary['readability'] . '
×
154
                                </div>
155
                                <div class="edac-panel-number-label' . ( ( (int) $summary['readability'] <= 9 || 'none' === $simplified_summary_prompt ) ? ' passed-text-color' : ' failed-text-color' ) . '">Reading <br />Level</div>
×
156
                        </div>
157
                        <div class="edac-summary-readability-summary">
158
                                <div class="edac-summary-readability-summary-icon' . ( ( ( 'none' === $simplified_summary_prompt || $summary['simplified_summary'] || (int) $summary['content_grade'] <= 9 ) && ! $simplified_summary_grade_failed ) ? ' active' : '' ) . '"></div>
×
159
                                <div class="edac-summary-readability-summary-text' . ( ( ( 'none' === $simplified_summary_prompt || $summary['simplified_summary'] || (int) $summary['content_grade'] <= 9 ) && ! $simplified_summary_grade_failed ) ? ' active' : '' ) . '">' . $simplified_summary_text . '</div>
×
160
                        </div>
161
                </div>
162
                ';
×
163

164
                $html['content'] .= '<div class="edac-summary-disclaimer" id="edac-summary-disclaimer"><small>' . PHP_EOL;
×
165
                $html['content'] .= sprintf(
×
166
                        '* True accessibility requires manual testing in addition to automated scans. %1$sLearn how to manually test for accessibility%2$s.',
×
167
                        '<a href="' . esc_url(
×
168
                                edac_generate_link_type(
×
169
                                        [
×
170
                                                'utm_campaign' => 'dashboard-widget',
×
171
                                                'utm_content'  => 'how-to-manually-check',
×
172
                                        ],
×
173
                                        'help',
×
174
                                        [ 'help_id' => 4280 ]
×
175
                                )
×
176
                        ) . '">',
×
177
                        '</a>'
×
178
                ) . PHP_EOL;
×
179
                $html['content'] .= '</small></div>' . PHP_EOL;
×
180

181
                if ( ! $html ) {
×
NEW
182
                        wp_send_json_error( new \WP_Error( '-3', __( 'No summary to return', 'accessibility-checker' ) ) );
×
183
                }
184

185
                wp_send_json_success( wp_json_encode( $html ) );
×
186
        }
187

188
        /**
189
         * Details Ajax
190
         *
191
         * @return void
192
         *
193
         *  - '-1' means that nonce could not be varified
194
         *  - '-2' means that the post ID was not specified
195
         *  - '-3' means that the table name is not valid
196
         *  - '-4' means that there isn't any details to return
197
         *  - '-5' means that the user does not have permission to view this information for this post
198
         */
199
        public function details() {
200

UNCOV
201
                if ( ! isset( $_REQUEST['nonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_REQUEST['nonce'] ) ), 'ajax-nonce' ) ) {
×
NEW
202
                        wp_send_json_error( new \WP_Error( '-1', __( 'Permission Denied', 'accessibility-checker' ) ) );
×
203
                }
204

205
                if ( ! isset( $_REQUEST['post_id'] ) ) {
×
NEW
206
                        wp_send_json_error( new \WP_Error( '-2', __( 'The post ID was not set', 'accessibility-checker' ) ) );
×
207
                }
208

NEW
209
                if ( ! current_user_can( 'edit_post', (int) $_REQUEST['post_id'] ) ) {
×
NEW
210
                        wp_send_json_error( new \WP_Error( '-5', __( 'You do not have permission to view this information for this post.', 'accessibility-checker' ) ) );
×
211
                }
212

213
                $html = '';
×
214
                global $wpdb;
×
215
                $table_name = edac_get_valid_table_name( $wpdb->prefix . 'accessibility_checker' );
×
216
                $postid     = (int) $_REQUEST['post_id'];
×
217
                $siteid     = get_current_blog_id();
×
218

219
                // Send error if table name is not valid.
220
                if ( ! $table_name ) {
×
NEW
221
                        wp_send_json_error( new \WP_Error( '-3', __( 'Invalid table name', 'accessibility-checker' ) ) );
×
222
                }
223

224
                $rules = edac_register_rules();
×
225
                if ( $rules ) {
×
226

227
                        // if ANWW is active remove link_blank for details meta box.
228
                        if ( defined( 'ANWW_VERSION' ) ) {
×
229
                                $rules = edac_remove_element_with_value( $rules, 'slug', 'link_blank' );
×
230
                        }
231

232
                        // separate rule types.
233
                        $passed_rules  = [];
×
234
                        $error_rules   = edac_remove_element_with_value( $rules, 'rule_type', 'warning' );
×
235
                        $warning_rules = edac_remove_element_with_value( $rules, 'rule_type', 'error' );
×
236

237
                        // add count, unset passed error rules and add passed rules to array.
238
                        if ( $error_rules ) {
×
239
                                foreach ( $error_rules as $key => $error_rule ) {
×
240
                                        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Using direct query for interacting with custom database, safe variable used for table name, caching not required for one time operation.
241
                                        $count = count( $wpdb->get_results( $wpdb->prepare( 'SELECT id, postid, object, ruletype, ignre, ignre_user, ignre_date, ignre_comment FROM %i where postid = %d and rule = %s and siteid = %d and ignre = %d', $table_name, $postid, $error_rule['slug'], $siteid, 0 ), ARRAY_A ) );
×
242
                                        if ( $count ) {
×
243
                                                $error_rules[ $key ]['count'] = $count;
×
244
                                        } else {
245
                                                $error_rule['count'] = 0;
×
246
                                                $passed_rules[]      = $error_rule;
×
247
                                                unset( $error_rules[ $key ] );
×
248
                                        }
249
                                }
250
                        }
251

252
                        // add count, unset passed warning rules and add passed rules to array.
253
                        if ( $warning_rules ) {
×
254
                                foreach ( $warning_rules as $key => $error_rule ) {
×
255
                                        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Using direct query for interacting with custom database, safe variable used for table name, caching not required for one time operation.
256
                                        $count = count( $wpdb->get_results( $wpdb->prepare( 'SELECT id, postid, object, ruletype, ignre, ignre_user, ignre_date, ignre_comment FROM %i where postid = %d and rule = %s and siteid = %d and ignre = %d', $table_name, $postid, $error_rule['slug'], $siteid, 0 ), ARRAY_A ) );
×
257
                                        if ( $count ) {
×
258
                                                $warning_rules[ $key ]['count'] = $count;
×
259
                                        } else {
260
                                                $error_rule['count'] = 0;
×
261
                                                $passed_rules[]      = $error_rule;
×
262
                                                unset( $warning_rules[ $key ] );
×
263
                                        }
264
                                }
265
                        }
266
                }
267

268
                // sort error rules by count.
269
                usort(
×
270
                        $error_rules,
×
271
                        function ( $a, $b ) {
×
272

273
                                return strcmp( $b['count'], $a['count'] );
×
274
                        }
×
275
                );
×
276

277
                // sort warning rules by count.
278
                usort(
×
279
                        $warning_rules,
×
280
                        function ( $a, $b ) {
×
281

282
                                return strcmp( $b['count'], $a['count'] );
×
283
                        }
×
284
                );
×
285

286
                // sort passed rules array by title.
287
                usort(
×
288
                        $passed_rules,
×
289
                        function ( $a, $b ) {
×
290

291
                                return strcmp( $b['title'], $a['title'] );
×
292
                        }
×
293
                );
×
294

295
                // merge rule arrays together.
296
                $rules = array_merge( $error_rules, $warning_rules, $passed_rules );
×
297

298
                if ( $rules ) {
×
299
                        /**
300
                         * Filters if a user can ignore issues.
301
                         *
302
                         * @since 1.4.0
303
                         *
304
                         * @allowed bool True if allowed, false if not
305
                         */
306
                        $ignore_permission = apply_filters( 'edac_ignore_permission', true );
×
307

308
                        foreach ( $rules as $rule ) {
×
309
                                // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Using direct query for interacting with custom database, safe variable used for table name, caching not required for one time operation.
310
                                $results        = $wpdb->get_results( $wpdb->prepare( 'SELECT id, postid, object, ruletype, ignre, ignre_user, ignre_date, ignre_comment, ignre_global, landmark, landmark_selector FROM %i where postid = %d and rule = %s and siteid = %d', $table_name, $postid, $rule['slug'], $siteid ), ARRAY_A );
×
311
                                $count_classes  = ( 'error' === $rule['rule_type'] ) ? ' edac-details-rule-count-error' : ' edac-details-rule-count-warning';
×
312
                                $count_classes .= ( 0 !== $rule['count'] ) ? ' active' : '';
×
313

314
                                $count_ignored = 0;
×
315
                                $ignores       = array_column( $results, 'ignre' );
×
316
                                if ( $ignores ) {
×
317
                                        foreach ( $ignores as $ignore ) {
×
318
                                                if ( true === (bool) $ignore ) {
×
319
                                                        ++$count_ignored;
×
320
                                                }
321
                                        }
322
                                }
323

324
                                // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Using direct query for interacting with custom database, safe variable used for table name, caching not required for one time operation.
325
                                $expand_rule = count( $wpdb->get_results( $wpdb->prepare( 'SELECT id FROM %i where postid = %d and rule = %s and siteid = %d', $table_name, $postid, $rule['slug'], $siteid ), ARRAY_A ) );
×
326

327
                                $tool_tip_link = edac_link_wrapper( $rule['info_url'], 'frontend-highlighter', $rule['slug'], false );
×
328

329
                                $html .= '<div class="edac-details-rule">';
×
330

331
                                $html .= '<div class="edac-details-rule-title">';
×
332

333
                                $html .= '<h3>';
×
334
                                $html .= '<span class="edac-details-rule-count' . $count_classes . '">' . $rule['count'] . '</span> ';
×
335
                                $html .= esc_html( $rule['title'] );
×
336
                                if ( $count_ignored > 0 ) {
×
337
                                        $html .= '<span class="edac-details-rule-count-ignore">' . $count_ignored . ' Ignored Items</span>';
×
338
                                }
339
                                $html .= '</h3>';
×
340
                                $html .= '<a href="' . $tool_tip_link . '" class="edac-details-rule-information" target="_blank" aria-label="Read documentation for ' . esc_html( $rule['title'] ) . '. ' . esc_attr__( 'Opens in a new window.', 'accessibility-checker' ) . '"><span class="dashicons dashicons-info"></span></a>';
×
341
                                $html .= ( $expand_rule ) ? '<button class="edac-details-rule-title-arrow" aria-expanded="false" aria-controls="edac-details-rule-records-' . $rule['slug'] . '" aria-label="Expand issues for ' . esc_html( $rule['title'] ) . '"><i class="dashicons dashicons-arrow-down-alt2"></i></button>' : '';
×
342

343
                                $html .= '</div>';
×
344

345
                                if ( $results ) {
×
346

347
                                        $html .= '<div id="edac-details-rule-records-' . $rule['slug'] . '" class="edac-details-rule-records">';
×
348

349
                                        $fixes_for_item = [];
×
350
                                        if ( isset( $rule['fixes'] ) && current_user_can( apply_filters( 'edac_filter_settings_capability', 'manage_options' ) ) ) {
×
351
                                                foreach ( $rule['fixes'] as $fix_slug ) {
×
352
                                                        $fixes_for_item[] = FixesManager::get_instance()->get_fix( $fix_slug );
×
353
                                                }
354

355
                                                $controls_id = 'edac-fix-modal-' . $rule['slug'] . '__' . implode( '__', $rule['fixes'] );
×
356
                                                ob_start();
×
357
                                                // NOTE: This is markup to be cloned into a thickbox modal. It gets cloned from the inner div.
358
                                                ?>
359
                                                <div style="display:none">
×
360
                                                        <div id="<?php echo esc_attr( $controls_id ); ?>" class="edac-details-fix-settings fix-settings--container">
×
361
                                                                <div class="setting-row fix-settings--container" data-fix="<?php echo esc_attr( $controls_id ); ?>">
×
362
                                                                        <?php
363
                                                                        printf(
×
364
                                                                                '<p class="modal-opening-message">%s <span class="hide-in-editor">%s</span></p>',
×
365
                                                                                esc_html__( 'These settings enable global fixes across your entire site.', 'accessibility-checker' ),
×
366
                                                                                esc_html__( 'Pages may need to be resaved or a full site scan run to see fixes reflected in reports.', 'accessibility-checker' )
×
367
                                                                        )
×
368
                                                                        ?>
×
369
                                                                        <div class="edac-fix-settings">
×
370
                                                                                <?php
371
                                                                                foreach ( $fixes_for_item as $index => $fix ) :
×
372
                                                                                        ?>
373
                                                                                        <div class="edac-fix-settings--fields">
×
374
                                                                                                <fieldset>
×
375
                                                                                                        <div class="title">
×
376
                                                                                                                <legend>
×
377
                                                                                                                        <h2 class="edac-fix-settings--title"><?php echo esc_html( $fix->get_nicename() ); ?></h2>
×
378
                                                                                                                </legend>
379
                                                                                                        </div>
380
                                                                                                        <?php
381
                                                                                                        foreach ( $fix->get_fields_array() as $name => $field ) {
×
382
                                                                                                                $field['name']     = $name;
×
383
                                                                                                                $field['location'] = 'details-panel';
×
384
                                                                                                                FixesPage::{$field['type']}( $field );
×
385
                                                                                                        }
386
                                                                                                        ?>
387
                                                                                                </fieldset>
×
388
                                                                                                <?php
×
389
                                                                                                // Output the save button only in the last group.
390
                                                                                                if ( count( $fixes_for_item ) === $index + 1 ) :
×
391
                                                                                                        ?>
392
                                                                                                        <div class="edac-fix-settings--action-row">
×
393
                                                                                                                <button role="button" class="button button-primary edac-fix-settings--button--save">
×
394
                                                                                                                        <?php esc_html_e( 'Save', 'accessibility-checker' ); ?>
×
395
                                                                                                                </button>
×
396
                                                                                                                <span class="edac-fix-settings--notice-slot" aria-live="polite" role="alert"></span>
×
397
                                                                                                        </div>
×
398
                                                                                                        <?php
×
399
                                                                                                endif;
400
                                                                                                ?>
401
                                                                                        </div>
×
402
                                                                                <?php endforeach; ?>
×
403
                                                                        </div>
×
404
                                                                </div>
×
405
                                                        </div>
×
406
                                                </div>
×
407
                                                <?php
×
408
                                                $html .= ob_get_clean();
×
409
                                        }
410

411

412

413
                                        $html .=
×
414
                                                '<div class="edac-details-rule-records-labels">
×
415
                                                        <div class="edac-details-rule-records-labels-label" aria-hidden="true">
416
                                                                ' . esc_html__( 'Affected Code', 'accessibility-checker' ) . '
×
417
                                                        </div>
418
                                                        <div class="edac-details-rule-records-labels-label" aria-hidden="true">
419
                                                                Image
420
                                                        </div>
421
                                                        <div class="edac-details-rule-records-labels-label" aria-hidden="true">
422
                                                                Landmark
423
                                                        </div>
424
                                                        <div class="edac-details-rule-records-labels-label" aria-hidden="true">
425
                                                                Actions
426
                                                        </div>
427
                                                </div>';
×
428

429
                                        foreach ( $results as $row ) {
×
430

431
                                                $id                      = (int) $row['id'];
×
432
                                                $ignore                  = (int) $row['ignre'];
×
433
                                                $ignore_class            = $ignore ? ' active' : '';
×
434
                                                $ignore_label            = $ignore ? 'Ignored' : 'Ignore';
×
435
                                                $ignore_user             = (int) $row['ignre_user'];
×
436
                                                $ignore_user_info        = get_userdata( $ignore_user );
×
437
                                                $ignore_username         = is_object( $ignore_user_info ) ? '<strong>Username:</strong> ' . $ignore_user_info->user_login : '';
×
438
                                                $ignore_date             = ( $row['ignre_date'] && '0000-00-00 00:00:00' !== $row['ignre_date'] ) ? '<strong>Date:</strong> ' . gmdate( 'F j, Y g:i a', strtotime( esc_html( $row['ignre_date'] ) ) ) : '';
×
439
                                                $ignore_comment          = esc_html( $row['ignre_comment'] );
×
440
                                                $ignore_action           = $ignore ? 'disable' : 'enable';
×
441
                                                $ignore_type             = $rule['rule_type'];
×
442
                                                $ignore_submit_label     = $ignore ? 'Stop Ignoring' : 'Ignore This ' . $ignore_type;
×
443
                                                $ignore_comment_disabled = $ignore ? 'disabled' : '';
×
444
                                                $ignore_global           = (int) $row['ignre_global'];
×
445

446
                                                // check for images and svgs in object code.
447
                                                $media      = edac_parse_html_for_media( $row['object'] );
×
448
                                                $object_img = $media['img'];
×
449
                                                $object_svg = $media['svg'];
×
450

451
                                                $html .= '<h4 class="screen-reader-text">Issue ID ' . $id . '</h4>';
×
452

453
                                                $html .= '<div id="edac-details-rule-records-record-' . $id . '" class="edac-details-rule-records-record">';
×
454

455
                                                $html .= '<div class="edac-details-rule-records-record-cell edac-details-rule-records-record-object">';
×
456

457
                                                $html .= '<code>' . esc_html( $row['object'] ) . '</code>';
×
458

459
                                                $html .= '</div>';
×
460

461
                                                $html .= '<div class="edac-details-rule-records-record-cell edac-details-rule-records-record-image">';
×
462

463
                                                if ( $object_img ) {
×
464
                                                        $html .= '<img src="' . $object_img . '" alt="image for issue ' . $id . '" />';
×
465
                                                } elseif ( $object_svg ) {
×
466
                                                        $html .= $object_svg;
×
467
                                                }
468

469
                                                $html .= '</div>';
×
470

471
                                                $html .= '<div class="edac-details-rule-records-record-cell edac-details-rule-records-record-landmark">';
×
472

473
                                                $landmark          = isset( $row['landmark'] ) ? $row['landmark'] : '';
×
474
                                                $landmark_selector = isset( $row['landmark_selector'] ) ? $row['landmark_selector'] : '';
×
475

476
                                                $html .= edac_generate_landmark_link( $landmark, $landmark_selector, $postid );
×
477

478
                                                $html .= '</div>';
×
479

480
                                                $html .= '<div class="edac-details-rule-records-record-cell edac-details-rule-records-record-actions">';
×
481

482
                                                if ( ! isset( $rule['viewable'] ) || $rule['viewable'] ) {
×
483

484
                                                        $post_view_link = apply_filters(
×
485
                                                                'edac_get_origin_url_for_virtual_page',
×
486
                                                                get_the_permalink( $postid ),
×
487
                                                                $postid
×
488
                                                        );
×
489

490
                                                        $url = add_query_arg(
×
491
                                                                [
×
492
                                                                        'edac'       => $id,
×
493
                                                                        'edac_nonce' => wp_create_nonce( 'edac_highlight' ),
×
494
                                                                ],
×
495
                                                                $post_view_link
×
496
                                                        );
×
497

498
                                                        // Translators: %d is the issue ID.
499
                                                        $aria_label = sprintf( __( 'View Issue ID %d on website, opens a new window', 'accessibility-checker' ), $id );
×
500
                                                        $html      .= '<a href="' . $url . '" class="edac-details-rule-records-record-actions-highlight-front" target="_blank" aria-label="' . esc_attr( $aria_label ) . '" ><span class="dashicons dashicons-welcome-view-site"></span>' . __( 'View on page', 'accessibility-checker' ) . '</a>';
×
501
                                                }
502

503
                                                if ( true === $ignore_permission ) {
×
504
                                                        $html .= '<button class="edac-details-rule-records-record-actions-ignore' . $ignore_class . '" aria-expanded="false" aria-controls="edac-details-rule-records-record-ignore-' . $row['id'] . '">' . EDAC_SVG_IGNORE_ICON . '<span class="edac-details-rule-records-record-actions-ignore-label">' . $ignore_label . '</span></button>';
×
505
                                                }
506

507
                                                if ( ! empty( $fixes_for_item ) ) {
×
508
                                                        $html .= sprintf(
×
509
                                                                '<button class="edac-details-rule-records-record-actions-fix"
×
510
                                                                        aria-haspopup="true"
511
                                                                        aria-controls="%1$s"
512
                                                                        aria-label="%2$s"
513
                                                                        type="button"
514
                                                                >
515
                                                                        <span class="dashicons dashicons-admin-tools"></span>
516
                                                                        %3$s
517
                                                                </button>',
×
518
                                                                esc_attr( $controls_id ),
×
519
                                                                esc_attr( __( 'Fix: ', 'accessibility-checker' ) . $fixes_for_item[0]->get_nicename() ),
×
520
                                                                esc_html__( 'Fix', 'accessibility-checker' )
×
521
                                                        );
×
522
                                                }
523

524
                                                $html .= '</div>';
×
525

526
                                                $html .= '<div id="edac-details-rule-records-record-ignore-' . $row['id'] . '" class="edac-details-rule-records-record-ignore">';
×
527

528
                                                $html .= '<div class="edac-details-rule-records-record-ignore-info">';
×
529
                                                $html .= '<span class="edac-details-rule-records-record-ignore-info-user">' . $ignore_username . '</span>';
×
530

531
                                                $html .= ' <span class="edac-details-rule-records-record-ignore-info-date">' . $ignore_date . '</span>';
×
532
                                                $html .= '</div>';
×
533

534
                                                $html .= ( true === $ignore_permission || ! empty( $ignore_comment ) ) ? '<label for="edac-details-rule-records-record-ignore-comment-' . $id . '">Comment</label><br>' : '';
×
535
                                                $html .= ( true === $ignore_permission || ! empty( $ignore_comment ) ) ? '<textarea rows="4" class="edac-details-rule-records-record-ignore-comment" id="edac-details-rule-records-record-ignore-comment-' . $id . '" ' . $ignore_comment_disabled . '>' . $ignore_comment . '</textarea>' : '';
×
536

537
                                                if ( $ignore_global ) {
×
538
                                                        $html .= ( true === $ignore_permission ) ? '<a href="' . admin_url( 'admin.php?page=accessibility_checker_ignored&tab=global' ) . '" class="edac-details-rule-records-record-ignore-global">Manage Globally Ignored</a>' : '';
×
539
                                                } else {
540
                                                        $html .= ( true === $ignore_permission ) ? '<button class="edac-details-rule-records-record-ignore-submit" data-id=' . $id . ' data-action=' . $ignore_action . ' data-type=' . $ignore_type . '>' . EDAC_SVG_IGNORE_ICON . ' <span class="edac-details-rule-records-record-ignore-submit-label">' . $ignore_submit_label . '<span></button>' : '';
×
541
                                                }
542

543
                                                $html .= ( false === $ignore_permission && false === $ignore ) ? __( 'Your user account doesn\'t have permission to ignore this issue.', 'accessibility-checker' ) : '';
×
544

545
                                                $html .= '</div>';
×
546

547
                                                $html .= '</div>';
×
548

549
                                        }
550

551
                                        $html .= '</div>';
×
552

553
                                }
554

555
                                $html .= '</div>';
×
556
                        }
557
                }
558

559
                if ( ! $html ) {
×
NEW
560
                        wp_send_json_error( new \WP_Error( '-4', __( 'No details to return', 'accessibility-checker' ) ) );
×
561
                }
562

563
                wp_send_json_success( wp_json_encode( $html ) );
×
564
        }
565

566
        /**
567
         * Readability Ajax
568
         *
569
         * @return void
570
         *
571
         *  - '-1' means that nonce could not be varified
572
         *  - '-2' means that the post ID was not specified
573
         *  - '-3' means that there isn't any readability data to return
574
         *  - '-5' means that the user does not have permission to view this information for this post
575
         */
576
        public function readability() {
577

UNCOV
578
                if ( ! isset( $_REQUEST['nonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_REQUEST['nonce'] ) ), 'ajax-nonce' ) ) {
×
NEW
579
                        wp_send_json_error( new \WP_Error( '-1', __( 'Permission Denied', 'accessibility-checker' ) ) );
×
580
                }
581

582
                if ( ! isset( $_REQUEST['post_id'] ) ) {
×
NEW
583
                        wp_send_json_error( new \WP_Error( '-2', __( 'The post ID was not set', 'accessibility-checker' ) ) );
×
584
                }
585

NEW
586
                if ( ! current_user_can( 'edit_post', (int) $_REQUEST['post_id'] ) ) {
×
NEW
587
                        wp_send_json_error( new \WP_Error( '-5', __( 'You do not have permission to view this information for this post.', 'accessibility-checker' ) ) );
×
588
                }
589

590
                $post_id                     = (int) $_REQUEST['post_id'];
×
591
                $html                        = '';
×
592
                $simplified_summary          = get_post_meta( $post_id, '_edac_simplified_summary', true ) ? get_post_meta( $post_id, '_edac_simplified_summary', true ) : '';
×
593
                $simplified_summary_position = get_option( 'edac_simplified_summary_position', $default = false );
×
594
                $content_post                = get_post( $post_id );
×
595
                $content                     = $content_post->post_content;
×
596
                $content                     = apply_filters( 'the_content', $content );
×
597

598
                /**
599
                 * Filter the content used for reading grade readability analysis.
600
                 *
601
                 * @since 1.4.0
602
                 *
603
                 * @param string $content The content to be filtered.
604
                 * @param int    $post_id The post ID.
605
                 */
606
                $content = apply_filters( 'edac_filter_readability_content', $content, $post_id );
×
607
                $content = wp_filter_nohtml_kses( $content );
×
608
                $content = str_replace( ']]>', ']]&gt;', $content );
×
609

610
                // get readability metadata and determine if a simplified summary is required.
611
                $edac_summary           = get_post_meta( $post_id, '_edac_summary', true );
×
612
                $post_grade_readability = ( isset( $edac_summary['readability'] ) ) ? $edac_summary['readability'] : 0;
×
613
                $post_grade             = (int) filter_var( $post_grade_readability, FILTER_SANITIZE_NUMBER_INT );
×
614
                $post_grade_failed      = ( $post_grade < 9 ) ? false : true;
×
615

616
                $simplified_summary_grade = 0;
×
617
                if ( class_exists( 'DaveChild\TextStatistics\TextStatistics' ) ) {
×
618
                        $text_statistics          = new \DaveChild\TextStatistics\TextStatistics();
×
619
                        $simplified_summary_grade = (int) floor( $text_statistics->fleschKincaidGradeLevel( $simplified_summary ) );
×
620
                }
621

622
                $simplified_summary_grade_failed = ( $simplified_summary_grade > 9 ) ? true : false;
×
623
                $simplified_summary_prompt       = get_option( 'edac_simplified_summary_prompt' );
×
624

625
                $html .= '<ul class="edac-readability-list">';
×
626

627
                $html .= '<li class="edac-readability-list-item edac-readability-grade-level">
×
628
                <span class="edac-readability-list-item-icon dashicons ' . ( ( $post_grade_failed || 0 === $post_grade ) ? 'dashicons-no-alt' : 'dashicons-saved' ) . '"></span>
×
629
                <p class="edac-readability-list-item-title">Post Reading Grade Level: <strong class="' . ( ( $post_grade_failed || 0 === $post_grade ) ? 'failed-text-color' : 'passed-text-color' ) . '">' . ( ( 0 === $post_grade ) ? 'None' : $post_grade_readability ) . '</strong><br /></p>';
×
630
                if ( $post_grade_failed ) {
×
631
                        $html .= '<p class="edac-readability-list-item-description">Your post has a reading level higher than 9th grade. Web Content Accessibility Guidelines (WCAG) at the AAA level require a simplified summary of your post that is 9th grade or below.</p>';
×
632
                } elseif ( 0 === $post_grade ) {
×
633
                        $html .= '<p class="edac-readability-list-item-description">Your post does not contain enough content to calculate its reading level.</p>';
×
634
                } else {
635
                        $html .= '<p class="edac-readability-list-item-description">A simplified summary is not necessary when content reading level is 9th grade or below. Choose when to prompt for a simplified summary on the settings page.</p>';
×
636
                }
637
                $html .= '</li>';
×
638

639
                if ( $post_grade_failed ) {
×
640

641
                        if ( $simplified_summary && 'none' !== $simplified_summary_prompt ) {
×
642
                                $html .= '<li class="edac-readability-list-item edac-readability-summary-grade-level">
×
643
                                        <span class="edac-readability-list-item-icon dashicons ' . ( ( $simplified_summary_grade_failed ) ? 'dashicons-no-alt' : 'dashicons-saved' ) . '"></span>
×
644
                                        <p class="edac-readability-list-item-title">Simplified Summary Reading Grade Level: <strong class="' . ( ( $simplified_summary_grade_failed ) ? 'failed-text-color' : 'passed-text-color' ) . '">' . edac_ordinal( $simplified_summary_grade ) . '</strong></p>
×
645
                                        <p class="edac-readability-list-item-description">Your simplified summary has a reading level ' . ( ( $simplified_summary_grade_failed ) ? 'higher' : 'lower' ) . ' than 9th grade.</p>
×
646
                                </li>';
×
647
                        }
648

649
                        if ( 'none' === $simplified_summary_prompt ) {
×
650

651
                                $html .=
×
652
                                        '<li class="edac-readability-list-item edac-readability-summary-position">
×
653
                                        <span class="edac-readability-list-item-icon"><img src="' . plugin_dir_url( __FILE__ ) . 'assets/images/warning-icon-yellow.png" alt="" width="22"></span>
×
654
                                        <p class="edac-readability-list-item-title">Simplified summary is not being automatically inserted into the content.</p>
655
                                                <p class="edac-readability-list-item-description">Your Prompt for Simplified Summary is set to "never." If you would like the simplified summary to be displayed automatically, you can change this on the <a href="' . get_bloginfo( 'url' ) . '/wp-admin/admin.php?page=accessibility_checker_settings">settings page</a>.</p>
×
656
                                </li>';
×
657

658
                        } elseif ( 'none' !== $simplified_summary_position ) {
×
659

660
                                $html .=
×
661
                                        '<li class="edac-readability-list-item edac-readability-summary-position">
×
662
                                        <span class="edac-readability-list-item-icon dashicons dashicons-saved"></span>
663
                                        <p class="edac-readability-list-item-title">Simplified summary is being automatically inserted <strong>' . $simplified_summary_position . ' the content</strong>.</p>
×
664
                                                <p class="edac-readability-list-item-description">Set where the Simplified Summary is inserted into the content on the <a href="' . get_bloginfo( 'url' ) . '/wp-admin/admin.php?page=accessibility_checker_settings">settings page</a>.</p>
×
665
                                </li>';
×
666

667
                        } else {
668

669
                                $html .=
×
670
                                        '<li class="edac-readability-list-item edac-readability-summary-position">
×
671
                                        <span class="edac-readability-list-item-icon"><img src="' . plugin_dir_url( __FILE__ ) . 'assets/images/warning-icon-yellow.png" alt="" width="22"></span>
×
672
                                        <p class="edac-readability-list-item-title">Simplified summary is not being automatically inserted into the content.</p>
673
                                                <p class="edac-readability-list-item-description">Your Simplified Summary location is set to "manually" which requires a function be added to your page template. If you would like the simplified summary to be displayed automatically, you can change this on the <a href="' . get_bloginfo( 'url' ) . '/wp-admin/admin.php?page=accessibility_checker_settings">settings page</a>.</p>
×
674
                                </li>';
×
675

676
                        }
677
                }
678

679
                $html .= '</ul>';
×
680

681
                if ( ( $post_grade_failed || 'always' === $simplified_summary_prompt ) && ( 'none' !== $simplified_summary_prompt ) ) {
×
682
                        $html .=
×
683
                                '</form>
×
684
                        <form action="/" class="edac-readability-simplified-summary">
685
                                <label for="edac-readability-text">Simplified Summary</label>
686
                                <textarea name="" id="edac-readability-text" cols="30" rows="10">' . $simplified_summary . '</textarea>
×
687
                                <input type="submit" value="Submit">
688
                        </form>';
×
689
                }
690

691
                $html .= '<span class="dashicons dashicons-info"></span><a href="' . esc_url( edac_link_wrapper( 'https://a11ychecker.com/help3265', 'wordpress-general', 'content-analysis', false ) ) . '" target="_blank">Learn more about improving readability and simplified summary requirements</a>';
×
692

693
                if ( ! $html ) {
×
NEW
694
                        wp_send_json_error( new \WP_Error( '-3', __( 'No readability data to return', 'accessibility-checker' ) ) );
×
695
                }
696

697
                wp_send_json_success( wp_json_encode( $html ) );
×
698
        }
699

700
        /**
701
         * Insert ignore data into database
702
         *
703
         * @return void
704
         *
705
         *  - '-1' means that nonce could not be varified
706
         *  - '-2' means that there isn't any ignore data to return
707
         */
708
        public function add_ignore() {
709

710
                // nonce security.
711
                if ( ! isset( $_REQUEST['nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['nonce'] ) ), 'ajax-nonce' ) ) {
×
NEW
712
                        wp_send_json_error( new \WP_Error( '-1', __( 'Permission Denied', 'accessibility-checker' ) ) );
×
713
                }
714

715
                global $wpdb;
×
NEW
716
                $table_name           = $wpdb->prefix . 'accessibility_checker';
×
NEW
717
                $raw_ids              = isset( $_REQUEST['ids'] ) ? (array) wp_unslash( $_REQUEST['ids'] ) : []; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Sanitization handled below.
×
NEW
718
                $ids                  = array_map(
×
719
                        function ( $value ) {
×
720
                                return (int) $value;
×
721
                        },
×
722
                        $raw_ids
×
723
                ); // Sanitizing array elements to integers.
×
NEW
724
                $action               = isset( $_REQUEST['ignore_action'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['ignore_action'] ) ) : '';
×
NEW
725
                $type                 = isset( $_REQUEST['ignore_type'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['ignore_type'] ) ) : '';
×
NEW
726
                $siteid               = get_current_blog_id();
×
NEW
727
                $ignre                = ( 'enable' === $action ) ? 1 : 0;
×
NEW
728
                $ignre_user           = ( 'enable' === $action ) ? get_current_user_id() : null;
×
NEW
729
                $ignre_user_info      = ( 'enable' === $action ) ? get_userdata( $ignre_user ) : '';
×
NEW
730
                $ignre_username       = ( 'enable' === $action ) ? $ignre_user_info->user_login : '';
×
NEW
731
                $ignre_date           = ( 'enable' === $action ) ? gmdate( 'Y-m-d H:i:s' ) : null;
×
NEW
732
                $ignre_date_formatted = ( 'enable' === $action ) ? gmdate( 'F j, Y g:i a', strtotime( $ignre_date ) ) : '';
×
NEW
733
                $ignre_comment        = ( 'enable' === $action && isset( $_REQUEST['comment'] ) ) ? sanitize_textarea_field( wp_unslash( $_REQUEST['comment'] ) ) : null;
×
NEW
734
                $ignore_global        = ( 'enable' === $action && isset( $_REQUEST['ignore_global'] ) ) ? sanitize_textarea_field( wp_unslash( $_REQUEST['ignore_global'] ) ) : 0;
×
735

736
                // If largeBatch is set and 'true', we need to perform an update using the 'object'
737
                // instead of IDs. It is a much less efficient query than by IDs - but many IDs run
738
                // into request size limits which caused this to not function at all.
739
                if ( isset( $_REQUEST['largeBatch'] ) && 'true' === $_REQUEST['largeBatch'] ) {
×
740
                        // Get the 'object' from the first id.
741
                        $first_id = $ids[0];
×
742
                        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- We need to get the latest value, not a cached value.
743
                        $object = $wpdb->get_var( $wpdb->prepare( 'SELECT object FROM %i WHERE id = %d', $table_name, $first_id ) );
×
744

745
                        if ( ! $object ) {
×
NEW
746
                                wp_send_json_error( new \WP_Error( '-2', __( 'No ignore data to return', 'accessibility-checker' ) ) );
×
747
                        }
748
                        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Safe variable used for table name, caching not required for one time operation.
749
                        $wpdb->query( $wpdb->prepare( 'UPDATE %i SET ignre = %d, ignre_user = %d, ignre_date = %s, ignre_comment = %s, ignre_global = %d WHERE siteid = %d and object = %s', $table_name, $ignre, $ignre_user, $ignre_date, $ignre_comment, $ignore_global, $siteid, $object ) );
×
750
                } else {
751
                        // For small batches of IDs, we can just loop through.
752
                        foreach ( $ids as $id ) {
×
753
                                // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Safe variable used for table name, caching not required for one time operation.
754
                                $wpdb->query( $wpdb->prepare( 'UPDATE %i SET ignre = %d, ignre_user = %d, ignre_date = %s, ignre_comment = %s, ignre_global = %d WHERE siteid = %d and id = %d', $table_name, $ignre, $ignre_user, $ignre_date, $ignre_comment, $ignore_global, $siteid, $id ) );
×
755
                        }
756
                }
757

758
                $data = [
×
759
                        'ids'    => $ids,
×
760
                        'action' => $action,
×
761
                        'type'   => $type,
×
762
                        'user'   => $ignre_username,
×
763
                        'date'   => $ignre_date_formatted,
×
764
                ];
×
765

766
                if ( ! $data ) {
×
NEW
767
                        wp_send_json_error( new \WP_Error( '-2', __( 'No ignore data to return', 'accessibility-checker' ) ) );
×
768
                }
769
                wp_send_json_success( wp_json_encode( $data ) );
×
770
        }
771

772
        /**
773
         * Update simplified summary
774
         *
775
         * @return void
776
         *
777
         *  - '-1' means that nonce could not be varified
778
         *  - '-2' means that the post ID was not specified
779
         *  - '-3' means that the summary was not specified
780
         *  - '-5' means that the user does not have permission to view this information for this post
781
         */
782
        public function simplified_summary() {
783

784
                        // nonce security.
785
                if ( ! isset( $_REQUEST['nonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_REQUEST['nonce'] ) ), 'ajax-nonce' ) ) {
×
NEW
786
                        wp_send_json_error( new \WP_Error( '-1', __( 'Permission Denied', 'accessibility-checker' ) ) );
×
787
                }
788

789
                if ( ! isset( $_REQUEST['post_id'] ) ) {
×
NEW
790
                        wp_send_json_error( new \WP_Error( '-2', __( 'The post ID was not set', 'accessibility-checker' ) ) );
×
791
                }
792

793
                if ( ! isset( $_REQUEST['summary'] ) ) {
×
NEW
794
                        wp_send_json_error( new \WP_Error( '-3', __( 'The summary was not set', 'accessibility-checker' ) ) );
×
795
                }
796

NEW
797
                if ( ! current_user_can( 'edit_post', (int) $_REQUEST['post_id'] ) ) {
×
NEW
798
                        wp_send_json_error( new \WP_Error( '-5', __( 'You do not have permission to edit this post.', 'accessibility-checker' ) ) );
×
799
                }
800

NEW
801
                $post_id = (int) $_REQUEST['post_id'];
×
NEW
802
                update_post_meta(
×
NEW
803
                        $post_id,
×
NEW
804
                        '_edac_simplified_summary',
×
NEW
805
                        sanitize_text_field( wp_unslash( $_REQUEST['summary'] ) )
×
NEW
806
                );
×
807

808
                $edac_simplified_summary = get_post_meta( $post_id, '_edac_simplified_summary', $single = true );
×
809
                $simplified_summary      = $edac_simplified_summary ? $edac_simplified_summary : '';
×
810

811
                wp_send_json_success( wp_json_encode( $simplified_summary ) );
×
812
        }
813

814
        /**
815
         * Handle AJAX request to dismiss Welcome CTA
816
         *
817
         * @return void
818
         */
819
        public function dismiss_welcome_cta() {
820

821
                update_user_meta( get_current_user_id(), 'edac_welcome_cta_dismissed', true );
×
822

823
                wp_send_json( 'success' );
×
824
        }
825

826
        /**
827
         * Handle AJAX request to dismiss dashboard CTA
828
         *
829
         * @return void
830
         */
831
        public function dismiss_dashboard_cta() {
832

833
                update_user_meta( get_current_user_id(), 'edac_dashboard_cta_dismissed', true );
×
834

835
                wp_send_json( 'success' );
×
836
        }
837
}
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