Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/v1.10.0 #538

Merged
merged 87 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
29f5968
Add a new class to hold the purge methods that are being deprecated a…
pattonwebz Feb 23, 2024
cb12b48
Move the purche functions to the new Purge_Posts_Data class
pattonwebz Feb 23, 2024
c0ced84
Add type hints to the params in the new methods
pattonwebz Feb 23, 2024
166a6f9
Fix the return types on delete_cpt_posts as it can return much more t…
pattonwebz Feb 23, 2024
cc43278
Swap to the migrated class method for deleting post data when called …
pattonwebz Feb 23, 2024
caaa78a
Swap to the migrated class method delete_cpt_posts when purging data …
pattonwebz Feb 23, 2024
5138ba7
Flag the old purge functions as deprecated and move them to deprecate…
pattonwebz Feb 23, 2024
67f2b9a
Adds a first pass of tests for the moved purge methods
pattonwebz Feb 23, 2024
70cbbc1
Update tests for Purge_Post_Data to succeed and test better paths
pattonwebz Feb 23, 2024
0dc36a6
Before performing any queries check if the passed post_type even exis…
pattonwebz Feb 23, 2024
5bb1bf8
Merge branch 'develop' into william/463/convert-purge-functions-to-cl…
pattonwebz Feb 23, 2024
38e6fe7
Replace the code in the new deprecated methods with calls to the repl…
pattonwebz Feb 23, 2024
ca91cba
Correct some comments to be more accurate to the code
pattonwebz Feb 23, 2024
741400c
Create a class to hold the insert rule data function
pattonwebz Feb 23, 2024
6cc95e4
Move code from `edac_insert_rule_data` to new class with method name …
pattonwebz Feb 23, 2024
25e06d0
Add type hints to the params passed to the `insert` method
pattonwebz Feb 23, 2024
cfed3d4
Add an early bail to the `insert` method when all params are not pass…
pattonwebz Feb 23, 2024
6a786c9
Move the `edac_insert_rule_data` function to deprecated.php
pattonwebz Feb 23, 2024
c7087bf
Swap `edac_insert_rule_data` calls to use new class method
pattonwebz Feb 23, 2024
6dabce7
Remove the insert.php file from the requires calls
pattonwebz Feb 23, 2024
98803a9
Add a basic test for expected return types from rule data inserter
pattonwebz Feb 23, 2024
1381411
Merge pull request #515 from equalizedigital/release/v1.9.0
SteveJonesDev Feb 27, 2024
857bea5
Move the wp-trash-post action hook to the admin class, so it only get…
pattonwebz Feb 27, 2024
834e096
Define the $valid_post_id property explicitly
pattonwebz Feb 27, 2024
fce2373
Need to hook the delete_post method to wp-trash-post now since this h…
pattonwebz Feb 27, 2024
407e997
Add `since` tags and `deprecated` tags with 2.0.0 as slated version s…
pattonwebz Feb 27, 2024
b794e2d
Update to use WP_UnitTestCase for purge tests
pattonwebz Feb 28, 2024
2f9c2b2
Add a test for delete_cpt_posts and verify deprecated functions are f…
pattonwebz Feb 28, 2024
80fdd3e
Fix table name in query `t1` -> `T1`
pattonwebz Feb 28, 2024
f15b4a0
Add lint-staged as dev dependency and when linting have it only check…
pattonwebz Feb 28, 2024
3ac1331
Add a new command to run phpcs on pre-commit only on the files staged…
pattonwebz Feb 28, 2024
b04968e
Fix spacing in package.json for new script
pattonwebz Feb 28, 2024
227dcaa
Update test to verify when data goes into the database and that it is…
pattonwebz Feb 28, 2024
a347ac6
Add a phpcs comment indicating creation of the exception is intention…
pattonwebz Feb 28, 2024
f1d4c25
Remove some single use variables as they were not adding to readabili…
pattonwebz Feb 28, 2024
7452dec
Update some deprecated version numbers to reflect milestone
pattonwebz Feb 28, 2024
34c28d5
Use correct milestone in since and deprecated tagging
pattonwebz Feb 28, 2024
0bad8e2
Merge pull request #519 from equalizedigital/hotfix/rules-filter-timing
SteveJonesDev Feb 28, 2024
974f3ed
Remove sleep() from test case
pattonwebz Feb 28, 2024
517db64
Add .css test in webpack to catch css in js
pattonwebz Feb 28, 2024
5333358
Import notyf css inside helpers.js to avoid loading from cdn
pattonwebz Feb 28, 2024
ff9bc6c
Add a test class and some initial test data for aria-hidden rule
pattonwebz Mar 7, 2024
7f57cde
Add helpers prep and pass markup to the aria-hidden test rule
pattonwebz Mar 7, 2024
70133ba
Add tests that cover the current functionality of aria-hidden rule
pattonwebz Mar 7, 2024
a04700f
Add tests to cover newly requested functionality from #448
pattonwebz Mar 7, 2024
f3258bc
Make aria-hidden rule handle elements that are hidden but presentational
pattonwebz Mar 7, 2024
6aa59e7
Make aria-hidden not flag elements if their parent has a non-empty label
pattonwebz Mar 7, 2024
e5abfe8
Merge pull request #526 from equalizedigital/william/hotfix/frontend-…
SteveJonesDev Mar 11, 2024
9c8cd68
Merge pull request #517 from pattonwebz/william/have-phpcs-run-only-o…
pattonwebz Mar 12, 2024
b47607a
Add some handling for sibling nodes are are likely screen reader elem…
pattonwebz Mar 12, 2024
e80da13
Remove test case for visible text checking in aria-hidden rules
pattonwebz Mar 12, 2024
36bd601
Add `@ since` tags for new functions added
pattonwebz Mar 12, 2024
6cde56f
Avoid single user vars in test helper function
pattonwebz Mar 12, 2024
5c194ab
Use dataProvider for passing and some failing screen-reader classes o…
pattonwebz Mar 12, 2024
5b8b577
Do exact match on screen-reader classes rather than contains checks t…
pattonwebz Mar 12, 2024
681ac67
Merge pull request #520 from pattonwebz/william/510/load-notif-from-l…
pattonwebz Mar 12, 2024
d34c5e3
Add some tests for the missing_transcript rule
pattonwebz Mar 12, 2024
15f3641
Adjust find_linked_media to extract and match against only the extens…
pattonwebz Mar 12, 2024
0582447
Use a more robust set of checks for early bail condition before reach…
pattonwebz Mar 13, 2024
b1f09eb
Merge pull request #534 from equalizedigital/william/531/add-capabili…
SteveJonesDev Mar 14, 2024
3089283
Ensure that parent elements that are NOT buttons or links don't have …
pattonwebz Mar 15, 2024
24a1eb0
Remove unnecessary line space
pattonwebz Mar 15, 2024
dfc56bf
Update the `@ since` tags to v1.10.0
pattonwebz Mar 15, 2024
f3f2757
Improve some of the docblock descriptions
pattonwebz Mar 15, 2024
c676210
Sanitize rule data that comes back through filter to make sure it's s…
pattonwebz Mar 15, 2024
a233cf0
Try detect visible text by stripping tags from parent if there is mor…
pattonwebz Mar 15, 2024
48ba4e7
Add test for visible text type markups
pattonwebz Mar 15, 2024
aaa9b11
Update version strings in since and deprecated tags
pattonwebz Mar 15, 2024
85f3596
Merge pull request #530 from equalizedigital/william/511/missing_tran…
pattonwebz Mar 15, 2024
43405f7
Merge pull request #512 from pattonwebz/william/463/convert-purge-fun…
pattonwebz Mar 15, 2024
023c510
Try make conditions more readable
pattonwebz Mar 15, 2024
460ae3f
Fix ignore->ignre in sanitizer
pattonwebz Mar 18, 2024
76b3dfb
Merge branch 'develop' into william/464/move-edac_insert_rule_data-to…
pattonwebz Mar 18, 2024
b3ca3d7
Merge branch 'develop' into william/464/move-edac_insert_rule_data-to…
pattonwebz Mar 18, 2024
f75ce37
Use a more strait-forward condition check for readability
pattonwebz Mar 18, 2024
2340406
Update the deprecated version string thrown when called
pattonwebz Mar 18, 2024
bacfd53
Merge pull request #523 from equalizedigital/william/448/improve-aria…
pattonwebz Mar 18, 2024
8b3485e
Merge pull request #513 from pattonwebz/william/464/move-edac_insert_…
pattonwebz Mar 18, 2024
3f6ab46
Bump version 1.9.3 -> 1.10.0
pattonwebz Mar 19, 2024
418bdc8
Add changelog for v 1.10.0
pattonwebz Mar 19, 2024
f1fe6b8
Bump stable tag in readme
pattonwebz Mar 19, 2024
d9f0c95
Move 1.8.x changelog entries from readme.txt to changelog.txt
pattonwebz Mar 19, 2024
52cf5be
Don't try to perform the initial frontend validate scan when post is …
pattonwebz Mar 20, 2024
6763364
Add a changelog message for the frontend validator change
pattonwebz Mar 20, 2024
cc13734
Update the method docblock to make it clearer how and what the functi…
pattonwebz Mar 20, 2024
77e9c24
More docblock edits for correctness
pattonwebz Mar 20, 2024
a5d9eef
Merge pull request #540 from equalizedigital/william/539/auto-draft-c…
pattonwebz Mar 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
npm run lint
npm run lint-staged-precommit
8 changes: 2 additions & 6 deletions accessibility-checker.php
100644 → 100755
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.9.3
* Version: 1.10.0
* Author: Equalize Digital
* Author URI: https://equalizedigital.com
* License: GPL-2.0+
Expand Down Expand Up @@ -41,7 +41,7 @@

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

// Current database version.
Expand Down Expand Up @@ -126,9 +126,6 @@
require_once plugin_dir_path( __FILE__ ) . 'includes/meta-boxes.php';
require_once plugin_dir_path( __FILE__ ) . 'includes/options-page.php';
require_once plugin_dir_path( __FILE__ ) . 'includes/validate.php';
require_once plugin_dir_path( __FILE__ ) . 'includes/insert.php';
require_once plugin_dir_path( __FILE__ ) . 'includes/purge.php';

/**
* Filters and Actions
*/
Expand All @@ -137,7 +134,6 @@
add_action( 'admin_init', 'edac_register_setting' );
add_action( 'admin_head', 'edac_post_on_load' );
add_filter( 'save_post', 'edac_save_post', 10, 3 );
add_action( 'wp_trash_post', 'edac_delete_post' );
add_action( 'pre_get_posts', 'edac_show_draft_posts' );
if ( is_plugin_active( 'oxygen/functions.php' ) ) {
add_action( 'added_post_meta', 'edac_oxygen_builder_save_post', 10, 4 );
Expand Down
6 changes: 4 additions & 2 deletions admin/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace EDAC\Admin;

use EDAC\Admin\SiteHealth\Information;
use EDAC\Admin\Purge_Post_Data;

/**
* Admin handling class.
Expand All @@ -29,8 +30,9 @@ public function init() {

$update_database = new Update_Database();
$update_database->init_hooks();

add_action( 'admin_enqueue_scripts', array( 'EDAC\Admin\Enqueue_Admin', 'enqueue' ) );
add_action( 'wp_trash_post', array( Purge_Post_Data::class, 'delete_post' ) );

$admin_notices = new Admin_Notices();
$admin_notices->init_hooks();
Expand All @@ -40,7 +42,7 @@ public function init() {

$site_health_info = new Information();
$site_health_info->init_hooks();

$this->init_ajax();
}

Expand Down
142 changes: 142 additions & 0 deletions admin/class-insert-rule-data.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<?php
/**
* Inserts rule data about a post to the database
*
* @since 1.10.0
*
* @package Accessibility_Checker
*/

namespace EDAC\Admin;

/**
* Class for inserting rule data into the database
*
* @since 1.10.0
*/
class Insert_Rule_Data {

/**
* Insert rule data into database
*
* @since 1.10.0
*
* @param object $post The post object. Must have a valid ID.
* @param string $rule The rule.
* @param string $ruletype The rule type.
* @param string $rule_obj The object.
*
* @return void|int|\WP_Error The ID of the inserted record, void if no
* record was inserted or a WP_Error if the insert failed.
*/
public function insert( object $post, string $rule, string $ruletype, string $rule_obj ) {

if ( ! isset( $post->ID, $post->post_type )
|| empty( $rule )
|| empty( $ruletype )
|| empty( $rule_obj )
) {
return;
}

global $wpdb;
$table_name = $wpdb->prefix . 'accessibility_checker';

// set up rule data array.
$rule_data = array(
'postid' => $post->ID,
'siteid' => get_current_blog_id(),
'type' => $post->post_type,
'rule' => $rule,
'ruletype' => $ruletype,
'object' => esc_attr( $rule_obj ),
'recordcheck' => 1,
'user' => get_current_user_id(),
'ignre' => 0,
'ignre_user' => null,
'ignre_date' => null,
'ignre_comment' => null,
'ignre_global' => 0,
);

// return if revision.
if ( 'revision' === $rule_data['type'] ) {
return;
}

// Check if exists.
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Using direct query for adding data to database, caching not required for one time operation.
$results = $wpdb->get_results(
$wpdb->prepare(
'SELECT postid, ignre FROM %i where type = %s and postid = %d and rule = %s and object = %s and siteid = %d',
$table_name,
$rule_data['type'],
$rule_data['postid'],
$rule_data['rule'],
$rule_data['object'],
$rule_data['siteid']
),
ARRAY_A
);

// Loop existing records.
if ( $results ) {
foreach ( $results as $row ) {

// if being ignored, don't overwrite value.
if ( true === (bool) $row['ignre'] ) {
$rule_data['ignre'] = 1;
}

// update existing record.
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Using direct query for adding data to database, caching not required for one time operation.
$wpdb->query(
$wpdb->prepare(
'UPDATE %i SET recordcheck = %d, ignre = %d WHERE siteid = %d and postid = %d and rule = %s and object = %s and type = %s',
$table_name,
1,
$rule_data['ignre'],
$rule_data['siteid'],
$rule_data['postid'],
$rule_data['rule'],
$rule_data['object'],
$rule_data['type']
)
);

}
}

// Insert new records.
if ( ! $results ) {

// filter post types.
$rule_data = apply_filters( 'edac_filter_insert_rule_data', $rule_data );

// Sanitize rule data since it is filtered, and we can't be sure
// the data is still as valid as it was when it was first set.
// Sanitize the filtered data.
$rule_data_sanitized = array(
'postid' => absint( $rule_data['postid'] ),
'siteid' => absint( $rule_data['siteid'] ),
'type' => sanitize_text_field( $rule_data['type'] ),
'rule' => sanitize_text_field( $rule_data['rule'] ),
'ruletype' => sanitize_text_field( $rule_data['ruletype'] ),
'object' => esc_attr( $rule_data['object'] ),
'recordcheck' => absint( $rule_data['recordcheck'] ),
'user' => absint( $rule_data['user'] ),
'ignre' => absint( $rule_data['ignre'] ),
'ignre_user' => isset( $rule_data['ignre_user'] ) ? absint( $rule_data['ignre_user'] ) : null,
'ignre_date' => isset( $rule_data['ignre_date'] ) ? sanitize_text_field( $rule_data['ignre_date'] ) : null,
'ignre_comment' => isset( $rule_data['ignre_comment'] ) ? sanitize_text_field( $rule_data['ignre_comment'] ) : null,
'ignre_global' => absint( $rule_data['ignre_global'] ),
);

// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Using direct query for adding data to database.
$wpdb->insert( $table_name, $rule_data_sanitized );

// Return insert id or error.
return $wpdb->insert_id;
}
}
}
96 changes: 96 additions & 0 deletions admin/class-purge-post-data.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?php
/**
* Purge Post Data stored in the database that holds scan data about the posts.
*
* @package Accessibility_Checker
*/

namespace EDAC\Admin;

/**
* Uses sql queries to get and purge post data from the database for given post
* ids or for custom posts by post_type string.
*
* @since 1.10.0
*/
class Purge_Post_Data {

/**
* Purge deleted posts
*
* @since 1.10.0
*
* @param int $post_id ID of the post.
*
* @return void
*/
public static function delete_post( int $post_id ) {
global $wpdb;

// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Safe variable used for table name, caching not required for one time operation.
$wpdb->query(
$wpdb->prepare(
'DELETE FROM %i WHERE postid = %d and siteid = %d',
edac_get_valid_table_name( $wpdb->prefix . 'accessibility_checker' ),
$post_id,
get_current_blog_id()
)
);

self::delete_post_meta( $post_id );
}

/**
* Delete post meta
*
* @since 1.10.0
*
* @param int $post_id ID of the post.
*
* @return void
*/
public static function delete_post_meta( int $post_id ) {

if ( ! $post_id ) {
return;
}

$post_meta = get_post_meta( $post_id );
if ( $post_meta ) {
foreach ( $post_meta as $key => $value ) {
if ( substr( $key, 0, 5 ) === '_edac' || substr( $key, 0, 6 ) === '_edacp' ) {
delete_post_meta( $post_id, $key );
}
}
}
}

/**
* Purge issues by post type
*
* @since 1.10.0
*
* @param string $post_type Post Type.
*
* @return bool|int|\mysqli_result|void
*/
public static function delete_cpt_posts( string $post_type ) {

if ( ! $post_type || ! post_type_exists( $post_type ) ) {
return;
}

global $wpdb;

// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Safe variable used for table name, caching not required for one time operation.
return $wpdb->query(
$wpdb->prepare(
"DELETE T1,T2 from $wpdb->postmeta as T1 JOIN %i as T2 ON T1.post_id = T2.postid WHERE T1.meta_key like %s and T2.siteid=%d and T2.type=%s",
edac_get_valid_table_name( $wpdb->prefix . 'accessibility_checker' ),
'_edac%',
get_current_blog_id(),
$post_type
)
);
}
}
53 changes: 52 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,56 @@
Newer versions can be found in readme.txt.

= 1.8.1 =
* Fixed: false positives on the incorrect heading order rule
* Added: fallback to determine ordinal when php intl extension is not installed

= 1.8.0 =
* Updated: heading order on welcome screen
* Updated: missing_title summary
* Updated: SQL prepare queries to use %i placeholder
* Updated: incorrect textdomains and made strings translatible
* Removed: single-use variables where possible
* Added: PHPUnit framework and workflow
* Added: unit test for the `edac_compare_strings` function
* Added: unit test for the `edac_parse_css` function
* Updated: the `edac_compare_strings` function to be more efficient, return the correct type, and fix the failing tests
* Updated: `readme.txt` to only have the latest major and minor changelog
* Added: `changelog.txt` file.
* Added: `includes/rules.php` file that contains all rules and returns them as an array
* Added a static var in the `edac_register_rules` function to avoid re-reading the `includes/rules.php` file every time the method is called
* Removed: `has_filter` check before calling `apply_filters`
* Added: `edac_register_rules` unit test
* Added: `edac_check_plugin_active` deprecated function
* Updated: `edac_check_plugin_active` calls with `is_plugin_active`
* Removed: calls to `add_option` and replaced with `update_option`
* Updated: Use of `else` statement and bailed early when needed
* Removed: `has_filter()` before applying apply_filters
* Removed: hooks from `EDAC\Admin_Notices` constructor and call them from the `init_hooks` method
* Added: `EDAC\Admin_Notices` unit tests
* Added: `EDAC\Ajax` class and moved AJAX functions into this class
* Removed: unnecessary `wp_ajax_nopriv_` hooks
* Added: namespace to `Frontend_Highlight` class and only instantiated on `DOING_AJAX`
* Removed: `EDAC_SVG_IGNORE_ICON` string and pulled it from the file
* Removed: `$plugin_check` global variable
* Removed: `$rules` global variable
* Updated: `edac_ordinal` function to support all locales, safeguards against improper inputs, number format
* Updated: JavaScript coding standards
* Added: `includes/classes` directory to autoloader
* Added: new directory admin to autoloader
* Removed: `require_once` class calls
* Created: `class-plugin.php` to load frontend classes
* Created: `class-admin.php` to load admin classes
* Updated: classes to follow new `EDAC\Admin` and `EDAC\Inc` namespaces
* Updated: accessibility statement functions to a class
* Updated: simplified summary functions to a class
* Updated: lazyload Filter function into a class
* Removed: removes calls to `add_post_meta` and uses `update_post_meta` where appropriate
* Added: `EDAC\Inc\Accessibility_Statement` unit test
* Added: `EDAC\Inc\Simplified_Summary` unit test
* Added: local PHPUnit to run on wp-env test
* Updated: enqueue scripts and styles setup to only load assets in the proper environments
* Updated: email signup form

= 1.7.1 =
* Fixed: classic editor save conflict
* Fixed: password protection message displaying repeatedly
Expand Down Expand Up @@ -273,7 +324,7 @@ Fixed: marketing notice logic
* Freemius Update

= 1.2.7 =
* Add accessibility statement page template
* Add accessibility statement page template

= 1.2.6 =
* Minor accessibility updates
Expand Down
6 changes: 3 additions & 3 deletions includes/classes/class-edac-dom.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ public function find_linked_media( $include_audio = true ) {
$elements = array_filter(
$elements_with_href,
function ( $element ) use ( $extensions ) {
$count = 0;
str_ireplace( $extensions, '', $element->getAttribute( 'href' ), $count );
return $count > 0;
$href = $element->getAttribute( 'href' );
$extension = pathinfo( $href, PATHINFO_EXTENSION );
return in_array( '.' . $extension, $extensions, true );
}
);
}
Expand Down
Loading
Loading