Automatic WordPress security: local firewall, malware and file-integrity scanning, vulnerability protection, quarantine, scheduled backups, an optional page cache, and automatic global threat intelligence. See README.md for installation, update, and uninstall instructions.
597 lines
36 KiB
PHP
597 lines
36 KiB
PHP
<?php
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
$argus_active_page = 'cache';
|
|
include ARGUS_WPD_DIR . 'admin/views/partials/header.php';
|
|
|
|
$tabs = array(
|
|
'overview' => __( 'Overview', 'argus-wordpress-defence' ),
|
|
'page-cache' => __( 'Page Cache', 'argus-wordpress-defence' ),
|
|
'discovery' => __( 'Page Discovery', 'argus-wordpress-defence' ),
|
|
'rules' => __( 'Cache Rules', 'argus-wordpress-defence' ),
|
|
'compression' => __( 'Compression', 'argus-wordpress-defence' ),
|
|
'warming' => __( 'Preload', 'argus-wordpress-defence' ),
|
|
'purge' => __( 'Purge & Cache', 'argus-wordpress-defence' ),
|
|
'analytics' => __( 'Analytics', 'argus-wordpress-defence' ),
|
|
'advanced' => __( 'Advanced', 'argus-wordpress-defence' ),
|
|
);
|
|
|
|
$hit_30d = $log_summary_30d[ Argus_Static_Cache::STATUS_HIT ]['count'] ?? 0;
|
|
$stale_30d = $log_summary_30d[ Argus_Static_Cache::STATUS_STALE ]['count'] ?? 0;
|
|
$miss_30d = $log_summary_30d[ Argus_Static_Cache::STATUS_MISS ]['count'] ?? 0;
|
|
$revalidated_30d = $log_summary_30d[ Argus_Static_Cache::STATUS_REVALIDATED ]['count'] ?? 0;
|
|
$bypass_30d = $log_summary_30d[ Argus_Static_Cache::STATUS_BYPASS ]['count'] ?? 0;
|
|
$excluded_30d = $log_summary_30d[ Argus_Static_Cache::STATUS_EXCLUDED ]['count'] ?? 0;
|
|
$accelerated_30d = $hit_30d + $stale_30d;
|
|
$origin_reached_30d = $miss_30d + $revalidated_30d;
|
|
$total_eligible_30d = $accelerated_30d + $origin_reached_30d;
|
|
$dynamic_protected_30d = $bypass_30d + $excluded_30d;
|
|
|
|
$requests_reduced_pct = $total_eligible_30d > 0 ? round( ( $accelerated_30d / $total_eligible_30d ) * 100 ) : null;
|
|
$cache_efficiency_pct = $total_eligible_30d > 0 ? round( ( $accelerated_30d / max( 1, $total_eligible_30d + $dynamic_protected_30d ) ) * 100, 1 ) : null;
|
|
|
|
$performance_status = ! $settings['static_cache_enabled']
|
|
? array( 'label' => __( 'Not Enabled', 'argus-wordpress-defence' ), 'chip' => 'chip-off' )
|
|
: ( $total_eligible_30d < 20
|
|
? array( 'label' => __( 'Learning', 'argus-wordpress-defence' ), 'chip' => 'chip-amber' )
|
|
: array( 'label' => __( 'Optimised', 'argus-wordpress-defence' ), 'chip' => 'chip-emerald' ) );
|
|
|
|
$cumulative = 0;
|
|
$cumulative_series = array();
|
|
foreach ( $daily_series as $day ) {
|
|
$cumulative += (int) $day['hit'];
|
|
$cumulative_series[] = array( 'label' => $day['date'], 'value' => $cumulative );
|
|
}
|
|
|
|
?>
|
|
|
|
<h1 class="argus-wpd-page-title"><?php esc_html_e( 'Cache & Performance', 'argus-wordpress-defence' ); ?></h1>
|
|
<p style="color:var(--muted);font-size:13px;margin:0 0 20px;"><?php esc_html_e( 'Your website is accelerated safely. Public pages are cached automatically when safe, while login areas, personalised content, shopping carts, and other dynamic pages are always excluded.', 'argus-wordpress-defence' ); ?></p>
|
|
|
|
<?php if ( ! empty( $notice ) ) : ?>
|
|
<div class="notice notice-<?php echo esc_attr( $notice_type ); ?>" style="padding:14px 18px;margin:0 0 20px;"><p style="margin:0"><?php echo esc_html( $notice ); ?></p></div>
|
|
<?php endif; ?>
|
|
|
|
<div class="argus-wpd-range-tabs" style="margin-bottom:20px;flex-wrap:wrap;">
|
|
<?php foreach ( $tabs as $key => $label ) : ?>
|
|
<a href="<?php echo esc_url( admin_url( 'admin.php?page=argus-wpd-cache&tab=' . $key ) ); ?>" class="<?php echo $key === $tab ? 'active' : ''; ?>"><?php echo esc_html( $label ); ?></a>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
<?php if ( 'overview' === $tab ) : ?>
|
|
|
|
<div class="argus-wpd-status-row">
|
|
<div class="argus-wpd-status-chip <?php echo esc_attr( $performance_status['chip'] ); ?>">
|
|
<span class="dot"></span>
|
|
<span class="label"><?php esc_html_e( 'PERFORMANCE', 'argus-wordpress-defence' ); ?></span>
|
|
<span class="state"><?php echo esc_html( strtoupper( $performance_status['label'] ) ); ?></span>
|
|
</div>
|
|
<div class="argus-wpd-status-chip chip-cyan">
|
|
<span class="dot"></span>
|
|
<span class="label"><?php esc_html_e( 'AUTOMATIC UPDATES', 'argus-wordpress-defence' ); ?></span>
|
|
<span class="state"><?php echo esc_html( strtoupper( $auto_update['label'] ) ); ?></span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="argus-wpd-grid">
|
|
<div class="argus-wpd-metric-card">
|
|
<div class="argus-wpd-metric-label"><?php esc_html_e( 'Pages Accelerated', 'argus-wordpress-defence' ); ?></div>
|
|
<div class="argus-wpd-metric-value"><?php echo esc_html( number_format_i18n( $accelerated_30d ) ); ?></div>
|
|
<div class="argus-wpd-metric-sub"><?php esc_html_e( 'Delivered instantly, last 30 days', 'argus-wordpress-defence' ); ?></div>
|
|
</div>
|
|
<div class="argus-wpd-metric-card">
|
|
<div class="argus-wpd-metric-label"><?php esc_html_e( 'Website Requests Reduced', 'argus-wordpress-defence' ); ?></div>
|
|
<div class="argus-wpd-metric-value"><?php echo null === $requests_reduced_pct ? '—' : esc_html( $requests_reduced_pct . '%' ); ?></div>
|
|
<div class="argus-wpd-metric-sub"><?php esc_html_e( "Didn't need to be processed by WordPress", 'argus-wordpress-defence' ); ?></div>
|
|
</div>
|
|
<div class="argus-wpd-metric-card">
|
|
<div class="argus-wpd-metric-label"><?php esc_html_e( 'Cache Efficiency', 'argus-wordpress-defence' ); ?></div>
|
|
<div class="argus-wpd-metric-value"><?php echo null === $cache_efficiency_pct ? '—' : esc_html( $cache_efficiency_pct . '%' ); ?></div>
|
|
<div class="argus-wpd-metric-sub"><?php esc_html_e( 'Of all safe, cacheable visits', 'argus-wordpress-defence' ); ?></div>
|
|
</div>
|
|
<div class="argus-wpd-metric-card">
|
|
<div class="argus-wpd-metric-label"><?php esc_html_e( 'Dynamic Pages Protected', 'argus-wordpress-defence' ); ?></div>
|
|
<div class="argus-wpd-metric-value"><?php echo esc_html( number_format_i18n( $dynamic_protected_30d ) ); ?></div>
|
|
<div class="argus-wpd-metric-sub"><?php esc_html_e( 'Kept safe from shared caching, last 30 days', 'argus-wordpress-defence' ); ?></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="argus-wpd-area-card">
|
|
<div class="argus-wpd-area-head">
|
|
<h2 style="margin:0"><?php esc_html_e( 'Pages Accelerated', 'argus-wordpress-defence' ); ?> · <?php esc_html_e( 'Last 14 days, cumulative', 'argus-wordpress-defence' ); ?></h2>
|
|
</div>
|
|
<?php if ( $cumulative <= 0 ) : ?>
|
|
<p class="argus-wpd-area-empty"><?php esc_html_e( 'No pages accelerated yet -- once Page Cache is turned on, this fills in automatically.', 'argus-wordpress-defence' ); ?></p>
|
|
<?php else : ?>
|
|
<?php echo Argus_Charts::area_chart( $cumulative_series ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<?php if ( ! $settings['static_cache_enabled'] ) : ?>
|
|
<div class="argus-wpd-panel">
|
|
<h2><?php esc_html_e( 'Turn on website acceleration', 'argus-wordpress-defence' ); ?></h2>
|
|
<p style="color:var(--faint);font-size:12.5px;margin:-8px 0 14px;"><?php esc_html_e( 'Safe Automatic mode is recommended -- ARGUS decides what is safe to accelerate for you.', 'argus-wordpress-defence' ); ?></p>
|
|
<a href="<?php echo esc_url( admin_url( 'admin.php?page=argus-wpd-cache&tab=page-cache' ) ); ?>" class="button button-primary"><?php esc_html_e( 'Go to Page Cache settings', 'argus-wordpress-defence' ); ?></a>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php elseif ( 'page-cache' === $tab ) : ?>
|
|
|
|
<div class="argus-wpd-panel">
|
|
<h2><?php esc_html_e( 'Safe Automatic — Recommended', 'argus-wordpress-defence' ); ?></h2>
|
|
<p style="color:var(--faint);font-size:12.5px;margin:-8px 0 16px;"><?php esc_html_e( 'ARGUS automatically caches only safe, public, anonymous pages. Login areas, personalised content, and shopping carts are always excluded -- there is nothing you need to configure for this to work safely.', 'argus-wordpress-defence' ); ?></p>
|
|
<form method="post">
|
|
<?php wp_nonce_field( 'argus_wpd_cache_settings', 'argus_wpd_cache_settings_nonce' ); ?>
|
|
<table class="form-table">
|
|
<tr>
|
|
<th><?php esc_html_e( 'Website Acceleration', 'argus-wordpress-defence' ); ?></th>
|
|
<td><label><input type="checkbox" name="static_cache_enabled" <?php checked( $settings['static_cache_enabled'] ); ?> /> <?php esc_html_e( 'Enabled (Safe Automatic)', 'argus-wordpress-defence' ); ?></label></td>
|
|
</tr>
|
|
<tr>
|
|
<th><?php esc_html_e( 'How long pages stay cached', 'argus-wordpress-defence' ); ?></th>
|
|
<td>
|
|
<input type="number" name="static_cache_ttl_secs" value="<?php echo esc_attr( $settings['static_cache_ttl_secs'] ); ?>" min="60" step="60" style="width:100px" /> <?php esc_html_e( 'seconds', 'argus-wordpress-defence' ); ?>
|
|
<p class="description"><?php esc_html_e( 'Default: 3600 (1 hour). Pages update automatically after this, or immediately when you publish/edit content.', 'argus-wordpress-defence' ); ?></p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th><?php esc_html_e( 'Grace period', 'argus-wordpress-defence' ); ?></th>
|
|
<td>
|
|
<input type="number" name="cache_stale_grace_secs" value="<?php echo esc_attr( $settings['cache_stale_grace_secs'] ); ?>" min="0" step="60" style="width:100px" /> <?php esc_html_e( 'seconds', 'argus-wordpress-defence' ); ?>
|
|
<p class="description"><?php esc_html_e( 'Keeps serving a page instantly for a short extra window while ARGUS refreshes it in the background, so visitors never wait during an update.', 'argus-wordpress-defence' ); ?></p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th><?php esc_html_e( 'Additional pages to exclude', 'argus-wordpress-defence' ); ?></th>
|
|
<td>
|
|
<textarea name="cache_custom_exclude_paths" rows="4" style="width:100%;max-width:480px;" placeholder="/special-landing-page /members-area/*"><?php echo esc_textarea( implode( "\n", (array) $settings['cache_custom_exclude_paths'] ) ); ?></textarea>
|
|
<p class="description"><?php esc_html_e( 'One path per line. Use * as a wildcard. Optional -- ARGUS already protects login, checkout, and account pages automatically.', 'argus-wordpress-defence' ); ?></p>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<?php submit_button( __( 'Save', 'argus-wordpress-defence' ) ); ?>
|
|
</form>
|
|
</div>
|
|
|
|
<div class="argus-wpd-panel">
|
|
<h2><?php esc_html_e( 'Automatically Protected', 'argus-wordpress-defence' ); ?></h2>
|
|
<p style="color:var(--faint);font-size:12.5px;margin:-8px 0 14px;"><?php esc_html_e( 'These are never cached, with no configuration needed:', 'argus-wordpress-defence' ); ?></p>
|
|
<ul style="font-size:13px;color:var(--text);margin:0;padding-left:20px;line-height:1.9;">
|
|
<li><?php esc_html_e( 'Your login and admin area', 'argus-wordpress-defence' ); ?></li>
|
|
<li><?php esc_html_e( 'Logged-in visitors', 'argus-wordpress-defence' ); ?></li>
|
|
<li><?php esc_html_e( 'Shopping cart, checkout, and account pages (WooCommerce)', 'argus-wordpress-defence' ); ?></li>
|
|
<li><?php esc_html_e( 'Search results and preview pages', 'argus-wordpress-defence' ); ?></li>
|
|
<li><?php esc_html_e( 'Comment forms and personalised content', 'argus-wordpress-defence' ); ?></li>
|
|
</ul>
|
|
</div>
|
|
|
|
<?php elseif ( 'discovery' === $tab ) : ?>
|
|
|
|
<div class="argus-wpd-grid">
|
|
<div class="argus-wpd-metric-card">
|
|
<div class="argus-wpd-metric-label"><?php esc_html_e( 'Pages Found', 'argus-wordpress-defence' ); ?></div>
|
|
<div class="argus-wpd-metric-value"><?php echo esc_html( number_format_i18n( $discovery_summary['total'] ?? 0 ) ); ?></div>
|
|
</div>
|
|
<div class="argus-wpd-metric-card">
|
|
<div class="argus-wpd-metric-label"><?php esc_html_e( 'Eligible for Acceleration', 'argus-wordpress-defence' ); ?></div>
|
|
<div class="argus-wpd-metric-value"><?php echo esc_html( number_format_i18n( $discovery_summary['eligible'] ?? 0 ) ); ?></div>
|
|
</div>
|
|
<div class="argus-wpd-metric-card">
|
|
<div class="argus-wpd-metric-label"><?php esc_html_e( 'Excluded for Safety', 'argus-wordpress-defence' ); ?></div>
|
|
<div class="argus-wpd-metric-value"><?php echo esc_html( number_format_i18n( $discovery_summary['excluded'] ?? 0 ) ); ?></div>
|
|
</div>
|
|
<div class="argus-wpd-metric-card">
|
|
<div class="argus-wpd-metric-label"><?php esc_html_e( 'Needs Review', 'argus-wordpress-defence' ); ?></div>
|
|
<div class="argus-wpd-metric-value"><?php echo esc_html( number_format_i18n( $discovery_summary['needs_review'] ?? 0 ) ); ?></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="argus-wpd-panel">
|
|
<p style="font-size:13px;color:var(--text);margin:0 0 12px;">
|
|
<?php if ( ! empty( $discovery_summary['last_run'] ) ) : ?>
|
|
<?php
|
|
printf(
|
|
|
|
esc_html__( 'Last checked %s ago.', 'argus-wordpress-defence' ),
|
|
esc_html( human_time_diff( strtotime( $discovery_summary['last_run'] . ' UTC' ) ) )
|
|
);
|
|
?>
|
|
<?php else : ?>
|
|
<?php esc_html_e( "ARGUS hasn't looked for your pages yet.", 'argus-wordpress-defence' ); ?>
|
|
<?php endif; ?>
|
|
</p>
|
|
<?php if ( ! empty( $discovery_summary['last_error'] ) ) : ?>
|
|
<p style="font-size:12.5px;color:var(--amber);margin:0 0 12px;"><?php echo esc_html( $discovery_summary['last_error'] ); ?></p>
|
|
<?php endif; ?>
|
|
<form method="post">
|
|
<?php wp_nonce_field( 'argus_wpd_cache_run_discovery', 'argus_wpd_cache_run_discovery_nonce' ); ?>
|
|
<button type="submit" class="button button-primary"><?php esc_html_e( 'Find Pages Now', 'argus-wordpress-defence' ); ?></button>
|
|
</form>
|
|
</div>
|
|
|
|
<?php if ( ! empty( $discovered_urls['rows'] ) ) : ?>
|
|
<div class="argus-wpd-panel">
|
|
<h2><?php esc_html_e( 'Discovered Pages', 'argus-wordpress-defence' ); ?></h2>
|
|
<table class="widefat striped">
|
|
<thead><tr><th><?php esc_html_e( 'Page', 'argus-wordpress-defence' ); ?></th><th><?php esc_html_e( 'Status', 'argus-wordpress-defence' ); ?></th></tr></thead>
|
|
<tbody>
|
|
<?php foreach ( $discovered_urls['rows'] as $row ) : ?>
|
|
<tr>
|
|
<td style="word-break:break-all;"><?php echo esc_html( $row->url ); ?></td>
|
|
<td>
|
|
<?php
|
|
$eligible_labels = array(
|
|
Argus_Cache_Eligibility::SAFE_TO_CACHE => __( 'Eligible', 'argus-wordpress-defence' ),
|
|
Argus_Cache_Eligibility::BYPASS => __( 'Excluded', 'argus-wordpress-defence' ),
|
|
Argus_Cache_Eligibility::FORCE_EXCLUDED => __( 'Excluded', 'argus-wordpress-defence' ),
|
|
Argus_Cache_Eligibility::NEEDS_REVIEW => __( 'Needs Review', 'argus-wordpress-defence' ),
|
|
);
|
|
echo esc_html( $eligible_labels[ $row->eligibility ] ?? $row->eligibility );
|
|
?>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
<?php
|
|
$page = $discovered_urls['page'];
|
|
$total_pages = $discovered_urls['total_pages'];
|
|
$base_url = remove_query_arg( 'paged' );
|
|
include ARGUS_WPD_DIR . 'admin/views/partials/pagination.php';
|
|
?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php elseif ( 'rules' === $tab ) : ?>
|
|
|
|
<div class="argus-wpd-panel">
|
|
<h2><?php esc_html_e( 'How ARGUS decides what to accelerate', 'argus-wordpress-defence' ); ?></h2>
|
|
<p style="color:var(--faint);font-size:12.5px;margin:-8px 0 16px;"><?php esc_html_e( 'Checked in this order for every page view. Safety always comes first.', 'argus-wordpress-defence' ); ?></p>
|
|
<ol style="font-size:13px;color:var(--text);margin:0;padding-left:20px;line-height:2;">
|
|
<li><?php esc_html_e( 'Security and privacy checks', 'argus-wordpress-defence' ); ?></li>
|
|
<li><?php esc_html_e( 'Is the visitor logged in?', 'argus-wordpress-defence' ); ?></li>
|
|
<li><?php esc_html_e( 'Shopping cart, checkout, or account activity (WooCommerce)', 'argus-wordpress-defence' ); ?></li>
|
|
<li><?php esc_html_e( 'Login, admin, and other protected areas', 'argus-wordpress-defence' ); ?></li>
|
|
<li><?php esc_html_e( 'Your own additional exclusions', 'argus-wordpress-defence' ); ?></li>
|
|
<li><?php esc_html_e( 'Personalised or changing content', 'argus-wordpress-defence' ); ?></li>
|
|
<li><?php esc_html_e( 'What the page itself says about being cacheable', 'argus-wordpress-defence' ); ?></li>
|
|
<li><?php esc_html_e( 'Safe to accelerate', 'argus-wordpress-defence' ); ?></li>
|
|
</ol>
|
|
</div>
|
|
|
|
<div class="argus-wpd-panel">
|
|
<h2><?php esc_html_e( 'Recently excluded pages', 'argus-wordpress-defence' ); ?></h2>
|
|
<p style="color:var(--faint);font-size:12.5px;margin:-8px 0 14px;"><?php esc_html_e( 'For troubleshooting -- shows why a specific page was not accelerated.', 'argus-wordpress-defence' ); ?></p>
|
|
<?php $rule_examples = array_slice( Argus_Cache_Log::recent( 15, Argus_Static_Cache::STATUS_BYPASS ), 0, 15 ); ?>
|
|
<?php if ( empty( $rule_examples ) ) : ?>
|
|
<p class="argus-wpd-empty" style="padding:10px 0;"><?php esc_html_e( 'Nothing to show yet.', 'argus-wordpress-defence' ); ?></p>
|
|
<?php else : ?>
|
|
<table class="widefat striped">
|
|
<thead><tr><th><?php esc_html_e( 'Page', 'argus-wordpress-defence' ); ?></th><th><?php esc_html_e( 'Reason', 'argus-wordpress-defence' ); ?></th></tr></thead>
|
|
<tbody>
|
|
<?php foreach ( $rule_examples as $row ) : ?>
|
|
<tr>
|
|
<td style="word-break:break-all;"><?php echo esc_html( wp_parse_url( $row['u'] ?? '', PHP_URL_PATH ) ?: ( $row['u'] ?? '' ) ); ?></td>
|
|
<td><?php echo esc_html( $row['r'] ?? '' ); ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<?php elseif ( 'compression' === $tab ) : ?>
|
|
|
|
<?php if ( $compression_stats['gzip']['files'] > 0 || $compression_stats['brotli']['files'] > 0 ) : ?>
|
|
<div class="argus-wpd-grid">
|
|
<div class="argus-wpd-metric-card">
|
|
<div class="argus-wpd-metric-label"><?php esc_html_e( 'Data Saved', 'argus-wordpress-defence' ); ?></div>
|
|
<div class="argus-wpd-metric-value"><?php echo esc_html( size_format( $compression_stats['total_bytes_saved'] ) ); ?></div>
|
|
<div class="argus-wpd-metric-sub"><?php esc_html_e( 'Across all accelerated pages', 'argus-wordpress-defence' ); ?></div>
|
|
</div>
|
|
<div class="argus-wpd-metric-card">
|
|
<div class="argus-wpd-metric-label"><?php esc_html_e( 'Gzip', 'argus-wordpress-defence' ); ?></div>
|
|
<div class="argus-wpd-metric-value"><?php echo $compression_stats['gzip']['files'] > 0 ? esc_html( $compression_stats['gzip']['avg_savings_pct'] . '%' ) : '—'; ?></div>
|
|
<div class="argus-wpd-metric-sub">
|
|
<?php
|
|
echo esc_html(
|
|
sprintf(
|
|
|
|
__( 'Average savings, %1$d page(s), %2$s saved', 'argus-wordpress-defence' ),
|
|
$compression_stats['gzip']['files'],
|
|
size_format( $compression_stats['gzip']['bytes_saved'] )
|
|
)
|
|
);
|
|
?>
|
|
</div>
|
|
</div>
|
|
<div class="argus-wpd-metric-card">
|
|
<div class="argus-wpd-metric-label"><?php esc_html_e( 'Brotli', 'argus-wordpress-defence' ); ?></div>
|
|
<div class="argus-wpd-metric-value"><?php echo $compression_stats['brotli']['files'] > 0 ? esc_html( $compression_stats['brotli']['avg_savings_pct'] . '%' ) : '—'; ?></div>
|
|
<div class="argus-wpd-metric-sub">
|
|
<?php
|
|
echo esc_html(
|
|
$compression_stats['brotli']['files'] > 0
|
|
? sprintf(
|
|
|
|
__( 'Average savings, %1$d page(s), %2$s saved', 'argus-wordpress-defence' ),
|
|
$compression_stats['brotli']['files'],
|
|
size_format( $compression_stats['brotli']['bytes_saved'] )
|
|
)
|
|
: __( 'Not currently in use', 'argus-wordpress-defence' )
|
|
);
|
|
?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="argus-wpd-panel">
|
|
<h2><?php esc_html_e( 'Compression', 'argus-wordpress-defence' ); ?></h2>
|
|
<p style="color:var(--faint);font-size:12.5px;margin:-8px 0 16px;"><?php esc_html_e( 'Accelerated pages are compressed automatically before being sent to visitors -- smaller downloads, faster page loads. Each visitor\'s browser receives only the format it supports.', 'argus-wordpress-defence' ); ?></p>
|
|
<form method="post">
|
|
<?php wp_nonce_field( 'argus_wpd_cache_compression', 'argus_wpd_cache_compression_nonce' ); ?>
|
|
<table class="form-table">
|
|
<tr>
|
|
<th><?php esc_html_e( 'Gzip Compression', 'argus-wordpress-defence' ); ?></th>
|
|
<td>
|
|
<label><input type="checkbox" name="cache_gzip_enabled" <?php checked( $settings['cache_gzip_enabled'] ); ?> <?php disabled( ! $gzip_available ); ?> /> <?php esc_html_e( 'Enabled', 'argus-wordpress-defence' ); ?></label>
|
|
<?php if ( ! $gzip_available ) : ?><p class="description"><?php esc_html_e( 'Not available on this server.', 'argus-wordpress-defence' ); ?></p><?php endif; ?>
|
|
<p class="description"><?php esc_html_e( 'Compression level (1 = fastest, 9 = smallest)', 'argus-wordpress-defence' ); ?></p>
|
|
<input type="number" name="cache_gzip_level" value="<?php echo esc_attr( $settings['cache_gzip_level'] ); ?>" min="1" max="9" style="width:80px" />
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th><?php esc_html_e( 'Brotli Compression', 'argus-wordpress-defence' ); ?></th>
|
|
<td>
|
|
<label><input type="checkbox" name="cache_brotli_enabled" <?php checked( $settings['cache_brotli_enabled'] ); ?> <?php disabled( ! $brotli_available ); ?> /> <?php esc_html_e( 'Enabled', 'argus-wordpress-defence' ); ?></label>
|
|
<?php if ( ! $brotli_available ) : ?><p class="description"><?php esc_html_e( 'Not available on this server -- your hosting provider would need to enable this. Gzip is used automatically instead.', 'argus-wordpress-defence' ); ?></p><?php endif; ?>
|
|
<p class="description"><?php esc_html_e( 'Compression level (0 = fastest, 11 = smallest)', 'argus-wordpress-defence' ); ?></p>
|
|
<input type="number" name="cache_brotli_level" value="<?php echo esc_attr( $settings['cache_brotli_level'] ); ?>" min="0" max="11" style="width:80px" />
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th><?php esc_html_e( 'Minimum page size to compress', 'argus-wordpress-defence' ); ?></th>
|
|
<td><input type="number" name="cache_min_compress_bytes" value="<?php echo esc_attr( $settings['cache_min_compress_bytes'] ); ?>" min="0" style="width:100px" /> <?php esc_html_e( 'bytes', 'argus-wordpress-defence' ); ?></td>
|
|
</tr>
|
|
</table>
|
|
<?php submit_button( __( 'Save', 'argus-wordpress-defence' ) ); ?>
|
|
</form>
|
|
</div>
|
|
|
|
<?php elseif ( 'warming' === $tab ) : ?>
|
|
|
|
<div class="argus-wpd-grid">
|
|
<div class="argus-wpd-metric-card">
|
|
<div class="argus-wpd-metric-label"><?php esc_html_e( 'Pages Prepared', 'argus-wordpress-defence' ); ?></div>
|
|
<div class="argus-wpd-metric-value"><?php echo esc_html( number_format_i18n( $warmer_status['done'] ?? 0 ) ); ?></div>
|
|
</div>
|
|
<div class="argus-wpd-metric-card">
|
|
<div class="argus-wpd-metric-label"><?php esc_html_e( 'Waiting', 'argus-wordpress-defence' ); ?></div>
|
|
<div class="argus-wpd-metric-value"><?php echo esc_html( number_format_i18n( ( $warmer_status['queued'] ?? 0 ) + ( $warmer_status['processing'] ?? 0 ) ) ); ?></div>
|
|
</div>
|
|
<div class="argus-wpd-metric-card">
|
|
<div class="argus-wpd-metric-label"><?php esc_html_e( 'Needs Attention', 'argus-wordpress-defence' ); ?></div>
|
|
<div class="argus-wpd-metric-value"><?php echo esc_html( number_format_i18n( $warmer_status['failed'] ?? 0 ) ); ?></div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php if ( ! empty( $warmer_status['paused_until'] ) ) : ?>
|
|
<div class="notice notice-warning" style="padding:14px 18px;margin:0 0 20px;"><p style="margin:0"><?php esc_html_e( 'Preparation is briefly paused to avoid adding load to your website. It will resume automatically.', 'argus-wordpress-defence' ); ?></p></div>
|
|
<?php endif; ?>
|
|
|
|
<div class="argus-wpd-panel">
|
|
<h2><?php esc_html_e( 'Preload / Cache Warming', 'argus-wordpress-defence' ); ?></h2>
|
|
<p style="color:var(--faint);font-size:12.5px;margin:-8px 0 16px;"><?php esc_html_e( 'ARGUS can visit your public pages ahead of time so the very first real visitor still gets an instant page load. This is always paced gently and pauses automatically if your website is under load.', 'argus-wordpress-defence' ); ?></p>
|
|
<form method="post">
|
|
<?php wp_nonce_field( 'argus_wpd_cache_warming', 'argus_wpd_cache_warming_nonce' ); ?>
|
|
<table class="form-table">
|
|
<tr>
|
|
<th><?php esc_html_e( 'Page Discovery', 'argus-wordpress-defence' ); ?></th>
|
|
<td><label><input type="checkbox" name="cache_discovery_enabled" <?php checked( $settings['cache_discovery_enabled'] ); ?> /> <?php esc_html_e( 'Automatically find pages daily', 'argus-wordpress-defence' ); ?></label></td>
|
|
</tr>
|
|
<tr>
|
|
<th><?php esc_html_e( 'Preloading', 'argus-wordpress-defence' ); ?></th>
|
|
<td><label><input type="checkbox" name="cache_warming_enabled" <?php checked( $settings['cache_warming_enabled'] ); ?> /> <?php esc_html_e( 'Enabled', 'argus-wordpress-defence' ); ?></label></td>
|
|
</tr>
|
|
<tr>
|
|
<th><?php esc_html_e( 'How many pages to prepare at once', 'argus-wordpress-defence' ); ?></th>
|
|
<td><input type="number" name="cache_warm_concurrency" value="<?php echo esc_attr( $settings['cache_warm_concurrency'] ); ?>" min="1" max="10" style="width:80px" /></td>
|
|
</tr>
|
|
<tr>
|
|
<th><?php esc_html_e( 'Pages per hour', 'argus-wordpress-defence' ); ?></th>
|
|
<td><input type="number" name="cache_warm_batch_size" value="<?php echo esc_attr( $settings['cache_warm_batch_size'] ); ?>" min="1" max="200" style="width:80px" /></td>
|
|
</tr>
|
|
<tr>
|
|
<th><?php esc_html_e( 'Pause between groups', 'argus-wordpress-defence' ); ?></th>
|
|
<td><input type="number" name="cache_warm_min_interval_secs" value="<?php echo esc_attr( $settings['cache_warm_min_interval_secs'] ); ?>" min="0" max="30" style="width:80px" /> <?php esc_html_e( 'seconds', 'argus-wordpress-defence' ); ?></td>
|
|
</tr>
|
|
</table>
|
|
<?php submit_button( __( 'Save', 'argus-wordpress-defence' ) ); ?>
|
|
</form>
|
|
<form method="post" style="margin-top:10px;">
|
|
<?php wp_nonce_field( 'argus_wpd_cache_run_warming', 'argus_wpd_cache_run_warming_nonce' ); ?>
|
|
<button type="submit" class="button"><?php esc_html_e( 'Prepare Pages Now', 'argus-wordpress-defence' ); ?></button>
|
|
</form>
|
|
</div>
|
|
|
|
<?php elseif ( 'purge' === $tab ) : ?>
|
|
|
|
<div class="argus-wpd-panel">
|
|
<h2><?php esc_html_e( 'Refresh Cache', 'argus-wordpress-defence' ); ?></h2>
|
|
<p style="color:var(--faint);font-size:12.5px;margin:-8px 0 14px;">
|
|
<?php
|
|
printf(
|
|
|
|
esc_html__( '%1$s pages currently accelerated (%2$s).', 'argus-wordpress-defence' ),
|
|
esc_html( number_format_i18n( $cache_stats['file_count'] ) ),
|
|
esc_html( size_format( $cache_stats['total_bytes'] ) )
|
|
);
|
|
?>
|
|
</p>
|
|
<form method="post" onsubmit="return confirm('<?php echo esc_js( __( 'Refresh the entire cache? All visitors will get a freshly-generated page until it rebuilds.', 'argus-wordpress-defence' ) ); ?>')">
|
|
<?php wp_nonce_field( 'argus_wpd_cache_purge_all', 'argus_wpd_cache_purge_all_nonce' ); ?>
|
|
<button type="submit" class="button"><?php esc_html_e( 'Refresh Everything', 'argus-wordpress-defence' ); ?></button>
|
|
</form>
|
|
</div>
|
|
|
|
<div class="argus-wpd-panel">
|
|
<h2><?php esc_html_e( 'Refresh a Specific Page', 'argus-wordpress-defence' ); ?></h2>
|
|
<form method="post" class="argus-wpd-inline-form">
|
|
<?php wp_nonce_field( 'argus_wpd_cache_purge_url', 'argus_wpd_cache_purge_url_nonce' ); ?>
|
|
<input type="text" name="purge_url" placeholder="<?php echo esc_attr( home_url( '/example-page/' ) ); ?>" style="min-width:320px" required />
|
|
<button type="submit" class="button"><?php esc_html_e( 'Refresh', 'argus-wordpress-defence' ); ?></button>
|
|
</form>
|
|
<form method="post" class="argus-wpd-inline-form" style="margin-top:10px;">
|
|
<?php wp_nonce_field( 'argus_wpd_cache_purge_pattern', 'argus_wpd_cache_purge_pattern_nonce' ); ?>
|
|
<input type="text" name="purge_pattern" placeholder="<?php echo esc_attr( home_url( '/blog/*' ) ); ?>" style="min-width:320px" required />
|
|
<button type="submit" class="button"><?php esc_html_e( 'Refresh Matching Pages', 'argus-wordpress-defence' ); ?></button>
|
|
</form>
|
|
</div>
|
|
|
|
<div class="argus-wpd-panel">
|
|
<h2><?php esc_html_e( 'Recently Accelerated Pages', 'argus-wordpress-defence' ); ?></h2>
|
|
<?php if ( empty( $cached_urls ) ) : ?>
|
|
<p class="argus-wpd-empty" style="padding:10px 0;"><?php esc_html_e( 'Nothing accelerated yet.', 'argus-wordpress-defence' ); ?></p>
|
|
<?php else : ?>
|
|
<table class="widefat striped">
|
|
<thead><tr><th><?php esc_html_e( 'Page', 'argus-wordpress-defence' ); ?></th><th><?php esc_html_e( 'Size', 'argus-wordpress-defence' ); ?></th><th><?php esc_html_e( 'Age', 'argus-wordpress-defence' ); ?></th><th><?php esc_html_e( 'Compression', 'argus-wordpress-defence' ); ?></th></tr></thead>
|
|
<tbody>
|
|
<?php foreach ( $cached_urls as $row ) : ?>
|
|
<tr>
|
|
<td style="word-break:break-all;"><?php echo esc_html( $row['url'] ); ?></td>
|
|
<td><?php echo esc_html( size_format( $row['bytes'] ) ); ?></td>
|
|
<td><?php echo null === $row['age_secs'] ? '—' : esc_html( human_time_diff( time() - $row['age_secs'] ) . ' ' . __( 'ago', 'argus-wordpress-defence' ) ); ?></td>
|
|
<td>
|
|
<?php
|
|
$badges = array();
|
|
if ( $row['has_brotli'] ) { $badges[] = 'Brotli'; }
|
|
if ( $row['has_gzip'] ) { $badges[] = 'Gzip'; }
|
|
echo esc_html( $badges ? implode( ', ', $badges ) : __( 'None', 'argus-wordpress-defence' ) );
|
|
?>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<?php elseif ( 'analytics' === $tab ) : ?>
|
|
|
|
<div class="argus-wpd-area-card">
|
|
<div class="argus-wpd-area-head"><h2 style="margin:0"><?php esc_html_e( 'Pages Accelerated', 'argus-wordpress-defence' ); ?> · <?php esc_html_e( 'Last 14 days, cumulative', 'argus-wordpress-defence' ); ?></h2></div>
|
|
<?php if ( $cumulative <= 0 ) : ?>
|
|
<p class="argus-wpd-area-empty"><?php esc_html_e( 'No activity recorded yet.', 'argus-wordpress-defence' ); ?></p>
|
|
<?php else : ?>
|
|
<?php echo Argus_Charts::area_chart( $cumulative_series ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div class="argus-wpd-panel" style="display:flex;gap:32px;align-items:center;flex-wrap:wrap;">
|
|
<?php
|
|
$distribution = array(
|
|
__( 'Served from Cache', 'argus-wordpress-defence' ) => $hit_30d + $stale_30d,
|
|
__( 'Loaded from WordPress', 'argus-wordpress-defence' ) => $miss_30d + $revalidated_30d,
|
|
__( 'Excluded for Safety', 'argus-wordpress-defence' ) => $dynamic_protected_30d,
|
|
);
|
|
?>
|
|
<?php echo Argus_Charts::donut( $distribution ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
|
|
<div style="flex:1;min-width:220px;"><?php echo Argus_Charts::legend( $distribution ); // phpcs:ignore WordPress.Security.EscapeOutput ?></div>
|
|
</div>
|
|
|
|
<div class="argus-wpd-panel">
|
|
<h2><?php esc_html_e( 'Recent Activity', 'argus-wordpress-defence' ); ?></h2>
|
|
<div class="argus-wpd-range-tabs" style="margin-bottom:14px;">
|
|
<a href="<?php echo esc_url( admin_url( 'admin.php?page=argus-wpd-cache&tab=analytics' ) ); ?>" class="<?php echo empty( $_GET['status'] ) ? 'active' : ''; ?>"><?php esc_html_e( 'All', 'argus-wordpress-defence' ); ?></a>
|
|
<?php foreach ( array( 'HIT' => __( 'Served from Cache', 'argus-wordpress-defence' ), 'MISS' => __( 'Loaded from WordPress', 'argus-wordpress-defence' ), 'BYPASS' => __( 'Excluded', 'argus-wordpress-defence' ), 'WARMED' => __( 'Preloaded', 'argus-wordpress-defence' ), 'PURGED' => __( 'Refreshed', 'argus-wordpress-defence' ) ) as $status_key => $status_label ) : ?>
|
|
<a href="<?php echo esc_url( admin_url( 'admin.php?page=argus-wpd-cache&tab=analytics&status=' . strtolower( $status_key ) ) ); ?>" class="<?php echo ( isset( $_GET['status'] ) && strtoupper( sanitize_key( wp_unslash( $_GET['status'] ) ) ) === $status_key ) ? 'active' : ''; ?>"><?php echo esc_html( $status_label ); ?></a>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php if ( empty( $recent_log ) ) : ?>
|
|
<p class="argus-wpd-empty" style="padding:10px 0;"><?php esc_html_e( 'No activity recorded yet.', 'argus-wordpress-defence' ); ?></p>
|
|
<?php else : ?>
|
|
<table class="widefat striped">
|
|
<thead><tr><th><?php esc_html_e( 'When', 'argus-wordpress-defence' ); ?></th><th><?php esc_html_e( 'Page', 'argus-wordpress-defence' ); ?></th><th><?php esc_html_e( 'Result', 'argus-wordpress-defence' ); ?></th></tr></thead>
|
|
<tbody>
|
|
<?php
|
|
$friendly_status = array(
|
|
'HIT' => __( 'Served from Cache', 'argus-wordpress-defence' ),
|
|
'STALE' => __( 'Served from Cache', 'argus-wordpress-defence' ),
|
|
'MISS' => __( 'Loaded from WordPress', 'argus-wordpress-defence' ),
|
|
'REVALIDATED' => __( 'Refreshed', 'argus-wordpress-defence' ),
|
|
'BYPASS' => __( 'Excluded', 'argus-wordpress-defence' ),
|
|
'EXCLUDED' => __( 'Excluded', 'argus-wordpress-defence' ),
|
|
'WARMED' => __( 'Preloaded', 'argus-wordpress-defence' ),
|
|
'PURGED' => __( 'Refreshed', 'argus-wordpress-defence' ),
|
|
'EXPIRED' => __( 'Renewed', 'argus-wordpress-defence' ),
|
|
);
|
|
?>
|
|
<?php foreach ( $recent_log as $row ) : ?>
|
|
<tr>
|
|
<td><?php echo esc_html( human_time_diff( (int) ( $row['t'] ?? time() ) ) . ' ' . __( 'ago', 'argus-wordpress-defence' ) ); ?></td>
|
|
<td style="word-break:break-all;"><?php echo esc_html( wp_parse_url( $row['u'] ?? '', PHP_URL_PATH ) ?: ( $row['u'] ?? '' ) ); ?></td>
|
|
<td><?php echo esc_html( $friendly_status[ $row['s'] ?? '' ] ?? ( $row['s'] ?? '' ) ); ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
<?php
|
|
$page = $log_page;
|
|
$total_pages = $log_total_pages;
|
|
$base_url = remove_query_arg( 'paged' );
|
|
include ARGUS_WPD_DIR . 'admin/views/partials/pagination.php';
|
|
?>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<?php elseif ( 'advanced' === $tab ) : ?>
|
|
|
|
<div class="argus-wpd-panel">
|
|
<h2><?php esc_html_e( 'Additional Performance Opportunity', 'argus-wordpress-defence' ); ?></h2>
|
|
<p style="color:var(--text);font-size:13px;margin:0 0 14px;line-height:1.6;"><?php esc_html_e( 'Your website could benefit from server-level compression for static files. ARGUS is already optimizing the content it can safely accelerate -- to compress images, fonts, and other static files further, your hosting provider may need to enable server-level compression.', 'argus-wordpress-defence' ); ?></p>
|
|
<table class="widefat" style="border:none;background:transparent;margin-bottom:14px;">
|
|
<tbody>
|
|
<tr>
|
|
<td style="border:none;padding:6px 0;color:var(--faint);font-size:12px;width:160px;"><?php esc_html_e( 'What this improves', 'argus-wordpress-defence' ); ?></td>
|
|
<td style="border:none;padding:6px 0;color:var(--text);font-size:13px;"><?php esc_html_e( 'Faster delivery of static website files.', 'argus-wordpress-defence' ); ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td style="border:none;padding:6px 0;color:var(--faint);font-size:12px;"><?php esc_html_e( 'Recommended next step', 'argus-wordpress-defence' ); ?></td>
|
|
<td style="border:none;padding:6px 0;color:var(--text);font-size:13px;"><?php esc_html_e( 'Contact your hosting provider.', 'argus-wordpress-defence' ); ?></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<?php
|
|
$provider_message = __( "Hello,\n\nI would like to confirm whether server-level compression is enabled for static assets on my WordPress website.\n\nCould you please confirm whether Gzip and/or Brotli compression is available for static files such as CSS, JavaScript, fonts and supported text-based assets?\n\nThank you.", 'argus-wordpress-defence' );
|
|
?>
|
|
<details>
|
|
<summary style="cursor:pointer;font-weight:600;font-size:12.5px;color:var(--cyan);"><?php esc_html_e( 'Copy message for your hosting provider', 'argus-wordpress-defence' ); ?></summary>
|
|
<textarea readonly rows="7" style="width:100%;max-width:520px;margin-top:10px;background:var(--panel-2);color:var(--text);border:1px solid var(--border);border-radius:8px;padding:10px;font-size:12.5px;font-family:inherit;" onclick="this.select();"><?php echo esc_textarea( $provider_message ); ?></textarea>
|
|
<p style="color:var(--faint);font-size:11.5px;margin:6px 0 0;"><?php esc_html_e( 'Click the text above to select it, then copy.', 'argus-wordpress-defence' ); ?></p>
|
|
</details>
|
|
</div>
|
|
|
|
<div class="argus-wpd-panel">
|
|
<details>
|
|
<summary style="cursor:pointer;font-weight:600;font-size:13px;"><?php esc_html_e( 'Advanced Diagnostics', 'argus-wordpress-defence' ); ?></summary>
|
|
<p style="color:var(--faint);font-size:12.5px;margin:12px 0 16px;"><?php esc_html_e( 'For troubleshooting with support -- not needed for normal use.', 'argus-wordpress-defence' ); ?></p>
|
|
<table class="widefat striped">
|
|
<tbody>
|
|
<tr><td><?php esc_html_e( 'Cached pages on disk', 'argus-wordpress-defence' ); ?></td><td><?php echo esc_html( number_format_i18n( $cache_stats['file_count'] ) ); ?></td></tr>
|
|
<tr><td><?php esc_html_e( 'Storage used', 'argus-wordpress-defence' ); ?></td><td><?php echo esc_html( size_format( $cache_stats['total_bytes'] ) ); ?></td></tr>
|
|
<tr><td><?php esc_html_e( 'Gzip available on this server', 'argus-wordpress-defence' ); ?></td><td><?php echo $gzip_available ? esc_html__( 'Yes', 'argus-wordpress-defence' ) : esc_html__( 'No', 'argus-wordpress-defence' ); ?></td></tr>
|
|
<tr><td><?php esc_html_e( 'Brotli available on this server', 'argus-wordpress-defence' ); ?></td><td><?php echo $brotli_available ? esc_html__( 'Yes', 'argus-wordpress-defence' ) : esc_html__( 'No', 'argus-wordpress-defence' ); ?></td></tr>
|
|
<tr><td><?php esc_html_e( 'Page discovery last run', 'argus-wordpress-defence' ); ?></td><td><?php echo esc_html( $discovery_summary['last_run'] ?: '—' ); ?></td></tr>
|
|
</tbody>
|
|
</table>
|
|
</details>
|
|
</div>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php include ARGUS_WPD_DIR . 'admin/views/partials/footer.php'; ?>
|