Files
argus-wp-defence/includes/class-argus-auto-update.php
T
ARGUSandClaude Sonnet 5 35efd3e485 ARGUS WordPress Defence 7.23.0
Real changes since 1.0.0, all live-verified before this release:

- Firewall: rule corpus expanded 19 -> 43 rules, real OWASP-CRS-equivalent
  coverage (XXE, SSRF, session fixation, Log4Shell/JNDI, scanner-tool
  detection, deeper SQL injection/XSS/PHP-injection).
- Fixed a real bug: a quarantined file's severity badge and its content
  analysis score could disagree with no explanation (e.g. a benign file
  showing CRITICAL next to Score 0); both are now derived consistently
  and shown together.
- ARGUS now always keeps itself updated, and can optionally do the same
  for every other installed plugin and theme (Settings, on by default) --
  uses WordPress's own native update system, nothing custom.
- Global Threat Intelligence is now opt-in, not automatic -- a single
  click on its own page, with an honest, specific description of exactly
  what's shared (an IP address, a reason code, a confidence score, a
  country). Previously connected automatically on activation.
- New first-run Welcome screen after activation: confirms what's already
  protecting the site, and surfaces the few real optional choices in one
  place.
- Dashboard: running version now visible in the header; new "IPs
  Tracked" and "ANIS Protections" metrics.
- Full WordPress.org Plugin Directory readiness audit performed against
  this codebase. Two real compliance issues found and fixed (see above:
  Global Threat Intelligence's default, and the self-update mechanism,
  which is excluded from this build entirely -- WordPress.org prohibits
  a plugin from using any update channel other than its own, even an
  inert one). This release is still self-distributed, not a WordPress.org
  submission -- that remains a future step.

Verified before publishing: this exact ZIP was installed, activated (14
admin pages loaded clean, zero PHP errors/warnings), and uninstalled
(zero leftover database tables or options) in a fresh, disposable
WordPress + MySQL environment.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-09 19:08:02 +00:00

70 lines
2.8 KiB
PHP

<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class Argus_Auto_Update {
public static function init() {
add_filter( 'auto_update_plugin', array( __CLASS__, 'force_plugin_auto_update' ), 10, 2 );
add_filter( 'auto_update_theme', array( __CLASS__, 'force_theme_auto_update' ), 10, 2 );
add_filter( 'plugin_auto_update_setting_html', array( __CLASS__, 'lock_admin_toggle' ), 10, 3 );
add_filter( 'site_option_auto_update_plugins', array( __CLASS__, 'ensure_self_in_list' ) );
add_filter( 'option_auto_update_plugins', array( __CLASS__, 'ensure_self_in_list' ) );
}
// ARGUS always auto-updates itself, independent of the site-wide setting
// below -- this is not user-configurable, matching the plugin's own
// self-protection design (ADR-0053 SS13.1).
public static function force_plugin_auto_update( $update, $item ) {
if ( isset( $item->plugin ) && ARGUS_WPD_BASENAME === $item->plugin ) {
return true;
}
if ( Argus_Settings::get( 'auto_update_all_enabled', true ) ) {
return true;
}
return $update;
}
// Uses WordPress core's own native automatic-update system
// (WP_Automatic_Updater, driven by the existing wp_version_check/
// wp_update_themes cron events and the official WordPress.org Themes
// API) -- no custom download/replace code, nothing external.
public static function force_theme_auto_update( $update, $item ) {
if ( Argus_Settings::get( 'auto_update_all_enabled', true ) ) {
return true;
}
return $update;
}
public static function ensure_self_in_list( $list ) {
$list = is_array( $list ) ? $list : array();
if ( ! in_array( ARGUS_WPD_BASENAME, $list, true ) ) {
$list[] = ARGUS_WPD_BASENAME;
}
return $list;
}
public static function lock_admin_toggle( $html, $plugin_file, $plugin_data ) {
if ( ARGUS_WPD_BASENAME !== $plugin_file ) {
return $html;
}
return '<span style="color:#00a86b;font-weight:600;">&#9679; ' . esc_html__( 'Automatic security updates: Enabled and protected', 'argus-wordpress-defence' ) . '</span>';
}
public static function status() {
if ( Argus_Settings::get( 'auto_update_all_enabled', true ) ) {
return array(
'label' => __( 'Enabled for All Plugins & Themes', 'argus-wordpress-defence' ),
'detail' => __( 'ARGUS Defence keeps ARGUS itself, and every other installed plugin and theme, on their latest available version automatically -- unpatched plugins/themes are one of the most common ways WordPress sites get compromised. You can turn this off for everything except ARGUS itself below.', 'argus-wordpress-defence' ),
);
}
return array(
'label' => __( 'Enabled for ARGUS Only', 'argus-wordpress-defence' ),
'detail' => __( 'ARGUS Defence automatically installs its own updates to stay protected. Automatic updates for your other plugins and themes are off -- turn them on below for stronger baseline protection.', 'argus-wordpress-defence' ),
);
}
}