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

equalizedigital / accessibility-checker / 17297832630

28 Aug 2025 01:47PM UTC coverage: 59.256% (-1.6%) from 60.808%
17297832630

push

github

web-flow
Merge pull request #1171 from equalizedigital/william/pro-169-filter-post-types-at-save-time

Add initial support for handling of virtual posts

47 of 252 new or added lines in 13 files covered. (18.65%)

2 existing lines in 1 file now uncovered.

4123 of 6958 relevant lines covered (59.26%)

3.52 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
use EDAC\Admin\Settings;
11

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

17

18
        /**
19
         * Constructor
20
         */
21
        public function __construct() {
22
        }
×
23

24

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

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

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

41

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

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

57
                if ( null === $post_id ) {
×
58
                        return;
×
59
                }
60

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

85

86
                // Don't load if this pagetype is not setup to be scanned.
NEW
87
                $post_types        = Settings::get_scannable_post_types();
×
88
                $current_post_type = get_post_type();
×
89
                $active            = ( is_array( $post_types ) && in_array( $current_post_type, $post_types, true ) );
×
90

91

92
                if ( $active ) {
×
93

94

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

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

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

119
                }
120
        }
121
}
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