mirror of
https://gh.wpcy.net/https://github.com/elementor/one-click-accessibility.git
synced 2026-04-23 08:02:29 +08:00
* Fix: Update stats calculation logic [APP-1607] * Fix: Set fixed width for the results table [APP-1650] * Fix: Update filter rules [APP-1634] * New: Add the no search results state [APP-1651] * Fix: Convert indents [n/a]
67 lines
1.7 KiB
PHP
67 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace EA11y\Modules\Scanner\Rest;
|
|
|
|
use EA11y\Modules\Scanner\Classes\Route_Base;
|
|
use EA11y\Modules\Scanner\Database\Scan_Entry;
|
|
use EA11y\Modules\Scanner\Database\Scans_Table;
|
|
use Throwable;
|
|
use WP_Error;
|
|
use WP_REST_Response;
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit; // Exit if accessed directly
|
|
}
|
|
|
|
class Resolve_Issue extends Route_Base {
|
|
public string $path = 'resolve-issue';
|
|
|
|
public function get_methods(): array {
|
|
return [ 'POST' ];
|
|
}
|
|
|
|
public function get_name(): string {
|
|
return 'resolve-issue';
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @return WP_Error|WP_REST_Response
|
|
*
|
|
*/
|
|
public function POST( $request ) {
|
|
try {
|
|
$error = $this->verify_capability();
|
|
|
|
if ( $error ) {
|
|
return $error;
|
|
}
|
|
|
|
$scan_id = $request->get_param( 'scanId' );
|
|
$scan = Scan_Entry::get_by_id( $scan_id );
|
|
|
|
if ( empty( $scan ) ) {
|
|
return $this->respond_error_json( [
|
|
'message' => 'Scan not found',
|
|
'code' => 'not_found',
|
|
] );
|
|
}
|
|
|
|
$summary = $scan->summary;
|
|
|
|
if ($summary['counts']['issuesResolved'] + 1 <= $summary['counts']['violation']) {
|
|
$summary['counts']['issuesResolved']++;
|
|
Scan_Entry::update_scan_summary( Scans_Table::ID, $scan_id, json_encode( $summary ) );
|
|
}
|
|
|
|
return $this->respond_success_json( [
|
|
'message' => 'Resolved',
|
|
] );
|
|
} catch ( Throwable $t ) {
|
|
return $this->respond_error_json( [
|
|
'message' => $t->getMessage(),
|
|
'code' => 'internal_server_error',
|
|
] );
|
|
}
|
|
}
|
|
}
|