mirror of
https://gh.wpcy.net/https://github.com/elementor/one-click-accessibility.git
synced 2026-04-21 02:26:10 +08:00
* [APP-1747] add parent selector * [APP-1747] add parent selector * [APP-1747] add parent selector * [APP-1747] add parent selector * [APP-1747] add parent selector * [APP-1747] add parent selector * [APP-1747] add parent selector * [APP-1747] add parent selector * [APP-1747] add parent selector * [APP-1747] add parent selector * [APP-1747] add parent selector * [APP-1747] add parent selector * [APP-1747] add parent selector * Add mixpanel events * Add mixpanel events * Add mixpanel events * Exclude adminbar from css rule * Exclude adminbar from css rule * Exclude adminbar from css rule * Exclude adminbar from css rule * Exclude adminbar from css rule * Exclude adminbar from css rule * Update modules/remediation/assets/js/actions/styles.js Co-authored-by: gitstream-cm[bot] <111687743+gitstream-cm[bot]@users.noreply.github.com> * Exclude adminbar from css rule * Exclude adminbar from css rule * Update modules/scanner/assets/js/hooks/use-color-contrast-form.js Co-authored-by: gitstream-cm[bot] <111687743+gitstream-cm[bot]@users.noreply.github.com> * Exclude adminbar from css rule * Exclude adminbar from css rule * fix quota * fix quota * fix quota * fix quota * fix quota * fix quota * fix quota * fix linter * [APP-1825] Add remove/disable category * [APP-1825] Add remove/disable category --------- Co-authored-by: gitstream-cm[bot] <111687743+gitstream-cm[bot]@users.noreply.github.com>
123 lines
2.4 KiB
PHP
123 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace EA11y\Modules\Scanner\Database;
|
|
|
|
use EA11y\Classes\Database\Entry;
|
|
use EA11y\Modules\Remediation\Exceptions\Missing_URL;
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit; // Exit if accessed directly
|
|
}
|
|
|
|
/**
|
|
* Class Scan_Entry
|
|
*/
|
|
class Scan_Entry extends Entry {
|
|
|
|
public static function get_helper_class(): string {
|
|
return Scans_Table::get_class_name();
|
|
}
|
|
|
|
/**
|
|
* get_scan_result
|
|
* @param string $url
|
|
* @param bool $latest
|
|
*
|
|
* @return array
|
|
*/
|
|
public static function get_scan_result( string $url, bool $latest = false ) : array {
|
|
$where = [
|
|
[
|
|
'column' => Scans_Table::URL,
|
|
'value' => $url,
|
|
'operator' => '=',
|
|
],
|
|
];
|
|
$order_by = [ 'id' => $latest ? 'desc' : 'asc' ];
|
|
$entries = Scans_Table::select( 'summary', $where, 1, null, '', $order_by );
|
|
return isset( $entries[0] ) ? json_decode( $entries[0]->summary, true ) : [];
|
|
}
|
|
|
|
/**
|
|
* get_scans
|
|
* @param string $url
|
|
* @param bool $latest
|
|
*
|
|
* @return array
|
|
*/
|
|
public static function get_scans( string $url, int $limit = 10 ) : array {
|
|
$where = [
|
|
[
|
|
'column' => Scans_Table::URL,
|
|
'value' => $url,
|
|
'operator' => '=',
|
|
],
|
|
];
|
|
|
|
$entries = Scans_Table::select( '*', $where, $limit, null, '', [ 'created_at' => 'desc' ] );
|
|
|
|
return array_map( function ( $entry ) {
|
|
$entry->summary = json_decode( $entry->summary, true );
|
|
|
|
return $entry;
|
|
}, $entries);
|
|
}
|
|
|
|
public static function get_by_id( int $id ) {
|
|
$where = [
|
|
[
|
|
'column' => Scans_Table::ID,
|
|
'value' => $id,
|
|
'operator' => '=',
|
|
],
|
|
];
|
|
|
|
$entries = Scans_Table::select( '*', $where, 1 );
|
|
|
|
if ( isset( $entries[0] ) ) {
|
|
$entries[0]->summary = json_decode( $entries[0]->summary, true );
|
|
|
|
return $entries[0];
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* @param string $by
|
|
* @param string $by_value
|
|
* @param string $content
|
|
*
|
|
* @return void
|
|
*/
|
|
public static function update_scan_summary( string $by, string $by_value, string $content ): void {
|
|
$where = [
|
|
$by => $by_value,
|
|
];
|
|
|
|
$data = [
|
|
Scans_Table::SUMMARY => $content,
|
|
];
|
|
|
|
Scans_Table::update( $data, $where );
|
|
}
|
|
|
|
/**
|
|
* Create
|
|
* used to ensure:
|
|
* the remediation is an array
|
|
* the hash is set
|
|
* URL is set
|
|
*
|
|
* @param string $id
|
|
*
|
|
* @throws Missing_URL
|
|
*/
|
|
public function create( string $id = 'id' ) {
|
|
if ( empty( $this->entry_data[ Scans_Table::URL ] ) ) {
|
|
throw new Missing_URL();
|
|
}
|
|
|
|
parent::create( $id );
|
|
}
|
|
}
|