v1.8.1
This commit is contained in:
parent
7b7fff5246
commit
b6a55a7f04
27 changed files with 2221 additions and 45 deletions
|
|
@ -137,6 +137,10 @@ class AlertsPage {
|
|||
|
||||
delete_transient( 'mra_alert_count' );
|
||||
self::invalidate_cache();
|
||||
|
||||
if ( is_multisite() && 'central' === get_site_option( 'robotstxt_mediaaudit_network_mode', 'per_site' ) ) {
|
||||
\MediaRightsAudit\Core\NetworkDatabase::update_dismissal_flag( get_current_blog_id(), $attachment_id, true );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -158,6 +162,10 @@ class AlertsPage {
|
|||
|
||||
delete_transient( 'mra_alert_count' );
|
||||
self::invalidate_cache();
|
||||
|
||||
if ( is_multisite() && 'central' === get_site_option( 'robotstxt_mediaaudit_network_mode', 'per_site' ) ) {
|
||||
\MediaRightsAudit\Core\NetworkDatabase::update_dismissal_flag( get_current_blog_id(), $attachment_id, false );
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -222,6 +222,40 @@ class Settings {
|
|||
return in_array( $raw, self::TAB_KEYS, true ) ? $raw : 'general';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the effective settings for the current context.
|
||||
*
|
||||
* In Multisite central mode, reads from the shared network site option so that
|
||||
* all providers and scanners pick up network-wide API credentials and filter
|
||||
* lists without changing per-site DB records.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function get_effective_settings(): array {
|
||||
if ( is_multisite() && 'central' === get_site_option( 'robotstxt_mediaaudit_network_mode', 'per_site' ) ) {
|
||||
$raw = get_site_option( 'robotstxt_mediaaudit_network_settings', array() );
|
||||
} else {
|
||||
$raw = get_option( self::OPTION_NAME, array() );
|
||||
}
|
||||
return is_array( $raw ) ? $raw : array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitizes a settings array for the network admin, merging against $current.
|
||||
*
|
||||
* Mirrors the tab-based logic of sanitize() but accepts the existing values
|
||||
* as a parameter rather than reading from get_option(), so it can be used
|
||||
* for both per-site and network site options.
|
||||
*
|
||||
* @param array<string, mixed> $input Raw POST input (must include '_tab').
|
||||
* @param array<string, mixed> $current Existing option values to merge against.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function sanitize_for_network( array $input, array $current ): array {
|
||||
return $this->sanitize_with_base( $input, $current );
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers all settings, sections, and fields via the WordPress Settings API.
|
||||
*
|
||||
|
|
@ -367,7 +401,19 @@ class Settings {
|
|||
public function sanitize( $input ): array {
|
||||
$raw = get_option( self::OPTION_NAME, array() );
|
||||
$current = is_array( $raw ) ? $raw : array();
|
||||
$output = $current;
|
||||
return $this->sanitize_with_base( $input, $current );
|
||||
}
|
||||
|
||||
/**
|
||||
* Core tab-based sanitization logic shared by sanitize() and sanitize_for_network().
|
||||
*
|
||||
* @param mixed $input Raw POST input.
|
||||
* @param array<string, mixed> $current Existing values to merge against.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function sanitize_with_base( $input, array $current ): array {
|
||||
$output = $current;
|
||||
|
||||
if ( ! is_array( $input ) ) {
|
||||
return $output;
|
||||
|
|
@ -430,11 +476,18 @@ class Settings {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sanitises a newline-separated list of hostnames into a deduplicated array.
|
||||
* Public proxy for sanitize_hostname_list(), used by Network\Settings.
|
||||
*
|
||||
* Accepts plain hostnames (example.com) and explicit wildcard prefixes
|
||||
* (*.example.com). A plain hostname implicitly covers all its subdomains
|
||||
* at match time.
|
||||
* @param mixed $raw Raw textarea value.
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
public function sanitize_hostname_list_public( mixed $raw ): array {
|
||||
return $this->sanitize_hostname_list( $raw );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitises a newline-separated hostname list into a deduplicated sorted array.
|
||||
*
|
||||
* @param mixed $raw Raw textarea value.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
exit;
|
||||
}
|
||||
|
||||
use MediaRightsAudit\Admin\Settings;
|
||||
use MediaRightsAudit\Core\Database;
|
||||
use MediaRightsAudit\Core\Queue\Scheduler;
|
||||
use MediaRightsAudit\External\ExternalScanner;
|
||||
|
|
@ -132,8 +133,7 @@ class ToolsPage {
|
|||
|
||||
case 'external':
|
||||
ExternalScanner::queue_all_pending();
|
||||
$raw_opts = get_option( 'robotstxt_mediaaudit_settings', array() );
|
||||
$opts_arr = is_array( $raw_opts ) ? $raw_opts : array();
|
||||
$opts_arr = Settings::get_effective_settings();
|
||||
$bs_setting = $opts_arr['external_batch_size'] ?? null;
|
||||
$ajax_bs = is_numeric( $bs_setting ) ? max( 1, (int) $bs_setting ) : 10;
|
||||
ExternalScanner::scan_batch( $ajax_bs );
|
||||
|
|
|
|||
Loading…
Reference in a new issue