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

equalizedigital / accessibility-checker / 17205722517

25 Aug 2025 10:05AM UTC coverage: 60.808% (+3.6%) from 57.172%
17205722517

push

github

web-flow
Merge pull request #1206 from equalizedigital/william/no-ticket/enhance-endpoint-checks

Backport v1.30.1

11 of 22 new or added lines in 3 files covered. (50.0%)

9 existing lines in 2 files now uncovered.

4110 of 6759 relevant lines covered (60.81%)

3.53 hits per line

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

0.0
/includes/classes/class-enqueue-frontend.php
1
<?php
2
/**
3
 * Class file for enqueueing frontend styles and scripts.
4
 *
5
 * @package Accessibility_Checker
6
 */
7

8
namespace EDAC\Inc;
9

10
/**
11
 * Class that initializes and handles enqueueing styles and scripts for the frontend.
12
 */
13
class Enqueue_Frontend {
14

15

16
        /**
17
         * Constructor
18
         */
19
        public function __construct() {
20
        }
×
21

22

23
        /**
24
         * Enqueue the scripts and styles.
25
         */
26
        public static function enqueue() {
27
                self::maybe_enqueue_frontend_highlighter();
×
28
        }
29

30
        /**
31
         * Enqueue the frontend highlighter.
32
         *
33
         * @return void
34
         */
35
        public static function maybe_enqueue_frontend_highlighter() {
36

37
                // This loads on all pages, so bail as early as possible. Do checks that don't require DB calls first.
38

39

40
                // Don't load on admin pages or in an iframe that is running a pageScan.
41
                if (
42
                        is_admin() ||
×
43
                        (
44
                                isset( $_GET['edac_pageScanner'] ) && // phpcs:ignore WordPress.Security.NonceVerification.Recommended
×
45
                                '1' === $_GET['edac_pageScanner'] // phpcs:ignore WordPress.Security.NonceVerification.Recommended
×
46
                        )
47
                ) {
48
                        return;
×
49
                }
50

51
                // Don't load on the frontend if we don't have a post to work with.
52
                global $post;
×
53
                $post_id = is_object( $post ) ? $post->ID : null;
×
54

55
                if ( null === $post_id ) {
×
56
                        return;
×
57
                }
58

59
                // Don't load in a customizer preview or user can't edit the page. A filter
60
                // can override the edit requirement to allow anyone to see it.
61
                if (
62
                        is_customize_preview() ||
×
63
                        (
64
                                /**
65
                                 * Filter the visibility of the frontend highlighter.
66
                                 *
67
                                 * 'edac_filter_frontend_highlighter_visibility' is a filter that can be used
68
                                 * to allow users without edit permissions on the post to see the frontend
69
                                 * highlighter. You can use the filter to perform additional permission checks
70
                                 * on who can see it.
71
                                 *
72
                                 * @since 1.14.0
73
                                 *
74
                                 * @param bool $visibility The visibility of the frontend highlighter. Default is false, return true to show the frontend highlighter.
75
                                 */
76
                                ! apply_filters( 'edac_filter_frontend_highlighter_visibility', false ) &&
×
77
                                ! ( $post_id && current_user_can( 'edit_post', $post_id ) )
×
78
                        )
79
                ) {
80
                        return;
×
81
                }
82

83

84
                // Don't load if this pagetype is not setup to be scanned.
85
                $post_types        = get_option( 'edac_post_types' );
×
86
                $current_post_type = get_post_type();
×
87
                $active            = ( is_array( $post_types ) && in_array( $current_post_type, $post_types, true ) );
×
88

89

90
                if ( $active ) {
×
91

92

93
                        wp_enqueue_style( 'edac-frontend-highlighter-app', plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/css/frontendHighlighterApp.css', false, EDAC_VERSION, 'all' );
×
94
                        wp_enqueue_script( 'edac-frontend-highlighter-app', plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/frontendHighlighterApp.bundle.js', false, EDAC_VERSION, false );
×
95

96
                        wp_localize_script(
×
97
                                'edac-frontend-highlighter-app',
×
98
                                'edacFrontendHighlighterApp',
×
99
                                [
×
100
                                        'postID'           => $post_id,
×
101
                                        'nonce'            => wp_create_nonce( 'ajax-nonce' ),
×
102
                                        'restNonce'        => wp_create_nonce( 'wp_rest' ),
×
103
                                        'userCanFix'       => current_user_can( apply_filters( 'edac_filter_settings_capability', 'manage_options' ) ),
×
NEW
104
                                        'userCanEdit'      => current_user_can( 'edit_post', $post_id ),
×
105
                                        'edacUrl'          => esc_url_raw( get_site_url() ),
×
106
                                        'ajaxurl'          => admin_url( 'admin-ajax.php' ),
×
107
                                        'loggedIn'         => is_user_logged_in(),
×
108
                                        'appCssUrl'        => EDAC_PLUGIN_URL . 'build/css/frontendHighlighterApp.css?ver=' . EDAC_VERSION,
×
109
                                        'widgetPosition'   => get_option( 'edac_frontend_highlighter_position', 'right' ),
×
110
                                        'editorLink'       => get_edit_post_link( $post_id ),
×
111
                                        'scannerBundleUrl' => plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/pageScanner.bundle.js',
×
112
                                ]
×
113
                        );
×
114

115
                        wp_set_script_translations( 'edac-frontend-highlighter-app', 'accessibility-checker', plugin_dir_path( EDAC_PLUGIN_FILE ) . 'languages' );
×
116

117
                }
118
        }
119
}
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

© 2025 Coveralls, Inc