This commit is contained in:
Javier Casares 2026-03-28 10:06:01 +00:00
commit 231ef59bb9
15 changed files with 254 additions and 135 deletions

View file

@ -120,11 +120,11 @@ class Two_Factor_Extended_Audit_Log {
return;
}
$providers = Two_Factor_Extended_Provider_Detector::get_user_enabled_providers( $user_id );
$providers = Two_Factor_Extended_Provider_Detector::get_user_enabled_providers( $user_id );
$provider_names = array();
foreach ( array_keys( $providers ) as $class ) {
$names = Two_Factor_Extended_Provider_Detector::get_provider_names();
$names = Two_Factor_Extended_Provider_Detector::get_provider_names();
$provider_names[] = $names[ $class ] ?? $class;
}
@ -301,7 +301,7 @@ class Two_Factor_Extended_Audit_Log {
* @since 0.1.0
*/
public function cleanup_old_logs(): void {
$logs = $this->get_logs();
$logs = $this->get_logs();
$cutoff_time = current_time( 'timestamp' ) - ( self::RETENTION_DAYS * DAY_IN_SECONDS );
$filtered_logs = array_filter(
@ -328,7 +328,7 @@ class Two_Factor_Extended_Audit_Log {
public function export_to_csv( array $filters = array() ): string {
$logs = $this->get_logs( $filters );
$csv = array();
$csv = array();
$csv[] = array( 'Timestamp', 'Action', 'Description', 'User', 'Actor', 'IP Address' );
foreach ( $logs as $log ) {
@ -424,8 +424,8 @@ class Two_Factor_Extended_Audit_Log {
$logs = $this->get_logs();
$stats = array(
'total' => count( $logs ),
'by_action' => array(),
'total' => count( $logs ),
'by_action' => array(),
'recent_count' => 0,
);
@ -439,11 +439,11 @@ class Two_Factor_Extended_Audit_Log {
if ( ! isset( $stats['by_action'][ $action ] ) ) {
$stats['by_action'][ $action ] = 0;
}
$stats['by_action'][ $action ]++;
++$stats['by_action'][ $action ];
// Count recent logs (last 7 days).
if ( $ts >= $recent_cutoff ) {
$stats['recent_count']++;
++$stats['recent_count'];
}
}