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

equalizedigital / accessibility-checker / 15452164054

04 Jun 2025 08:32PM UTC coverage: 28.973%. First build
15452164054

Pull #1004

github

web-flow
Merge 28c013970 into 147ba9c27
Pull Request #1004: Release v1.24.0

7 of 92 new or added lines in 13 files covered. (7.61%)

1495 of 5160 relevant lines covered (28.97%)

1.5 hits per line

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

0.0
/admin/AdminPage/FixesPage.php
1
<?php
2
/**
3
 * Admin page that holds the list of fix options.
4
 *
5
 * @package Accessibility_Checker
6
 */
7

8
namespace EqualizeDigital\AccessibilityChecker\Admin\AdminPage;
9

10
/**
11
 * Registers the Fixes page and it's settings.
12
 *
13
 * Sections and settings are passed through filters so that other plugins can add their own.
14
 *
15
 * @since 1.16.0
16
 */
17
class FixesPage implements PageInterface {
18

19
        use FixesSettingType\Checkbox;
20
        use FixesSettingType\Text;
21

22
        /**
23
         * The capability required to access the settings page.
24
         *
25
         * @var string
26
         */
27
        private $settings_capability;
28

29
        const PAGE_TAB_SLUG = 'fixes';
30

31
        /**
32
         * The settings page slug which all sections, settings and fields are registered to.
33
         *
34
         * @var string
35
         */
36
        const SETTINGS_SLUG = 'edac_settings_fixes';
37

38
        /**
39
         * Constructor.
40
         *
41
         * @param string $settings_capability The capability required to access the settings page.
42
         */
43
        public function __construct( $settings_capability ) {
44
                $this->settings_capability = $settings_capability;
×
45
        }
46

47
        /**
48
         * Add the settings sections and fields and setup it's tabs and filter in for the content.
49
         */
50
        public function add_page() {
51

52
                $this->register_settings_sections();
×
53
                $this->register_fields_and_settings();
×
54

55
                add_filter( 'edac_filter_admin_scripts_slugs', [ $this, 'add_slug_to_admin_scripts' ] );
×
56
                add_filter( 'edac_filter_remove_admin_notices_screens', [ $this, 'add_slug_to_admin_notices' ] );
×
57
                add_filter( 'edac_filter_settings_tab_items', [ $this, 'add_fixes_tab' ] );
×
58
                add_action( 'edac_settings_tab_content', [ $this, 'add_fixes_tab_content' ], 11, 1 );
×
59
        }
60

61
        /**
62
         * Add fixes tab to settings page.
63
         *
64
         * @param  array $settings_tab_items arrray of tab items.
65
         * @return array
66
         */
67
        public function add_fixes_tab( $settings_tab_items ) {
68

69
                $scan_tab = [
×
70
                        'slug'  => 'fixes',
×
NEW
71
                        'label' => __( 'Fixes', 'accessibility-checker' ),
×
72
                        'order' => 2,
×
73
                ];
×
74
                array_push( $settings_tab_items, $scan_tab );
×
75

76
                return $settings_tab_items;
×
77
        }
78

79
        /**
80
         * Licence fixes tab content to settings page.
81
         *
82
         * @param  string $tab name of tab.
83
         * @return void
84
         */
85
        public function add_fixes_tab_content( $tab ) {
86
                if ( 'fixes' === $tab ) {
×
87
                        include EDAC_PLUGIN_DIR . '/partials/admin-page/fixes-page.php';
×
88
                }
89
        }
90

91
        /**
92
         * Add the fixes slug to the admin scripts.
93
         *
94
         * @param array $slugs The slugs that are already added.
95
         * @return array
96
         */
97
        public function add_slug_to_admin_scripts( $slugs ) {
98
                $slugs[] = 'accessibility_checker_' . self::PAGE_TAB_SLUG;
×
99
                return $slugs;
×
100
        }
101

102
        /**
103
         * Add the fixes slug to the admin notices.
104
         *
105
         * @param array $slugs The slugs that are already added.
106
         * @return array
107
         */
108
        public function add_slug_to_admin_notices( $slugs ) {
109
                $slugs[] = 'accessibility-checker_page_accessibility_checker_' . self::PAGE_TAB_SLUG;
×
110
                return $slugs;
×
111
        }
112

113
        /**
114
         * Render the page.
115
         */
116
        public function render_page() {
117
                include_once EDAC_PLUGIN_DIR . 'partials/admin-page/fixes-page.php';
×
118
        }
119

120
        /**
121
         * Register the settings sections for this options page.
122
         *
123
         * Sections are passed through a filter so that other plugins can add their own.
124
         */
125
        public function register_settings_sections() {
126

127
                /**
128
                 * Filter the sections that are registered for the fixes settings page.
129
                 *
130
                 * @since 1.16.0
131
                 *
132
                 * @param array $sections The sections that are to be registered for the fixes settings page. Must have the id as the key and an array with a title and callback.
133
                 */
134
                $sections = apply_filters(
×
135
                        'edac_filter_fixes_settings_sections',
×
136
                        [
×
137
                                'edac_fixes_general' => [
×
138
                                        'title'    => __( 'General Fixes', 'accessibility-checker' ),
×
139
                                        'callback' => [ $this, 'fixes_section_general_cb' ],
×
140
                                ],
×
141
                        ]
×
142
                );
×
143

144
                foreach ( $sections as $section_id => $section ) {
×
145
                        if ( ! is_string( $section_id ) || ! isset( $section['title'], $section['callback'] ) ) {
×
146
                                continue;
×
147
                        }
148

149
                        // The callback must be callable otherwise it will throw an error.
150
                        if ( ! is_callable( $section['callback'] ) ) {
×
151
                                continue;
×
152
                        }
153

154
                        add_settings_section(
×
155
                                $section_id,
×
156
                                $section['title'],
×
157
                                $section['callback'],
×
158
                                self::SETTINGS_SLUG,
×
159
                        );
×
160
                }
161
        }
162

163
        /**
164
         * Register the settings fields and settings for this options page.
165
         *
166
         * It passed through a filter so that other plugins can add their own settings.
167
         */
168
        public function register_fields_and_settings() {
169
                /**
170
                 * Filter the fields that are registered for the fixes settings page.
171
                 *
172
                 * @since 1.16.0
173
                 *
174
                 * @param array $fields The fields that are to be registered for the fixes settings page.
175
                 */
176
                $fields = apply_filters( 'edac_filter_fixes_settings_fields', [] );
×
177

178
                foreach ( $fields as $field_id => $field ) {
×
179

180
                        $field_type = $field['type'] ?? 'checkbox';
×
181
                        $sanitizer  = $field['sanitize_callback'] ?? [ $this, 'sanitize_checkbox' ];
×
182

183
                        $is_upsell = $field['upsell'] ?? false;
×
184

185
                        add_settings_field(
×
186
                                $field_id,
×
187
                                $field['label'],
×
188
                                $field['callback'] ?? [ $this, $field_type ],
×
189
                                self::SETTINGS_SLUG,
×
190
                                $field['section'] ?? 'edac_fixes_general',
×
191
                                [
×
192
                                        'name'          => $field_id,
×
193
                                        'labelledby'    => $field_id,
×
194
                                        'description'   => $field['description'] ?? '',
×
195
                                        'condition'     => $field['condition'] ?? '',
×
196
                                        'required_when' => $field['required_when'] ?? '',
×
197
                                        'default'       => $field['default'] ?? '',
×
198
                                        'upsell'        => $is_upsell,
×
199
                                        'help_id'       => $field['help_id'] ?? '',
×
200
                                        'label'         => $field['label'] ?? '',
×
201
                                ]
×
202
                        );
×
203

204
                        register_setting( self::SETTINGS_SLUG, $field_id, $sanitizer );
×
205
                }
206
        }
207

208
        /**
209
         * Callback for the general settings section that renders a description for it.
210
         */
211
        public function fixes_section_general_cb() {
212
                echo '<p>' . esc_html__( 'These fixes help improve accessibility by modifying HTML elements and behaviors on your site.', 'accessibility-checker' ) . '</p>';
×
213
        }
214
}
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