$target ) ); self::install(); return; } if ( md5_file( $target ) !== md5_file( self::source_path() ) ) { self::maybe_log_self_heal( 'medium', 'MU enforcement core was out of date -- refreshed', array( 'path' => $target ) ); self::install(); } } protected static function maybe_log_self_heal( $severity, $message, array $context ) { $last = (int) get_option( self::SELF_HEAL_LOG_COOLDOWN_OPTION, 0 ); if ( time() - $last < self::SELF_HEAL_LOG_COOLDOWN_SECS ) { return; } update_option( self::SELF_HEAL_LOG_COOLDOWN_OPTION, time(), false ); Argus_Events::record( 'self_heal', $severity, $message, $context ); } public static function status() { return get_option( 'argus_wpd_mu_install_status', 'unknown' ); } const HEARTBEAT_OPTION = 'argus_wpd_mu_core_heartbeat'; const HEARTBEAT_INTERVAL_SECS = 300; const HEARTBEAT_STALE_AFTER_SECS = 900; public static function execution_status() { $last = (int) get_option( self::HEARTBEAT_OPTION, 0 ); if ( 0 === $last ) { return 'never'; } return ( time() - $last ) <= self::HEARTBEAT_STALE_AFTER_SECS ? 'healthy' : 'stale'; } public static function uninstall() { $target = self::target_path(); if ( file_exists( $target ) ) { wp_delete_file( $target ); } delete_option( 'argus_wpd_mu_install_status' ); } }