This commit is contained in:
Javier Casares 2026-06-03 06:31:47 +00:00
commit 7b7fff5246
36 changed files with 610 additions and 31 deletions

View file

@ -153,7 +153,7 @@
var targetId = $( this ).data( 'target' ); var targetId = $( this ).data( 'target' );
var $row = $( '#' + targetId ); var $row = $( '#' + targetId );
$row.prop( 'hidden', function ( i, v ) { return !v; } ); $row.prop( 'hidden', function ( i, v ) { return !v; } );
$( this ).text( $row.prop( 'hidden' ) ? 'Dismiss' : 'Cancel' ); $( this ).text( $row.prop( 'hidden' ) ? mraAlerts.i18n.dismiss : mraAlerts.i18n.cancel );
} ); } );
// Cancel button inside dismiss form row. // Cancel button inside dismiss form row.
@ -161,7 +161,7 @@
var $row = $( this ).closest( 'tr.mra-dismiss-row' ); var $row = $( this ).closest( 'tr.mra-dismiss-row' );
var rowId = $row.attr( 'id' ); var rowId = $row.attr( 'id' );
$row.prop( 'hidden', true ); $row.prop( 'hidden', true );
$( '[data-target="' + rowId + '"]' ).text( 'Dismiss' ); $( '[data-target="' + rowId + '"]' ).text( mraAlerts.i18n.dismiss );
} ); } );
} ); } );
} ( jQuery ) ); } ( jQuery ) );

View file

@ -1,5 +1,17 @@
== Changelog == == Changelog ==
= 1.7.1 =
_Release date: 2026-06-02_
**Fixed**
* Dismissal timestamps are now stored in UTC, consistent with all other plugin timestamps (`dismissed_at`).
* Settings option (`robotstxt_mediaaudit_settings`) no longer autoloads on every page request, reducing the autoloaded options payload.
* Alert count on the Media Audit dashboard is now cached with a transient (1 hour TTL) and invalidated automatically on dismiss, reactivate, scan, purge, and full reset operations.
* "Dismiss" and "Cancel" button labels on the Alerts page are now translatable via `wp_localize_script`.
* Added direct file access guard (`if ( ! defined( 'ABSPATH' ) ) { exit; }`) to all PHP class files in `includes/`.
= 1.7.0 = = 1.7.0 =
_Release date: 2026-05-11_ _Release date: 2026-05-11_

View file

@ -130,11 +130,12 @@ class AlertsPage {
notes = VALUES(notes)", notes = VALUES(notes)",
$attachment_id, $attachment_id,
$user_id, $user_id,
current_time( 'mysql' ), current_time( 'mysql', true ),
$notes $notes
) )
); );
delete_transient( 'mra_alert_count' );
self::invalidate_cache(); self::invalidate_cache();
} }
@ -155,6 +156,7 @@ class AlertsPage {
array( '%d' ) array( '%d' )
); );
delete_transient( 'mra_alert_count' );
self::invalidate_cache(); self::invalidate_cache();
} }
@ -192,6 +194,17 @@ class AlertsPage {
wp_enqueue_style( 'mra-admin', $base . 'css/media-audit-admin.css', array(), $ver ); wp_enqueue_style( 'mra-admin', $base . 'css/media-audit-admin.css', array(), $ver );
wp_enqueue_script( 'mra-admin', $base . 'js/media-audit-admin.js', array( 'jquery' ), $ver, true ); wp_enqueue_script( 'mra-admin', $base . 'js/media-audit-admin.js', array( 'jquery' ), $ver, true );
wp_localize_script(
'mra-admin',
'mraAlerts',
array(
'i18n' => array(
'dismiss' => __( 'Dismiss', 'robotstxt-mediaaudit' ),
'cancel' => __( 'Cancel', 'robotstxt-mediaaudit' ),
),
)
);
} }
/** /**

View file

@ -7,6 +7,10 @@
namespace MediaRightsAudit\Admin; namespace MediaRightsAudit\Admin;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use MediaRightsAudit\External\HostnameFilter; use MediaRightsAudit\External\HostnameFilter;
/** /**

View file

@ -7,6 +7,10 @@
namespace MediaRightsAudit\Admin; namespace MediaRightsAudit\Admin;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use MediaRightsAudit\Admin\AlertsPage; use MediaRightsAudit\Admin\AlertsPage;
use MediaRightsAudit\Admin\AttachmentDetailPage; use MediaRightsAudit\Admin\AttachmentDetailPage;
use MediaRightsAudit\External\ExternalScanner; use MediaRightsAudit\External\ExternalScanner;
@ -928,6 +932,11 @@ class AuditPage {
* @return int * @return int
*/ */
private static function get_alert_attachment_count(): int { private static function get_alert_attachment_count(): int {
$cached = get_transient( 'mra_alert_count' );
if ( is_int( $cached ) ) {
return $cached;
}
global $wpdb; global $wpdb;
// phpcs:ignore WordPress.DB.DirectDatabaseQuery // phpcs:ignore WordPress.DB.DirectDatabaseQuery
@ -937,6 +946,7 @@ class AuditPage {
); );
if ( ! is_array( $rows ) ) { if ( ! is_array( $rows ) ) {
set_transient( 'mra_alert_count', 0, HOUR_IN_SECONDS );
return 0; return 0;
} }
@ -983,6 +993,7 @@ class AuditPage {
} }
} }
set_transient( 'mra_alert_count', $alert_count, HOUR_IN_SECONDS );
return $alert_count; return $alert_count;
} }
} }

View file

@ -7,6 +7,10 @@
namespace MediaRightsAudit\Admin; namespace MediaRightsAudit\Admin;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use MediaRightsAudit\Admin\AlertsPage; use MediaRightsAudit\Admin\AlertsPage;
use MediaRightsAudit\Admin\AttachmentDetailPage; use MediaRightsAudit\Admin\AttachmentDetailPage;
use MediaRightsAudit\External\HostnameFilter; use MediaRightsAudit\External\HostnameFilter;

View file

@ -7,6 +7,10 @@
namespace MediaRightsAudit\Admin; namespace MediaRightsAudit\Admin;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/** /**
* Registers and renders the plugin Settings page with tab navigation. * Registers and renders the plugin Settings page with tab navigation.
* *
@ -233,6 +237,7 @@ class Settings {
'type' => 'array', 'type' => 'array',
'sanitize_callback' => array( $this, 'sanitize' ), 'sanitize_callback' => array( $this, 'sanitize' ),
'default' => array(), 'default' => array(),
'autoload' => false,
) )
); );

View file

@ -7,6 +7,10 @@
namespace MediaRightsAudit\Admin; namespace MediaRightsAudit\Admin;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use MediaRightsAudit\Core\Database; use MediaRightsAudit\Core\Database;
use MediaRightsAudit\Core\Queue\Scheduler; use MediaRightsAudit\Core\Queue\Scheduler;
use MediaRightsAudit\External\ExternalScanner; use MediaRightsAudit\External\ExternalScanner;

View file

@ -7,6 +7,10 @@
namespace MediaRightsAudit\CLI; namespace MediaRightsAudit\CLI;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use MediaRightsAudit\Core\Database; use MediaRightsAudit\Core\Database;
use MediaRightsAudit\External\ExternalScanner; use MediaRightsAudit\External\ExternalScanner;
use MediaRightsAudit\Internal\AttachmentIndexer; use MediaRightsAudit\Internal\AttachmentIndexer;

View file

@ -7,6 +7,10 @@
namespace MediaRightsAudit\Core; namespace MediaRightsAudit\Core;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use MediaRightsAudit\Admin\Settings; use MediaRightsAudit\Admin\Settings;
/** /**

View file

@ -7,6 +7,10 @@
namespace MediaRightsAudit\Core; namespace MediaRightsAudit\Core;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/** /**
* Manages all custom table creation and schema migrations. * Manages all custom table creation and schema migrations.
* *
@ -86,6 +90,8 @@ class Database {
$wpdb->query( "TRUNCATE TABLE `{$wpdb->prefix}mra_media_usage`" ); $wpdb->query( "TRUNCATE TABLE `{$wpdb->prefix}mra_media_usage`" );
$wpdb->query( "TRUNCATE TABLE `{$wpdb->prefix}mra_media_index`" ); $wpdb->query( "TRUNCATE TABLE `{$wpdb->prefix}mra_media_index`" );
// phpcs:enable WordPress.DB.DirectDatabaseQuery // phpcs:enable WordPress.DB.DirectDatabaseQuery
delete_transient( 'mra_alert_count' );
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------

View file

@ -7,6 +7,10 @@
namespace MediaRightsAudit\Core; namespace MediaRightsAudit\Core;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use MediaRightsAudit\Core\Queue\Scheduler; use MediaRightsAudit\Core\Queue\Scheduler;
/** /**

View file

@ -7,6 +7,10 @@
namespace MediaRightsAudit\Core; namespace MediaRightsAudit\Core;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use MediaRightsAudit\Admin\AlertsPage; use MediaRightsAudit\Admin\AlertsPage;
use MediaRightsAudit\Admin\AttachmentDetailPage; use MediaRightsAudit\Admin\AttachmentDetailPage;
use MediaRightsAudit\Admin\AuditPage; use MediaRightsAudit\Admin\AuditPage;

View file

@ -7,6 +7,10 @@
namespace MediaRightsAudit\Core\Queue; namespace MediaRightsAudit\Core\Queue;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/** /**
* Thin wrapper around Action Scheduler that namespaces all jobs under a single group. * Thin wrapper around Action Scheduler that namespaces all jobs under a single group.
* *

View file

@ -7,6 +7,10 @@
namespace MediaRightsAudit\External; namespace MediaRightsAudit\External;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/** /**
* Provides rate-limited scanning via a transient-based per-minute counter. * Provides rate-limited scanning via a transient-based per-minute counter.
* *

View file

@ -7,6 +7,10 @@
namespace MediaRightsAudit\External; namespace MediaRightsAudit\External;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use MediaRightsAudit\Core\Queue\Scheduler; use MediaRightsAudit\Core\Queue\Scheduler;
/** /**
@ -145,6 +149,8 @@ class ExternalScanner {
self::scan_batch( $batch_size ); self::scan_batch( $batch_size );
delete_transient( 'mra_alert_count' );
if ( self::get_pending_count() > 0 ) { if ( self::get_pending_count() > 0 ) {
Scheduler::schedule_single( self::AS_HOOK ); Scheduler::schedule_single( self::AS_HOOK );
} }
@ -361,6 +367,8 @@ class ExternalScanner {
) )
); );
// phpcs:enable WordPress.DB.DirectDatabaseQuery,WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare // phpcs:enable WordPress.DB.DirectDatabaseQuery,WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
delete_transient( 'mra_alert_count' );
} }
/** /**
@ -381,6 +389,8 @@ class ExternalScanner {
); );
// phpcs:enable WordPress.DB.DirectDatabaseQuery // phpcs:enable WordPress.DB.DirectDatabaseQuery
delete_transient( 'mra_alert_count' );
return $count; return $count;
} }

View file

@ -7,6 +7,10 @@
namespace MediaRightsAudit\External; namespace MediaRightsAudit\External;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use MediaRightsAudit\Admin\Settings; use MediaRightsAudit\Admin\Settings;
/** /**

View file

@ -7,6 +7,10 @@
namespace MediaRightsAudit\External; namespace MediaRightsAudit\External;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/** /**
* Classifies hostnames against the site's configured alert (include) and * Classifies hostnames against the site's configured alert (include) and
* ignored (exclude) lists stored in the robotstxt_mediaaudit_settings option. * ignored (exclude) lists stored in the robotstxt_mediaaudit_settings option.

View file

@ -7,6 +7,10 @@
namespace MediaRightsAudit\External; namespace MediaRightsAudit\External;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use MediaRightsAudit\Admin\Settings; use MediaRightsAudit\Admin\Settings;
/** /**

View file

@ -7,6 +7,10 @@
namespace MediaRightsAudit\External; namespace MediaRightsAudit\External;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/** /**
* Aggregates external scan results across multiple providers to surface * Aggregates external scan results across multiple providers to surface
* domains that appear in more than one provider's findings (consensus signals). * domains that appear in more than one provider's findings (consensus signals).

Some files were not shown because too many files have changed in this diff Show more