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

equalizedigital / accessibility-checker / 22024231170

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

Pull #1413

github

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

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

4147 of 7242 relevant lines covered (57.26%)

3.47 hits per line

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

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

NEW
15
if ( ! defined( 'ABSPATH' ) ) {
×
NEW
16
        exit;
×
17
}
18

19
/**
20
 * Class that handles ajax requests.
21
 */
22
class Ajax {
23

24
        /**
25
         * Constructor function for the class.
26
         */
27
        public function __construct() {
28
        }
×
29

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

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

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

63
                if ( ! isset( $_REQUEST['post_id'] ) ) {
×
64
                        wp_send_json_error( new \WP_Error( '-2', __( 'The post ID was not set', 'accessibility-checker' ) ) );
×
65
                }
66

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

71
                $html            = [];
×
72
                $html['content'] = '';
×
73

74
                $post_id                   = (int) $_REQUEST['post_id'];
×
75
                $summary                   = ( new Summary_Generator( $post_id ) )->generate_summary();
×
76
                $simplified_summary_text   = '';
×
77
                $simplified_summary_prompt = get_option( 'edac_simplified_summary_prompt' );
×
78
                $simplified_summary        = get_post_meta( $post_id, '_edac_simplified_summary', true ) ? get_post_meta( $post_id, '_edac_simplified_summary', true ) : '';
×
79

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

87
                $simplified_summary_text = esc_html__( 'A Simplified summary has not been included for this content.', 'accessibility-checker' );
×
88
                if ( 'none' !== $simplified_summary_prompt ) {
×
89
                        if ( $summary['content_grade'] <= 9 ) {
×
90
                                $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' );
×
91
                        } elseif ( $summary['simplified_summary'] ) {
×
92
                                if ( $simplified_summary_grade_failed ) {
×
93
                                        $simplified_summary_text = esc_html__( 'The reading level of the simplified summary is too high.', 'accessibility-checker' );
×
94
                                } else {
95
                                        $simplified_summary_text = esc_html__( 'A simplified summary has been included for this content.', 'accessibility-checker' );
×
96
                                }
97
                        }
98
                }
99

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

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

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

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

121
                        $html['content'] .= '</li>';
×
122

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

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

152
                </ul>
153
                <div class="edac-summary-readability" ' . ( $is_virtual_page ? 'style="display: none;"' : '' ) . '>
×
154
                        <div class="edac-summary-readability-level">
155
                                <div><img src="' . EDAC_PLUGIN_URL . 'assets/images/readability-icon-navy.png" alt="" width="54"></div>
×
156
                                <div class="edac-panel-number' . ( ( (int) $summary['content_grade'] <= 9 || 'none' === $simplified_summary_prompt ) ? ' passed-text-color' : ' failed-text-color' ) . '">
×
157
                                        ' . $summary['readability'] . '
×
158
                                </div>
159
                                <div class="edac-panel-number-label' . ( ( (int) $summary['readability'] <= 9 || 'none' === $simplified_summary_prompt ) ? ' passed-text-color' : ' failed-text-color' ) . '">Reading <br />Level</div>
×
160
                        </div>
161
                        <div class="edac-summary-readability-summary">
162
                                <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>
×
163
                                <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>
×
164
                        </div>
165
                </div>
166
                ';
×
167

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

185
                if ( ! $html ) {
×
186
                        wp_send_json_error( new \WP_Error( '-3', __( 'No summary to return', 'accessibility-checker' ) ) );
×
187
                }
188

189
                wp_send_json_success( wp_json_encode( $html ) );
×
190
        }
191

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

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

209
                if ( ! isset( $_REQUEST['post_id'] ) ) {
×
210
                        wp_send_json_error( new \WP_Error( '-2', __( 'The post ID was not set', 'accessibility-checker' ) ) );
×
211
                }
212

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

217
                $html = '';
×
218
                global $wpdb;
×
219
                $table_name = edac_get_valid_table_name( $wpdb->prefix . 'accessibility_checker' );
×
220
                $postid     = (int) $_REQUEST['post_id'];
×
221
                $siteid     = get_current_blog_id();
×
222

223
                // Send error if table name is not valid.
224
                if ( ! $table_name ) {
×
225
                        wp_send_json_error( new \WP_Error( '-3', __( 'Invalid table name', 'accessibility-checker' ) ) );
×
226
                }
227

228
                $rules = edac_register_rules();
×
229
                if ( $rules ) {
×
230

231
                        // if ANWW is active remove link_blank for details meta box.
232
                        if ( defined( 'ANWW_VERSION' ) ) {
×
233
                                $rules = edac_remove_element_with_value( $rules, 'slug', 'link_blank' );
×
234
                        }
235

236
                        // separate rule types.
237
                        $passed_rules  = [];
×
238
                        $error_rules   = edac_remove_element_with_value( $rules, 'rule_type', 'warning' );
×
239
                        $warning_rules = edac_remove_element_with_value( $rules, 'rule_type', 'error' );
×
240

241
                        // add count, unset passed error rules and add passed rules to array.
242
                        if ( $error_rules ) {
×
243
                                foreach ( $error_rules as $key => $error_rule ) {
×
244
                                        // 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.
245
                                        $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 ) );
×
246
                                        if ( $count ) {
×
247
                                                $error_rules[ $key ]['count'] = $count;
×
248
                                        } else {
249
                                                $error_rule['count'] = 0;
×
250
                                                $passed_rules[]      = $error_rule;
×
251
                                                unset( $error_rules[ $key ] );
×
252
                                        }
253
                                }
254
                        }
255

256
                        // add count, unset passed warning rules and add passed rules to array.
257
                        if ( $warning_rules ) {
×
258
                                foreach ( $warning_rules as $key => $error_rule ) {
×
259
                                        // 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.
260
                                        $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 ) );
×
261
                                        if ( $count ) {
×
262
                                                $warning_rules[ $key ]['count'] = $count;
×
263
                                        } else {
264
                                                $error_rule['count'] = 0;
×
265
                                                $passed_rules[]      = $error_rule;
×
266
                                                unset( $warning_rules[ $key ] );
×
267
                                        }
268
                                }
269
                        }
270
                }
271

272
                // sort error rules by count.
273
                usort(
×
274
                        $error_rules,
×
275
                        function ( $a, $b ) {
×
276

277
                                return strcmp( $b['count'], $a['count'] );
×
278
                        }
×
279
                );
×
280

281
                // sort warning rules by count.
282
                usort(
×
283
                        $warning_rules,
×
284
                        function ( $a, $b ) {
×
285

286
                                return strcmp( $b['count'], $a['count'] );
×
287
                        }
×
288
                );
×
289

290
                // sort passed rules array by title.
291
                usort(
×
292
                        $passed_rules,
×
293
                        function ( $a, $b ) {
×
294

295
                                return strcmp( $b['title'], $a['title'] );
×
296
                        }
×
297
                );
×
298

299
                // merge rule arrays together.
300
                $rules = array_merge( $error_rules, $warning_rules, $passed_rules );
×
301

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

312
                        foreach ( $rules as $rule ) {
×
313
                                // 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.
314
                                $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 );
×
315
                                $count_classes  = ( 'error' === $rule['rule_type'] ) ? ' edac-details-rule-count-error' : ' edac-details-rule-count-warning';
×
316
                                $count_classes .= ( 0 !== $rule['count'] ) ? ' active' : '';
×
317

318
                                $count_ignored = 0;
×
319
                                $ignores       = array_column( $results, 'ignre' );
×
320
                                if ( $ignores ) {
×
321
                                        foreach ( $ignores as $ignore ) {
×
322
                                                if ( true === (bool) $ignore ) {
×
323
                                                        ++$count_ignored;
×
324
                                                }
325
                                        }
326
                                }
327

328
                                // 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.
329
                                $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 ) );
×
330

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

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

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

337
                                $html .= '<h3>';
×
338
                                $html .= '<span class="edac-details-rule-count' . $count_classes . '">' . $rule['count'] . '</span> ';
×
339
                                $html .= esc_html( $rule['title'] );
×
340
                                if ( $count_ignored > 0 ) {
×
341
                                        $html .= '<span class="edac-details-rule-count-ignore">' . $count_ignored . ' Ignored Items</span>';
×
342
                                }
343
                                $html .= '</h3>';
×
344
                                $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>';
×
345
                                $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>' : '';
×
346

347
                                $html .= '</div>';
×
348

349
                                if ( $results ) {
×
350

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

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

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

415

416

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

433
                                        foreach ( $results as $row ) {
×
434

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

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

456
                                                // check for images and svgs in object code.
457
                                                $media      = edac_parse_html_for_media( $row['object'] );
×
458
                                                $object_img = $media['img'];
×
459
                                                $object_svg = $media['svg'];
×
460

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

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

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

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

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

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

473
                                                if ( $object_img ) {
×
474
                                                        $html .= '<img src="' . $object_img . '" alt="image for issue ' . $id . '" />';
×
475
                                                } elseif ( $object_svg ) {
×
476
                                                        $html .= $object_svg;
×
477
                                                }
478

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

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

483
                                                $landmark          = isset( $row['landmark'] ) ? $row['landmark'] : '';
×
484
                                                $landmark_selector = isset( $row['landmark_selector'] ) ? $row['landmark_selector'] : '';
×
485

486
                                                $html .= edac_generate_landmark_link( $landmark, $landmark_selector, $postid );
×
487

488
                                                $html .= '</div>';
×
489

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

492
                                                if ( ! isset( $rule['viewable'] ) || $rule['viewable'] ) {
×
493

494
                                                        $post_view_link = apply_filters(
×
495
                                                                'edac_get_origin_url_for_virtual_page',
×
496
                                                                get_the_permalink( $postid ),
×
497
                                                                $postid
×
498
                                                        );
×
499

500
                                                        $url = add_query_arg(
×
501
                                                                [
×
502
                                                                        'edac'       => $id,
×
503
                                                                        'edac_nonce' => wp_create_nonce( 'edac_highlight' ),
×
504
                                                                ],
×
505
                                                                $post_view_link
×
506
                                                        );
×
507

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

513
                                                if ( true === $ignore_permission ) {
×
514
                                                        $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>';
×
515
                                                }
516

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

534
                                                $html .= '</div>';
×
535

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

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

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

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

547
                                                if ( $ignore_global && edac_is_pro() ) {
×
548
                                                        $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', 'accessibility-checker' ) . '</a>' : '';
×
549
                                                } else {
550
                                                        $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>' : '';
×
551
                                                }
552

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

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

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

559
                                        }
560

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

563
                                }
564

565
                                $html .= '</div>';
×
566
                        }
567
                }
568

569
                if ( ! $html ) {
×
570
                        wp_send_json_error( new \WP_Error( '-4', __( 'No details to return', 'accessibility-checker' ) ) );
×
571
                }
572

573
                wp_send_json_success( wp_json_encode( $html ) );
×
574
        }
575

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

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

592
                if ( ! isset( $_REQUEST['post_id'] ) ) {
×
593
                        wp_send_json_error( new \WP_Error( '-2', __( 'The post ID was not set', 'accessibility-checker' ) ) );
×
594
                }
595

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

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

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

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

626
                $simplified_summary_grade = 0;
×
627
                if ( class_exists( 'DaveChild\TextStatistics\TextStatistics' ) ) {
×
628
                        $text_statistics          = new \DaveChild\TextStatistics\TextStatistics();
×
629
                        $simplified_summary_grade = (int) floor( $text_statistics->fleschKincaidGradeLevel( $simplified_summary ) );
×
630
                }
631

632
                $simplified_summary_grade_failed = ( $simplified_summary_grade > 9 ) ? true : false;
×
633
                $simplified_summary_prompt       = get_option( 'edac_simplified_summary_prompt' );
×
634

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

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

649
                if ( $post_grade_failed ) {
×
650

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

659
                        if ( 'none' === $simplified_summary_prompt ) {
×
660

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

668
                        } elseif ( 'none' !== $simplified_summary_position ) {
×
669

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

677
                        } else {
678

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

686
                        }
687
                }
688

689
                $html .= '</ul>';
×
690

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

701
                $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>';
×
702

703
                if ( ! $html ) {
×
704
                        wp_send_json_error( new \WP_Error( '-3', __( 'No readability data to return', 'accessibility-checker' ) ) );
×
705
                }
706

707
                wp_send_json_success( wp_json_encode( $html ) );
×
708
        }
709

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

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

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

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

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

768
                $data = [
×
769
                        'ids'    => $ids,
×
770
                        'action' => $action,
×
771
                        'type'   => $type,
×
772
                        'user'   => $ignre_username,
×
773
                        'date'   => $ignre_date_formatted,
×
774
                ];
×
775

776
                if ( ! $data ) {
×
777
                        wp_send_json_error( new \WP_Error( '-2', __( 'No ignore data to return', 'accessibility-checker' ) ) );
×
778
                }
779
                wp_send_json_success( wp_json_encode( $data ) );
×
780
        }
781

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

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

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

803
                if ( ! isset( $_REQUEST['summary'] ) ) {
×
804
                        wp_send_json_error( new \WP_Error( '-3', __( 'The summary was not set', 'accessibility-checker' ) ) );
×
805
                }
806

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

811
                $post_id = (int) $_REQUEST['post_id'];
×
812
                update_post_meta(
×
813
                        $post_id,
×
814
                        '_edac_simplified_summary',
×
815
                        sanitize_text_field( wp_unslash( $_REQUEST['summary'] ) )
×
816
                );
×
817

818
                $edac_simplified_summary = get_post_meta( $post_id, '_edac_simplified_summary', $single = true );
×
819
                $simplified_summary      = $edac_simplified_summary ? $edac_simplified_summary : '';
×
820

821
                wp_send_json_success( wp_json_encode( $simplified_summary ) );
×
822
        }
823

824
        /**
825
         * Handle AJAX request to dismiss Welcome CTA
826
         *
827
         * @return void
828
         */
829
        public function dismiss_welcome_cta() {
830

831
                update_user_meta( get_current_user_id(), 'edac_welcome_cta_dismissed', true );
×
832

833
                wp_send_json( 'success' );
×
834
        }
835

836
        /**
837
         * Handle AJAX request to dismiss dashboard CTA
838
         *
839
         * @return void
840
         */
841
        public function dismiss_dashboard_cta() {
842

843
                update_user_meta( get_current_user_id(), 'edac_dashboard_cta_dismissed', true );
×
844

845
                wp_send_json( 'success' );
×
846
        }
847
}
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