insert( $wpdb->prefix . 'agyl_audit_log', array( 'actor_id' => get_current_user_id() ?: null, 'actor_type' => is_user_logged_in() ? 'user' : 'system', 'action' => substr( $action, 0, 64 ), 'target' => null === $target ? null : substr( $target, 0, 190 ), 'args_hash' => $args ? hash( 'sha256', (string) wp_json_encode( $args ) ) : null, 'result' => substr( $result, 0, 20 ), 'detail' => '' === $detail ? null : substr( $detail, 0, 5000 ), 'ip_hash' => '' !== $ip ? SessionManager::hash_ip( $ip ) : null, 'created_at' => gmdate( 'Y-m-d H:i:s' ), ) ); } }