Skip to content

Commit

Permalink
Merge pull request #421 from aristath/fix/global-var/rules
Browse files Browse the repository at this point in the history
Avoid setting a `$rules` global variable
  • Loading branch information
SteveJonesDev authored Dec 13, 2023
2 parents 7a570d9 + f00b4e2 commit 72f55f4
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions accessibility-checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,18 +239,22 @@ function edac_register_rules() {
/**
* Include Rules
*
* @var object $rules
* @return void
*/
$rules = edac_register_rules();
if ( $rules ) {
function edac_include_rules_files() {
$rules = edac_register_rules();
if ( ! $rules ) {
return;
}
foreach ( $rules as $rule ) {
if ( ( array_key_exists( 'ruleset', $rule ) && 'php' === $rule['ruleset'] ) ||
( ! array_key_exists( 'ruleset', $rule ) && $rule['slug'] ) ) {
if ( ( array_key_exists( 'ruleset', $rule ) && 'php' === $rule['ruleset'] )
|| ( ! array_key_exists( 'ruleset', $rule ) && $rule['slug'] )
) {
require_once plugin_dir_path( __FILE__ ) . 'includes/rules/' . $rule['slug'] . '.php';
}
}
}

edac_include_rules_files();

/**
* Code that needs to run before the page is rendered
Expand Down

0 comments on commit 72f55f4

Please sign in to comment.