Skip to content

Commit

Permalink
Merge pull request #645 from equalizedigital/release/1.13.0
Browse files Browse the repository at this point in the history
Release v1.13.0
  • Loading branch information
pattonwebz committed May 29, 2024
2 parents 6039627 + ca4e60c commit 55a2aef
Show file tree
Hide file tree
Showing 25 changed files with 333 additions and 507 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/deploy-on-release-to-dot-org.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ jobs:
- name: WordPress plugin deploy
id: deploy
uses: 10up/action-wordpress-plugin-deploy@stable
with:
dry-run: true # exists to prevent accidental deploys during testing
env:
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
Expand Down
4 changes: 2 additions & 2 deletions accessibility-checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Plugin Name: Accessibility Checker
* Plugin URI: https://a11ychecker.com
* Description: Audit and check your website for accessibility before you hit publish. In-post accessibility scanner and guidance.
* Version: 1.12.0
* Version: 1.13.0
* Author: Equalize Digital
* Author URI: https://equalizedigital.com
* License: GPL-2.0+
Expand All @@ -35,7 +35,7 @@

// Current plugin version.
if ( ! defined( 'EDAC_VERSION' ) ) {
define( 'EDAC_VERSION', '1.12.0' );
define( 'EDAC_VERSION', '1.13.0' );
}

// Current database version.
Expand Down
2 changes: 1 addition & 1 deletion admin/class-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ function ( $a, $b ) {

$html .= '<button class="edac-details-rule-records-record-actions-ignore' . $ignore_class . '" aria-expanded="false" aria-controls="edac-details-rule-records-record-ignore-' . $row['id'] . '">' . EDAC_SVG_IGNORE_ICON . '<span class="edac-details-rule-records-record-actions-ignore-label">' . $ignore_label . '</span></button>';

if ( 'missing_headings' !== $rule['slug'] ) {
if ( ! isset( $rule['viewable'] ) || $rule['viewable'] ) {

$url = add_query_arg(
[
Expand Down
1 change: 1 addition & 0 deletions admin/class-enqueue-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public static function maybe_enqueue_admin_and_editor_app_scripts() {
$post_id,
[ 'edac_pageScanner' => 1 ]
),
'version' => EDAC_VERSION,
]
);

Expand Down
55 changes: 46 additions & 9 deletions includes/classes/class-rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function __construct() {
*/
public function init_hooks() {
add_action( 'init', [ $this, 'init_rest_routes' ] );
add_filter( 'edac_filter_js_violation_html', [ $this, 'filter_js_validation_html' ], 10, 3 );
}


Expand Down Expand Up @@ -161,7 +162,28 @@ function () use ( $ns, $version ) {
);
}


/**
* Filter the html of the js validation violation.
*
* This can be used to store additional data in the html of the violation.
*
* @since 1.13.0
* @param string $html The html of the violation.
* @param string $rule_id The id of the rule.
* @param array $violation The violation data.
*
* @return string
*/
public function filter_js_validation_html( string $html, string $rule_id, array $violation ): string {
// Add the selector to the violation message as empty paragraphs are almost always
// duplicate html fragments. Adding the selector makes it unique, so it can be saved.
if ( 'empty_paragraph_tag' === $rule_id ) {
$html .= $violation['selector'][0]
? '// {{ ' . $violation['selector'][0] . ' }}'
: '';
}
return $html;
}

/**
* REST handler that saves to the DB a list of js rule violations for a post.
Expand Down Expand Up @@ -194,11 +216,19 @@ public function set_post_scan_results( $request ) {

//phpcs:ignore Generic.Commenting.Todo.TaskFound
// TODO: setup a rules class for loading/filtering rules.
$rules = edac_register_rules();
$js_rule_ids = [];
$rules = edac_register_rules();
$js_rule_ids = [];
$combined_rule_ids = [];
foreach ( $rules as $rule ) {
if ( array_key_exists( 'ruleset', $rule ) && 'js' === $rule['ruleset'] ) {
$js_rule_ids[] = $rule['slug'];

// Some rules can be a grouping of other checks with different ids. This tracks those combined check IDs for later mapping.
if ( array_key_exists( 'combines', $rule ) && ! empty( $rule['combines'] ) ) {
foreach ( $rule['combines'] as $combine_rule_id ) {
$combined_rule_ids[ $combine_rule_id ] = $rule['slug'];
}
}
}
}

Expand Down Expand Up @@ -226,17 +256,20 @@ public function set_post_scan_results( $request ) {
foreach ( $violations as $violation ) {
$rule_id = $violation['ruleId'];

if ( in_array( $rule_id, $js_rule_ids, true ) ) {
// If this rule is a combined rule then map it to the actual reporting rule ID.
$actual_rule_id = array_key_exists( $rule_id, $combined_rule_ids ) ? $combined_rule_ids[ $rule_id ] : $rule_id;

if ( in_array( $actual_rule_id, $js_rule_ids, true ) ) {

// This rule is one that we've included in our js ruleset.

$html = $violation['html'];
$html = apply_filters( 'edac_filter_js_violation_html', $violation['html'], $rule_id, $violation );
$impact = $violation['impact']; // by default, use the impact setting from the js rule.

//phpcs:ignore Generic.Commenting.Todo.TaskFound
// TODO: setup a rules class for loading/filtering rules.
foreach ( $rules as $rule ) {
if ( $rule['slug'] === $rule_id ) {
if ( $rule['slug'] === $actual_rule_id ) {
$impact = $rule['rule_type']; // if we are defining the rule_type in php rules config, use that instead of the js rule's impact setting.
}
}
Expand All @@ -255,9 +288,9 @@ public function set_post_scan_results( $request ) {
* @param string $rule_id The rule ID.
* @param string $type The type of validation which is always 'js' in this path.
*/
do_action( 'edac_before_rule', $post_id, $rule_id, 'js' );
do_action( 'edac_before_rule', $post_id, $actual_rule_id, 'js' );

( new Insert_Rule_Data() )->insert( $post, $rule_id, $impact, $html );
( new Insert_Rule_Data() )->insert( $post, $actual_rule_id, $impact, $html );

/**
* Fires after a rule is run against the content.
Expand All @@ -270,7 +303,7 @@ public function set_post_scan_results( $request ) {
* @param string $rule_id The rule ID.
* @param string $type The type of validation which is always 'js' in this path.
*/
do_action( 'edac_after_rule', $post_id, $rule_id, 'js' );
do_action( 'edac_after_rule', $post_id, $actual_rule_id, 'js' );

}
}
Expand All @@ -297,6 +330,10 @@ public function set_post_scan_results( $request ) {
// store a record of this scan in the post's meta.
update_post_meta( $post_id, '_edac_post_checked_js', time() );

if ( true === $request['isFailure'] ) {
update_post_meta( $post_id, '_edac_post_checked_js_failure', time() );
}

return new \WP_REST_Response(
[
'success' => true,
Expand Down
Loading

0 comments on commit 55a2aef

Please sign in to comment.