This commit is contained in:
Javier Casares 2026-06-03 06:28:34 +00:00
commit 83d629568a
20 changed files with 1321 additions and 15 deletions

View file

@ -7,6 +7,7 @@
namespace MediaRightsAudit\Admin;
use MediaRightsAudit\Admin\AttachmentDetailPage;
use MediaRightsAudit\External\ExternalScanner;
use MediaRightsAudit\External\ResultsConsolidator;
use MediaRightsAudit\Internal\AttachmentIndexer;
@ -269,7 +270,7 @@ class AuditPage {
// phpcs:ignore WordPress.DB.DirectDatabaseQuery,WordPress.DB.PreparedSQL.InterpolatedNotPrepared
$rows = $wpdb->get_results(
$wpdb->prepare(
"SELECT provider, match_count, top_domains, created_at
"SELECT provider, match_count, top_domains, raw_response, created_at
FROM {$wpdb->prefix}mra_external_results
WHERE attachment_id = %d
ORDER BY provider ASC",
@ -285,6 +286,7 @@ class AuditPage {
$provider_names = array(
'google_vision' => 'Google Cloud Vision',
'tineye' => 'TinEye',
'picdefense' => 'PicDefense',
);
$html = '<h4 class="mra-section-heading">' . esc_html__( 'External Scan Results', 'robotstxt-mediaaudit' ) . '</h4>';
@ -303,6 +305,12 @@ class AuditPage {
$td_val = $row['top_domains'] ?? null;
$td_raw = is_string( $td_val ) ? json_decode( $td_val, true ) : null;
$domains = is_array( $td_raw ) ? $td_raw : array();
$rr_val = $row['raw_response'] ?? null;
$raw = null;
if ( is_string( $rr_val ) && '' !== $rr_val ) {
$rr_decoded = json_decode( $rr_val, true );
$raw = is_array( $rr_decoded ) ? $rr_decoded : null;
}
$html .= '<div class="mra-provider-result">';
$html .= '<strong>' . esc_html( $name ) . '</strong> — ';
@ -319,6 +327,19 @@ class AuditPage {
$html .= esc_html__( 'No matches', 'robotstxt-mediaaudit' );
}
if ( 'picdefense' === $slug && null !== $raw ) {
$pd_data_raw = $raw['data'] ?? null;
$pd_arr = is_array( $pd_data_raw ) ? $pd_data_raw : array();
$pd_data = isset( $pd_arr[0] ) && is_array( $pd_arr[0] ) ? $pd_arr[0] : null;
if ( is_array( $pd_data ) ) {
$pr_val = $pd_data['picrisk'] ?? null;
$picrisk = is_string( $pr_val ) ? strtolower( $pr_val ) : '';
if ( '' !== $picrisk ) {
$html .= ' <span class="mra-badge mra-picrisk-' . esc_attr( $picrisk ) . '">' . esc_html( ucfirst( $picrisk ) ) . '</span>';
}
}
}
if ( '' !== $scanned_at ) {
$html .= ' <small>' . esc_html( $scanned_at ) . '</small>';
}
@ -364,6 +385,10 @@ class AuditPage {
}
}
$html .= '<p class="mra-detail-link"><a href="' . esc_url( AttachmentDetailPage::url( $attachment_id ) ) . '">'
. esc_html__( 'View full report →', 'robotstxt-mediaaudit' )
. '</a></p>';
return $html;
}