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

equalizedigital / accessibility-checker / 13161962549

05 Feb 2025 04:26PM UTC coverage: 24.679% (+0.003%) from 24.676%
13161962549

push

github

web-flow
Merge pull request #849 from equalizedigital/steve/8065492104/find-unique-missing-transcripts

updated: EDAC_Dom and missing_transcript to modify element output to ensure each unique element is stored

0 of 2 new or added lines in 2 files covered. (0.0%)

1751 of 7095 relevant lines covered (24.68%)

5.54 hits per line

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

81.58
/includes/classes/class-edac-dom.php
1
<?php
2
/**
3
 * Accessibility Checker pluign file.
4
 *
5
 * @package Accessibility_Checker
6
 */
7

8
/**
9
 * EDAC DOM Class
10
 */
11
class EDAC_Dom extends simple_html_dom {
12

13
        /**
14
         * Array of supported video extensions.
15
         *
16
         * @var array $video_ext Video extensions.
17
         */
18
        protected $video_ext = [
19
                '.3gp',
20
                '.asf',
21
                '.asx',
22
                '.avi',
23
                '.flv',
24
                '.m4p',
25
                '.mov',
26
                '.mpeg',
27
                '.mpeg2',
28
                '.mpg',
29
                '.mpv',
30
                '.ogg',
31
                '.ogv',
32
                '.qtl',
33
                '.smi',
34
                '.smil',
35
                '.wax',
36
                '.webm',
37
                '.wmv',
38
                '.wmp',
39
                '.wmx',
40
        ];
41

42
        /**
43
         * List of supported audio file extensions.
44
         *
45
         * @var array $audio_ext Audio extensions.
46
         */
47
        protected $audio_ext = [
48
                '.aif',
49
                '.aiff',
50
                '.m4a',
51
                '.mp2',
52
                '.mp3',
53
                '.mp4',
54
                '.mpa',
55
                '.ra',
56
                '.ram',
57
                '.wav',
58
                '.wma',
59
        ];
60

61
        /**
62
         * Array containing URLs of embed sources.
63
         *
64
         * @var array $embed_sources Embed source URLs.
65
         */
66
        protected $embed_sources = [
67
                'mixcloud.com',
68
                'reverbnation.com',
69
                'screencast.com',
70
                'soundcloud.com',
71
                'spotify.com',
72
                'ted.com',
73
                'tiktok.com',
74
                'youtube.com',
75
                'youtu.be',
76
                'videopress.com',
77
                'vimeo.com',
78
        ];
79

80
        /**
81
         * Convert Tag to Marker
82
         *
83
         * @param array $tags array of tags.
84
         * @return void
85
         */
86
        public function convert_tag_to_marker( $tags ) {
87
                $elements = [];
10✔
88

89
                foreach ( $tags as $tag ) {
10✔
90
                        $elements = array_merge( $elements, $this->find( $tag ) );
10✔
91
                }
92

93
                foreach ( $elements as $element ) {
10✔
NEW
94
                        $element->outertext .= ' element:' . $element->tag_start;
×
95
                }
96
        }
97

98
        /**
99
         * Text around element contains
100
         *
101
         * @param obj     $element object for element.
102
         * @param string  $contains value contains.
103
         * @param integer $distance_after_element number.
104
         * @return int
105
         */
106
        public function text_around_element_contains( $element, $contains, $distance_after_element = 25 ) {
107
                // to account for the start of the search term getting cut off add the length of the search to the distance.
108
                $total_distance       = $distance_after_element + strlen( $contains );
8✔
109
                $marker               = $element->plaintext;
8✔
110
                $tag_end              = stripos( $this->plaintext, $marker ) + strlen( $marker );
8✔
111
                $next_marker_position = stripos( $this->plaintext, 'ac_element', $tag_end ) !== false ? stripos( $this->plaintext, 'ac_element', $tag_end ) : strlen( $this->plaintext );
8✔
112
                $found_position       = stripos( $this->plaintext, $contains, $tag_end );
8✔
113

114
                if ( false === $found_position || $found_position > $next_marker_position ) {
8✔
115
                        return false;
4✔
116
                }
117

118
                $distance = $found_position - $tag_end;
4✔
119

120
                return $distance < $total_distance;
4✔
121
        }
122

123
        /**
124
         * Find Media Embeds
125
         *
126
         * @param boolean $include_audio boolean to include audio.
127
         * @return array
128
         */
129
        public function find_media_embeds( $include_audio = true ) {
130
                // all elements with sources.
131
                $elements_with_src = $this->find( '[src]' );
10✔
132
                $elements          = [];
10✔
133
                $audio             = $include_audio ? $this->audio_ext : [];
10✔
134
                $extensions        = array_merge( $this->video_ext, $this->embed_sources, $audio );
10✔
135
                if ( $elements_with_src ) {
10✔
136
                        $elements = array_filter(
×
137
                                $elements_with_src,
×
138
                                function ( $element ) use ( $extensions ) {
×
139
                                        return edac_is_item_using_matching_extension( $element->getAttribute( 'href' ), $extensions );
×
140
                                }
×
141
                        );
×
142
                }
143

144
                return array_merge( $elements, $this->find( '.is-type-video' ) );
10✔
145
        }
146

147
        /**
148
         * Find Linked Media
149
         *
150
         * @param boolean $include_audio boolean to include audio.
151
         * @return array
152
         */
153
        public function find_linked_media( $include_audio = true ) {
154
                $elements_with_href = $this->find( '[href]' );
10✔
155
                $elements           = [];
10✔
156
                $audio              = $include_audio ? $this->audio_ext : [];
10✔
157
                $extensions         = array_merge( $this->video_ext, $audio );
10✔
158
                if ( $elements_with_href ) {
10✔
159
                        $elements = array_filter(
10✔
160
                                $elements_with_href,
10✔
161
                                function ( $element ) use ( $extensions ) {
10✔
162
                                        return edac_is_item_using_matching_extension( $element->getAttribute( 'href' ), $extensions );
10✔
163
                                }
10✔
164
                        );
10✔
165
                }
166

167
                return $elements;
10✔
168
        }
169
}
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