• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In
Build has been canceled!

equalizedigital / accessibility-checker / 25881928913

14 May 2026 07:49PM UTC coverage: 57.657% (+0.1%) from 57.515%
25881928913

push

github

web-flow
Merge pull request #1679 from equalizedigital/william/add-extra-compatibility-checking-info

Add a SystemInfo class for getting theme, plugin and env type

42 of 54 new or added lines in 2 files covered. (77.78%)

1 existing line in 1 file now uncovered.

5538 of 9605 relevant lines covered (57.66%)

4.58 hits per line

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

85.42
/includes/classes/SystemInfo/SystemInfo.php
1
<?php
2
/**
3
 * System information helpers.
4
 *
5
 * @package Accessibility_Checker
6
 */
7

8
namespace EqualizeDigital\AccessibilityChecker\SystemInfo;
9

10
use WP_Theme;
11

12
/**
13
 * Collects active plugin and theme information.
14
 */
15
class SystemInfo {
16

17
        /**
18
         * Returns active plugins with name, slug, and version.
19
         *
20
         * @return array<int, array<string, string>>
21
         */
22
        public static function get_active_plugins() {
23
                $active_plugins = [];
24✔
24

25
                foreach ( wp_get_active_and_valid_plugins() as $plugin_path ) {
24✔
NEW
26
                        $plugin_data      = get_plugin_data( $plugin_path, false, false );
×
NEW
27
                        $active_plugins[] = [
×
NEW
28
                                'name'    => $plugin_data['Name'] ?? '',
×
NEW
29
                                'slug'    => self::get_plugin_slug_from_path( $plugin_path ),
×
NEW
30
                                'version' => $plugin_data['Version'] ?? '',
×
NEW
31
                        ];
×
32
                }
33

34
                return $active_plugins;
24✔
35
        }
36

37
        /**
38
         * Gets the plugin slug from a plugin file path.
39
         *
40
         * @param string $plugin_path Path to a plugin file.
41
         * @return string
42
         */
43
        public static function get_plugin_slug_from_path( $plugin_path ) {
44
                if ( ! is_string( $plugin_path ) || '' === $plugin_path ) {
8✔
45
                        return '';
4✔
46
                }
47

48
                $relative = plugin_basename( $plugin_path );
4✔
49
                $dir      = dirname( $relative );
4✔
50

51
                if ( '.' !== $dir ) {
4✔
52
                        return $dir;
2✔
53
                }
54

55
                return basename( $relative, '.php' );
2✔
56
        }
57

58
        /**
59
         * Returns active theme information, including parent data for child themes.
60
         *
61
         * @return array<string, mixed>
62
         */
63
        public static function get_active_theme() {
64
                $theme_data = wp_get_theme();
24✔
65

66
                $active_theme = self::get_theme_data_collection( $theme_data );
24✔
67

68
                $active_theme['accessibility_ready'] = self::is_theme_accessibility_ready( $theme_data );
24✔
69

70
                $active_theme['parent_theme'] = [];
24✔
71
                if ( $theme_data->parent() ) {
24✔
NEW
72
                        $active_theme['parent_theme'] = self::get_theme_data_collection( $theme_data->parent() );
×
73
                }
74

75
                return $active_theme;
24✔
76
        }
77

78
        /**
79
         * Gets theme details as a normalized collection.
80
         *
81
         * @param mixed $theme Theme object.
82
         * @return array<string, mixed>
83
         */
84
        public static function get_theme_data_collection( $theme ) {
85
                if ( ! is_a( $theme, '\\WP_Theme' ) ) {
32✔
86
                        return [];
2✔
87
                }
88

89
                return [
30✔
90
                        'name'    => $theme->get( 'Name' ) ?? '',
30✔
91
                        'slug'    => $theme->get_stylesheet() ?? '',
30✔
92
                        'version' => $theme->get( 'Version' ) ?? '',
30✔
93
                        'tags'    => $theme->get( 'Tags' ) ?? [],
30✔
94
                ];
30✔
95
        }
96

97
        /**
98
         * Checks whether theme or parent theme is tagged accessibility-ready.
99
         *
100
         * @param WP_Theme $theme_data Theme object to check.
101
         * @return bool
102
         */
103
        public static function is_theme_accessibility_ready( WP_Theme $theme_data ) {
104
                $tags = is_array( $theme_data->get( 'Tags' ) ) ? $theme_data->get( 'Tags' ) : [];
30✔
105

106
                if ( $theme_data->parent() ) {
30✔
107
                        $parent_tags = $theme_data->parent()->get( 'Tags' );
2✔
108
                        $tags        = array_merge( $tags, is_array( $parent_tags ) ? $parent_tags : [] );
2✔
109
                }
110

111
                return in_array( 'accessibility-ready', $tags, true );
30✔
112
        }
113

114
        /**
115
         * Gets the current WordPress environment type.
116
         *
117
         * @return string
118
         */
119
        public static function get_environment_type() {
120
                return function_exists( 'wp_get_environment_type' ) ? wp_get_environment_type() : 'production';
22✔
121
        }
122

123
        /**
124
         * Gets the current WordPress version.
125
         *
126
         * @return string
127
         */
128
        public static function get_wordpress_version() {
129
                return (string) get_bloginfo( 'version' );
22✔
130
        }
131

132
        /**
133
         * Gets the current PHP version.
134
         *
135
         * @return string
136
         */
137
        public static function get_php_version() {
138
                return (string) phpversion();
22✔
139
        }
140

141
        /**
142
         * Gets a payload-ready set of system fields for license API requests.
143
         *
144
         * @return array<string, mixed>
145
         */
146
        public static function get_license_request_context() {
147
                $active_plugins = wp_json_encode( self::get_active_plugins() );
18✔
148
                $active_theme   = wp_json_encode( self::get_active_theme() );
18✔
149

150
                return [
18✔
151
                        'environment'    => self::get_environment_type(),
18✔
152
                        'wp_version'     => self::get_wordpress_version(),
18✔
153
                        'php_version'    => self::get_php_version(),
18✔
154
                        'active_plugins' => false !== $active_plugins ? $active_plugins : '[]',
18✔
155
                        'active_theme'   => false !== $active_theme ? $active_theme : '{}',
18✔
156
                ];
18✔
157
        }
158
}
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