Skip to content

Commit

Permalink
Merge pull request #677 from equalizedigital/william/no-issue/handle-…
Browse files Browse the repository at this point in the history
…namespace-changes-in-pro

Add some checks for namespace updates
  • Loading branch information
pattonwebz committed Jun 24, 2024
2 parents 230eb68 + a15bfb7 commit c593aa4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
22 changes: 19 additions & 3 deletions admin/class-scans-stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace EDAC\Admin;

use EqualizeDigital\AccessibilityCheckerPro\Admin\Scans;

/**
* Class that handles calculating scans stats
*/
Expand Down Expand Up @@ -176,7 +178,7 @@ function ( $item ) {

if ( $rule_query->count() ) {
++$data['rules_failed'];
}
}
}
$data['rules_passed'] = $this->rule_count - $data['rules_failed'];

Expand Down Expand Up @@ -231,7 +233,7 @@ function ( $item ) {
$data['posts_without_issues'] = 0;
$data['avg_issues_per_post'] = 0;

if ( $data['posts_scanned'] > 0
if ( $data['posts_scanned'] > 0
&& ! empty( Settings::get_scannable_post_types() )
&& ! empty( Settings::get_scannable_post_statuses() )
) {
Expand Down Expand Up @@ -270,7 +272,20 @@ function ( $item ) {
$data['fullscan_state'] = '';
$data['fullscan_completed_at'] = 0;

if ( class_exists( '\EDACP\Scans' ) ) {
// For back compat reasons the old class_exists is kept and moved to an else block.
// After a few releases the else should be removed.
if ( class_exists( '\EqualizeDigital\AccessibilityCheckerPro\Admin\Scans' ) ) {
$scans = new Scans();
$scan_state = $scans->scan_state();

$data['fullscan_state'] = $scan_state;
if ( Scans::SCAN_STATE_PHP_SCAN_RUNNING === $scan_state
|| Scans::SCAN_STATE_JS_SCAN_RUNNING === $scan_state
) {
$data['fullscan_running'] = true;
}
$data['fullscan_completed_at'] = $scans->scan_date( 'php' );
} elseif ( class_exists( '\EDACP\Scans' ) ) {
$scans = new \EDACP\Scans();
$scan_state = $scans->scan_state();

Expand All @@ -281,6 +296,7 @@ function ( $item ) {
$data['fullscan_running'] = true;
}
$data['fullscan_completed_at'] = $scans->scan_date( 'php' );

}

$data['cache_id'] = $transient_name;
Expand Down
9 changes: 7 additions & 2 deletions admin/class-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ public static function get_scannable_post_statuses() {
*/
public static function get_scannable_post_types() {

if ( ! class_exists( '\EDACP\Settings' ) ) {
// Check if the new settings class exists. This is added to allow for backwards compatibility
// with the old settings class. The old settings class check should be removed after a few releases.
$new_settings_class_exists = class_exists( 'EqualizeDigital\AccessibilityCheckerPro\Admin\Settings' );
if ( ! class_exists( '\EDACP\Settings' ) || ! $new_settings_class_exists ) {

$post_types = Helpers::get_option_as_array( 'edac_post_types' );

Expand All @@ -53,7 +56,9 @@ public static function get_scannable_post_types() {
return $post_types;
}

return \EDACP\Settings::get_scannable_post_types();
return $new_settings_class_exists
? \EqualizeDigital\AccessibilityCheckerPro\Admin\Settings::get_scannable_post_types()
: \EDACP\Settings::get_scannable_post_types();
}


Expand Down
3 changes: 2 additions & 1 deletion includes/options-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,8 @@ function edac_sanitize_post_types( $selected_post_types ) {
$scan_stats = new \EDAC\Admin\Scans_Stats();
$scan_stats->clear_cache();

if ( class_exists( '\EDACP\Scans' ) ) {
// EDACP\Scans is the old namespace, kept for back compat but should be removed after a few releases.
if ( class_exists( '\EDACP\Scans' ) || class_exists( '\EqualizeDigital\AccessibilityCheckerPro\Admin\Scans' ) ) {
delete_option( 'edacp_fullscan_completed_at' );
}
}
Expand Down

0 comments on commit c593aa4

Please sign in to comment.