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

equalizedigital / accessibility-checker / 19966527801

05 Dec 2025 02:47PM UTC coverage: 57.464%. First build
19966527801

Pull #1298

github

web-flow
Merge b38c84b5f into fb04bca5f
Pull Request #1298: Release v1.35.0

65 of 108 new or added lines in 10 files covered. (60.19%)

4173 of 7262 relevant lines covered (57.46%)

3.44 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' ) ) {
×
56
                        wp_send_json_error( new \WP_Error( '-1', __( 'Permission Denied', 'accessibility-checker' ) ) );
×
57
                }
58

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

63
                if ( ! current_user_can( 'edit_post', (int) $_REQUEST['post_id'] ) ) {
×
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

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 */
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 */
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 */
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 */
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 ) {
×
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

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

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

209
                if ( ! current_user_can( 'edit_post', (int) $_REQUEST['post_id'] ) ) {
×
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 ) {
×
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

NEW
431
                                                $id               = (int) $row['id'];
×
NEW
432
                                                $ignore           = (int) $row['ignre'];
×
NEW
433
                                                $ignore_class     = $ignore ? ' active' : '';
×
NEW
434
                                                $ignore_label     = $ignore ? 'Ignored' : 'Ignore';
×
NEW
435
                                                $ignore_user      = (int) $row['ignre_user'];
×
NEW
436
                                                $ignore_user_info = get_userdata( $ignore_user );
×
NEW
437
                                                $ignore_username  = is_object( $ignore_user_info )
×
NEW
438
                                                        ? '<strong>' . esc_html__( 'Username:', 'accessibility-checker' ) . '</strong> ' . esc_html( $ignore_user_info->user_login )
×
NEW
439
                                                        : '';
×
440

NEW
441
                                                $ignore_date_text        = $row['ignre_date'] ? edac_format_datetime_from_utc( $row['ignre_date'] ) : '';
×
NEW
442
                                                $ignore_date             = $ignore_date_text
×
NEW
443
                                                ? '<strong>' . esc_html__( 'Date:', 'accessibility-checker' ) . '</strong> ' . esc_html( $ignore_date_text )
×
NEW
444
                                                : '';
×
445
                                                $ignore_comment          = esc_html( $row['ignre_comment'] );
×
446
                                                $ignore_action           = $ignore ? 'disable' : 'enable';
×
447
                                                $ignore_type             = $rule['rule_type'];
×
448
                                                $ignore_submit_label     = $ignore ? 'Stop Ignoring' : 'Ignore This ' . $ignore_type;
×
449
                                                $ignore_comment_disabled = $ignore ? 'disabled' : '';
×
450
                                                $ignore_global           = (int) $row['ignre_global'];
×
451

452
                                                // check for images and svgs in object code.
453
                                                $media      = edac_parse_html_for_media( $row['object'] );
×
454
                                                $object_img = $media['img'];
×
455
                                                $object_svg = $media['svg'];
×
456

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

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

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

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

465
                                                $html .= '</div>';
×
466

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

469
                                                if ( $object_img ) {
×
470
                                                        $html .= '<img src="' . $object_img . '" alt="image for issue ' . $id . '" />';
×
471
                                                } elseif ( $object_svg ) {
×
472
                                                        $html .= $object_svg;
×
473
                                                }
474

475
                                                $html .= '</div>';
×
476

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

479
                                                $landmark          = isset( $row['landmark'] ) ? $row['landmark'] : '';
×
480
                                                $landmark_selector = isset( $row['landmark_selector'] ) ? $row['landmark_selector'] : '';
×
481

482
                                                $html .= edac_generate_landmark_link( $landmark, $landmark_selector, $postid );
×
483

484
                                                $html .= '</div>';
×
485

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

488
                                                if ( ! isset( $rule['viewable'] ) || $rule['viewable'] ) {
×
489

490
                                                        $post_view_link = apply_filters(
×
491
                                                                'edac_get_origin_url_for_virtual_page',
×
492
                                                                get_the_permalink( $postid ),
×
493
                                                                $postid
×
494
                                                        );
×
495

496
                                                        $url = add_query_arg(
×
497
                                                                [
×
498
                                                                        'edac'       => $id,
×
499
                                                                        'edac_nonce' => wp_create_nonce( 'edac_highlight' ),
×
500
                                                                ],
×
501
                                                                $post_view_link
×
502
                                                        );
×
503

504
                                                        // Translators: %d is the issue ID.
505
                                                        $aria_label = sprintf( __( 'View Issue ID %d on website, opens a new window', 'accessibility-checker' ), $id );
×
506
                                                        $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>';
×
507
                                                }
508

509
                                                if ( true === $ignore_permission ) {
×
510
                                                        $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>';
×
511
                                                }
512

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

530
                                                $html .= '</div>';
×
531

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

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

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

540
                                                $html .= ( true === $ignore_permission || ! empty( $ignore_comment ) ) ? '<label for="edac-details-rule-records-record-ignore-comment-' . $id . '">Comment</label><br>' : '';
×
541
                                                $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>' : '';
×
542

543
                                                if ( $ignore_global ) {
×
544
                                                        $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>' : '';
×
545
                                                } else {
546
                                                        $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>' : '';
×
547
                                                }
548

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

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

553
                                                $html .= '</div>';
×
554

555
                                        }
556

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

559
                                }
560

561
                                $html .= '</div>';
×
562
                        }
563
                }
564

565
                if ( ! $html ) {
×
566
                        wp_send_json_error( new \WP_Error( '-4', __( 'No details to return', 'accessibility-checker' ) ) );
×
567
                }
568

569
                wp_send_json_success( wp_json_encode( $html ) );
×
570
        }
571

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

584
                if ( ! isset( $_REQUEST['nonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_REQUEST['nonce'] ) ), 'ajax-nonce' ) ) {
×
585
                        wp_send_json_error( new \WP_Error( '-1', __( 'Permission Denied', 'accessibility-checker' ) ) );
×
586
                }
587

588
                if ( ! isset( $_REQUEST['post_id'] ) ) {
×
589
                        wp_send_json_error( new \WP_Error( '-2', __( 'The post ID was not set', 'accessibility-checker' ) ) );
×
590
                }
591

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

596
                $post_id                     = (int) $_REQUEST['post_id'];
×
597
                $html                        = '';
×
598
                $simplified_summary          = get_post_meta( $post_id, '_edac_simplified_summary', true ) ? get_post_meta( $post_id, '_edac_simplified_summary', true ) : '';
×
599
                $simplified_summary_position = get_option( 'edac_simplified_summary_position', $default = false );
×
600
                $content_post                = get_post( $post_id );
×
601
                $content                     = $content_post->post_content;
×
602
                $content                     = apply_filters( 'the_content', $content );
×
603

604
                /**
605
                 * Filter the content used for reading grade readability analysis.
606
                 *
607
                 * @since 1.4.0
608
                 *
609
                 * @param string $content The content to be filtered.
610
                 * @param int    $post_id The post ID.
611
                 */
612
                $content = apply_filters( 'edac_filter_readability_content', $content, $post_id );
×
613
                $content = wp_filter_nohtml_kses( $content );
×
614
                $content = str_replace( ']]>', ']]&gt;', $content );
×
615

616
                // get readability metadata and determine if a simplified summary is required.
617
                $edac_summary           = get_post_meta( $post_id, '_edac_summary', true );
×
618
                $post_grade_readability = ( isset( $edac_summary['readability'] ) ) ? $edac_summary['readability'] : 0;
×
619
                $post_grade             = (int) filter_var( $post_grade_readability, FILTER_SANITIZE_NUMBER_INT );
×
620
                $post_grade_failed      = ( $post_grade < 9 ) ? false : true;
×
621

622
                $simplified_summary_grade = 0;
×
623
                if ( class_exists( 'DaveChild\TextStatistics\TextStatistics' ) ) {
×
624
                        $text_statistics          = new \DaveChild\TextStatistics\TextStatistics();
×
625
                        $simplified_summary_grade = (int) floor( $text_statistics->fleschKincaidGradeLevel( $simplified_summary ) );
×
626
                }
627

628
                $simplified_summary_grade_failed = ( $simplified_summary_grade > 9 ) ? true : false;
×
629
                $simplified_summary_prompt       = get_option( 'edac_simplified_summary_prompt' );
×
630

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

633
                $html .= '<li class="edac-readability-list-item edac-readability-grade-level">
×
634
                <span class="edac-readability-list-item-icon dashicons ' . ( ( $post_grade_failed || 0 === $post_grade ) ? 'dashicons-no-alt' : 'dashicons-saved' ) . '"></span>
×
635
                <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>';
×
636
                if ( $post_grade_failed ) {
×
637
                        $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>';
×
638
                } elseif ( 0 === $post_grade ) {
×
639
                        $html .= '<p class="edac-readability-list-item-description">Your post does not contain enough content to calculate its reading level.</p>';
×
640
                } else {
641
                        $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>';
×
642
                }
643
                $html .= '</li>';
×
644

645
                if ( $post_grade_failed ) {
×
646

647
                        if ( $simplified_summary && 'none' !== $simplified_summary_prompt ) {
×
648
                                $html .= '<li class="edac-readability-list-item edac-readability-summary-grade-level">
×
649
                                        <span class="edac-readability-list-item-icon dashicons ' . ( ( $simplified_summary_grade_failed ) ? 'dashicons-no-alt' : 'dashicons-saved' ) . '"></span>
×
650
                                        <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>
×
651
                                        <p class="edac-readability-list-item-description">Your simplified summary has a reading level ' . ( ( $simplified_summary_grade_failed ) ? 'higher' : 'lower' ) . ' than 9th grade.</p>
×
652
                                </li>';
×
653
                        }
654

655
                        if ( 'none' === $simplified_summary_prompt ) {
×
656

657
                                $html .=
×
658
                                        '<li class="edac-readability-list-item edac-readability-summary-position">
×
659
                                        <span class="edac-readability-list-item-icon"><img src="' . plugin_dir_url( __FILE__ ) . 'assets/images/warning-icon-yellow.png" alt="" width="22"></span>
×
660
                                        <p class="edac-readability-list-item-title">Simplified summary is not being automatically inserted into the content.</p>
661
                                                <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>
×
662
                                </li>';
×
663

664
                        } elseif ( 'none' !== $simplified_summary_position ) {
×
665

666
                                $html .=
×
667
                                        '<li class="edac-readability-list-item edac-readability-summary-position">
×
668
                                        <span class="edac-readability-list-item-icon dashicons dashicons-saved"></span>
669
                                        <p class="edac-readability-list-item-title">Simplified summary is being automatically inserted <strong>' . $simplified_summary_position . ' the content</strong>.</p>
×
670
                                                <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>
×
671
                                </li>';
×
672

673
                        } else {
674

675
                                $html .=
×
676
                                        '<li class="edac-readability-list-item edac-readability-summary-position">
×
677
                                        <span class="edac-readability-list-item-icon"><img src="' . plugin_dir_url( __FILE__ ) . 'assets/images/warning-icon-yellow.png" alt="" width="22"></span>
×
678
                                        <p class="edac-readability-list-item-title">Simplified summary is not being automatically inserted into the content.</p>
679
                                                <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>
×
680
                                </li>';
×
681

682
                        }
683
                }
684

685
                $html .= '</ul>';
×
686

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

697
                $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>';
×
698

699
                if ( ! $html ) {
×
700
                        wp_send_json_error( new \WP_Error( '-3', __( 'No readability data to return', 'accessibility-checker' ) ) );
×
701
                }
702

703
                wp_send_json_success( wp_json_encode( $html ) );
×
704
        }
705

706
        /**
707
         * Insert ignore data into database
708
         *
709
         * @return void
710
         *
711
         *  - '-1' means that nonce could not be varified
712
         *  - '-2' means that there isn't any ignore data to return
713
         */
714
        public function add_ignore() {
715

716
                // nonce security.
717
                if ( ! isset( $_REQUEST['nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['nonce'] ) ), 'ajax-nonce' ) ) {
×
718
                        wp_send_json_error( new \WP_Error( '-1', __( 'Permission Denied', 'accessibility-checker' ) ) );
×
719
                }
720

721
                global $wpdb;
×
722
                $table_name           = $wpdb->prefix . 'accessibility_checker';
×
723
                $raw_ids              = isset( $_REQUEST['ids'] ) ? (array) wp_unslash( $_REQUEST['ids'] ) : []; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Sanitization handled below.
×
724
                $ids                  = array_map(
×
725
                        function ( $value ) {
×
726
                                return (int) $value;
×
727
                        },
×
728
                        $raw_ids
×
729
                ); // Sanitizing array elements to integers.
×
730
                $action               = isset( $_REQUEST['ignore_action'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['ignore_action'] ) ) : '';
×
731
                $type                 = isset( $_REQUEST['ignore_type'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['ignore_type'] ) ) : '';
×
732
                $siteid               = get_current_blog_id();
×
733
                $ignre                = ( 'enable' === $action ) ? 1 : 0;
×
734
                $ignre_user           = ( 'enable' === $action ) ? get_current_user_id() : null;
×
735
                $ignre_user_info      = ( 'enable' === $action ) ? get_userdata( $ignre_user ) : '';
×
736
                $ignre_username       = ( 'enable' === $action ) ? $ignre_user_info->user_login : '';
×
NEW
737
                $ignre_date           = ( 'enable' === $action ) ? edac_get_current_utc_datetime() : null;
×
NEW
738
                $ignre_date_formatted = ( 'enable' === $action ) ? edac_format_datetime_from_utc( $ignre_date ) : '';
×
739
                $ignre_comment        = ( 'enable' === $action && isset( $_REQUEST['comment'] ) ) ? sanitize_textarea_field( wp_unslash( $_REQUEST['comment'] ) ) : null;
×
740
                $ignore_global        = ( 'enable' === $action && isset( $_REQUEST['ignore_global'] ) ) ? sanitize_textarea_field( wp_unslash( $_REQUEST['ignore_global'] ) ) : 0;
×
741

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

751
                        if ( ! $object ) {
×
752
                                wp_send_json_error( new \WP_Error( '-2', __( 'No ignore data to return', 'accessibility-checker' ) ) );
×
753
                        }
754
                        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Safe variable used for table name, caching not required for one time operation.
755
                        $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 ) );
×
756
                } else {
757
                        // For small batches of IDs, we can just loop through.
758
                        foreach ( $ids as $id ) {
×
759
                                // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Safe variable used for table name, caching not required for one time operation.
760
                                $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 ) );
×
761
                        }
762
                }
763

764
                $data = [
×
765
                        'ids'    => $ids,
×
766
                        'action' => $action,
×
767
                        'type'   => $type,
×
768
                        'user'   => $ignre_username,
×
769
                        'date'   => $ignre_date_formatted,
×
770
                ];
×
771

772
                if ( ! $data ) {
×
773
                        wp_send_json_error( new \WP_Error( '-2', __( 'No ignore data to return', 'accessibility-checker' ) ) );
×
774
                }
775
                wp_send_json_success( wp_json_encode( $data ) );
×
776
        }
777

778
        /**
779
         * Update simplified summary
780
         *
781
         * @return void
782
         *
783
         *  - '-1' means that nonce could not be varified
784
         *  - '-2' means that the post ID was not specified
785
         *  - '-3' means that the summary was not specified
786
         *  - '-5' means that the user does not have permission to view this information for this post
787
         */
788
        public function simplified_summary() {
789

790
                        // nonce security.
791
                if ( ! isset( $_REQUEST['nonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_REQUEST['nonce'] ) ), 'ajax-nonce' ) ) {
×
792
                        wp_send_json_error( new \WP_Error( '-1', __( 'Permission Denied', 'accessibility-checker' ) ) );
×
793
                }
794

795
                if ( ! isset( $_REQUEST['post_id'] ) ) {
×
796
                        wp_send_json_error( new \WP_Error( '-2', __( 'The post ID was not set', 'accessibility-checker' ) ) );
×
797
                }
798

799
                if ( ! isset( $_REQUEST['summary'] ) ) {
×
800
                        wp_send_json_error( new \WP_Error( '-3', __( 'The summary was not set', 'accessibility-checker' ) ) );
×
801
                }
802

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

807
                $post_id = (int) $_REQUEST['post_id'];
×
808
                update_post_meta(
×
809
                        $post_id,
×
810
                        '_edac_simplified_summary',
×
811
                        sanitize_text_field( wp_unslash( $_REQUEST['summary'] ) )
×
812
                );
×
813

814
                $edac_simplified_summary = get_post_meta( $post_id, '_edac_simplified_summary', $single = true );
×
815
                $simplified_summary      = $edac_simplified_summary ? $edac_simplified_summary : '';
×
816

817
                wp_send_json_success( wp_json_encode( $simplified_summary ) );
×
818
        }
819

820
        /**
821
         * Handle AJAX request to dismiss Welcome CTA
822
         *
823
         * @return void
824
         */
825
        public function dismiss_welcome_cta() {
826

827
                update_user_meta( get_current_user_id(), 'edac_welcome_cta_dismissed', true );
×
828

829
                wp_send_json( 'success' );
×
830
        }
831

832
        /**
833
         * Handle AJAX request to dismiss dashboard CTA
834
         *
835
         * @return void
836
         */
837
        public function dismiss_dashboard_cta() {
838

839
                update_user_meta( get_current_user_id(), 'edac_dashboard_cta_dismissed', true );
×
840

841
                wp_send_json( 'success' );
×
842
        }
843
}
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