Skip to content

Commit 0c1949e

Browse files
authored
Merge pull request #815 from equalizedigital/release/1.16.3
Release v1.16.3
2 parents 7443360 + a670251 commit 0c1949e

8 files changed

Lines changed: 188 additions & 6 deletions

File tree

accessibility-checker.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Plugin Name: Accessibility Checker
1111
* Plugin URI: https://a11ychecker.com
1212
* Description: Audit and check your website for accessibility before you hit publish. In-post accessibility scanner and guidance.
13-
* Version: 1.16.2
13+
* Version: 1.16.3
1414
* Author: Equalize Digital
1515
* Author URI: https://equalizedigital.com
1616
* License: GPL-2.0+
@@ -35,7 +35,7 @@
3535

3636
// Current plugin version.
3737
if ( ! defined( 'EDAC_VERSION' ) ) {
38-
define( 'EDAC_VERSION', '1.16.2' );
38+
define( 'EDAC_VERSION', '1.16.3' );
3939
}
4040

4141
// Current database version.

admin/site-health/class-free.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
namespace EDAC\Admin\SiteHealth;
1010

11+
use EqualizeDigital\AccessibilityChecker\Fixes\FixesManager;
12+
1113
/**
1214
* Loads free information into Site Health
1315
*
@@ -28,6 +30,18 @@ public function __construct() {
2830
* @return array
2931
*/
3032
public function get() {
33+
// Get only the non-pro fixes.
34+
$fixes = array_filter(
35+
FixesManager::get_instance()->get_fixes_settings(),
36+
function ( $fix ) {
37+
return ! $fix['is_pro'];
38+
}
39+
);
40+
// remove the is_pro flag, this isn't needed in the output.
41+
foreach ( $fixes as $key => $fix ) {
42+
unset( $fixes[ $key ]['is_pro'] );
43+
}
44+
3145
return [
3246
'label' => __( 'Accessibility Checker — Free', 'accessibility-checker' ),
3347
'fields' => [
@@ -87,6 +101,10 @@ public function get() {
87101
'label' => 'DB Table Count',
88102
'value' => absint( edac_database_table_count( 'accessibility_checker' ) ),
89103
],
104+
'fixes' => [
105+
'label' => 'Fixes',
106+
'value' => esc_html( wp_json_encode( $fixes ) ),
107+
],
90108
],
91109
];
92110
}

admin/site-health/class-pro.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
namespace EDAC\Admin\SiteHealth;
1010

11+
use EqualizeDigital\AccessibilityChecker\Fixes\FixesManager;
12+
1113
/**
1214
* Loads pro information into Site Health
1315
*
@@ -28,6 +30,19 @@ public function __construct() {
2830
* @return array
2931
*/
3032
public function get() {
33+
34+
// Get only the pro fixes.
35+
$fixes = array_filter(
36+
FixesManager::get_instance()->get_fixes_settings(),
37+
function ( $fix ) {
38+
return $fix['is_pro'];
39+
}
40+
);
41+
// remove the is_pro flag, this isn't needed in the output.
42+
foreach ( $fixes as $key => $fix ) {
43+
unset( $fixes[ $key ]['is_pro'] );
44+
}
45+
3146
return [
3247
'label' => __( 'Accessibility Checker — Pro', 'accessibility-checker' ),
3348
'fields' => [
@@ -71,6 +86,10 @@ public function get() {
7186
'label' => 'Ignores DB Table Count',
7287
'value' => absint( edac_database_table_count( 'accessibility_checker_global_ignores' ) ),
7388
],
89+
'fixes' => [
90+
'label' => 'Fixes',
91+
'value' => esc_html( wp_json_encode( $fixes ) ),
92+
],
7493
],
7594
];
7695
}

includes/classes/Fixes/Fix/AddLabelToUnlabelledFormFieldsFix.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static function get_slug(): string {
3131
* @return string
3232
*/
3333
public static function get_nicename(): string {
34-
return __( 'Add Size & Type To File Links', 'accessibility-checker' );
34+
return __( 'Add Labels to Unlabelled Form Fields', 'accessibility-checker' );
3535
}
3636

3737
/**

includes/classes/Fixes/FixesManager.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,30 @@ public function get_fix( $slug ) {
158158
return isset( $this->fixes[ $slug ] ) ? $this->fixes[ $slug ] : null;
159159
}
160160

161+
/**
162+
* Get the fixes settings.
163+
*
164+
* Returns an array of all the fix settings and their values along with a pro or not flag.
165+
*
166+
* @return array
167+
*/
168+
public function get_fixes_settings() {
169+
$fixes_array = [];
170+
foreach ( $this->fixes as $fix ) {
171+
172+
$fields = [];
173+
foreach ( $fix->get_fields_array() as $field_slug => $field ) {
174+
$fields[ $field_slug ] = get_option( $field_slug, $field['default'] ?? 0 );
175+
}
176+
177+
$fixes_array[ $fix::get_slug() ] = [
178+
'fields' => $fields,
179+
'is_pro' => isset( $fix->is_pro ) ? $fix->is_pro : false,
180+
];
181+
}
182+
return $fixes_array;
183+
}
184+
161185
/**
162186
* Register the fixes.
163187
*/

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "accessibility-checker",
3-
"version": "1.16.2",
3+
"version": "1.16.3",
44
"description": "Audit and check your website for accessibility before you hit publish. In-post accessibility scanner and guidance.",
55
"author": "Equalize Digital",
66
"license": "GPL-2.0+",

readme.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: equalizedigital, alh0319, stevejonesdev
33
Tags: accessibility, accessible, wcag, ada, WP accessibility
44
Requires at least: 6.2
55
Tested up to: 6.7.0
6-
Stable tag: 1.16.2
6+
Stable tag: 1.16.3
77
License: GPLv2 or later
88
License URI: http://www.gnu.org/licenses/gpl-2.0.html
99

@@ -171,8 +171,11 @@ No, Accessibility Checker runs completely on your server and does not require yo
171171

172172
== Changelog ==
173173

174-
= 1.16.2 =
174+
= 1.16.3 =
175+
* Enhancement: Add Fix settings to site health info panels.
176+
* Fixed: Corrected a string that was misplaced in a fix.
175177

178+
= 1.16.2 =
176179
* Enhancement: Use better names for fix modal titles.
177180
* Enhancement: Improve the link_pdf rule to detect more accurately.
178181
* Enhancement: Improve the link_ms_office_doc rule to detect more accurately.
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<?php
2+
/**
3+
* Test class for FixesManager.
4+
*
5+
* @package accessibility-checker
6+
*/
7+
8+
use PHPUnit\Framework\TestCase;
9+
use EqualizeDigital\AccessibilityChecker\Fixes\FixesManager;
10+
use EqualizeDigital\AccessibilityChecker\Fixes\FixInterface;
11+
12+
/**
13+
* Unit tests for the FixesManager class.
14+
*/
15+
class FixesManagerTest extends WP_UnitTestCase {
16+
17+
/**
18+
* Setup the test environment by resetting the instance before each test.
19+
*
20+
* @return void
21+
*/
22+
public function setUp(): void {
23+
parent::setUp();
24+
// Reset the instance before each test.
25+
$reflection = new ReflectionClass( FixesManager::class );
26+
$instance = $reflection->getProperty( 'instance' );
27+
$instance->setAccessible( true );
28+
$instance->setValue( null, null );
29+
}
30+
31+
/**
32+
* Tear down the test environment by closing Mockery.
33+
*
34+
* @return void
35+
*/
36+
public function tearDown(): void {
37+
Mockery::close();
38+
}
39+
40+
/**
41+
* Test that the instance retuns an empty array when no fixes are registered.
42+
*
43+
* @return void
44+
*/
45+
public function test_get_fixes_settings_returns_empty_array_when_no_fixes() {
46+
$fixes_manager = FixesManager::get_instance();
47+
$this->assertEmpty( $fixes_manager->get_fixes_settings() );
48+
}
49+
50+
/**
51+
* Test that the instance returns the correct structure when fixes are registered.
52+
*
53+
* @return void
54+
*/
55+
public function test_get_fixes_settings_returns_correct_structure() {
56+
$fix_mock = Mockery::mock( 'EqualizeDigital\AccessibilityChecker\Fixes\Fix\AddFileSizeAndTypeToLinkedFilesFix' );
57+
$fix_mock->shouldReceive( 'get_slug' )->andReturn( 'mock_fix' );
58+
$fix_mock->shouldReceive( 'get_fields_array' )->andReturn(
59+
[
60+
'field1' => [ 'default' => 'value1' ],
61+
'field2' => [ 'default' => 'value2' ],
62+
]
63+
);
64+
$fix_mock->is_pro = true;
65+
66+
$fixes_manager = FixesManager::get_instance();
67+
$reflection = new ReflectionClass( $fixes_manager );
68+
$fixes_property = $reflection->getProperty( 'fixes' );
69+
$fixes_property->setAccessible( true );
70+
$fixes_property->setValue( $fixes_manager, [ 'mock_fix' => $fix_mock ] );
71+
72+
$expected = [
73+
'mock_fix' => [
74+
'fields' => [
75+
'field1' => 'value1',
76+
'field2' => 'value2',
77+
],
78+
'is_pro' => true,
79+
],
80+
];
81+
82+
$this->assertEquals( $expected, $fixes_manager->get_fixes_settings() );
83+
}
84+
85+
/**
86+
* Test that the instance returns the default values when options aren't set.
87+
*
88+
* @return void
89+
*/
90+
public function test_get_fixes_settings_uses_default_values() {
91+
$fix_mock = Mockery::mock( 'EqualizeDigital\AccessibilityChecker\Fixes\Fix\AddFileSizeAndTypeToLinkedFilesFix' );
92+
$fix_mock->shouldReceive( 'get_slug' )->andReturn( 'mock_fix' );
93+
$fix_mock->shouldReceive( 'get_fields_array' )->andReturn(
94+
[
95+
'field1' => [ 'default' => 'default_value1' ],
96+
'field2' => [ 'default' => 'default_value2' ],
97+
]
98+
);
99+
100+
$fixes_manager = FixesManager::get_instance();
101+
$reflection = new ReflectionClass( $fixes_manager );
102+
$fixes_property = $reflection->getProperty( 'fixes' );
103+
$fixes_property->setAccessible( true );
104+
$fixes_property->setValue( $fixes_manager, [ 'mock_fix' => $fix_mock ] );
105+
106+
$expected = [
107+
'mock_fix' => [
108+
'fields' => [
109+
'field1' => 'default_value1',
110+
'field2' => 'default_value2',
111+
],
112+
'is_pro' => false,
113+
],
114+
];
115+
116+
$this->assertEquals( $expected, $fixes_manager->get_fixes_settings() );
117+
}
118+
}

0 commit comments

Comments
 (0)