To retrieve $_GET parameters in a secure way, one can use get_query_var
get_query_var( string $query_var, mixed $default_value = '' ): mixed
The parameters would have first to be added to the public query variables available to WP_Query.
add_filter( 'query_vars', 'dev__pommes' );
function dev__pomme( $qvars ) {
$qvars[] = 'pommes';
return $qvars;
}
Source : https://developer.wordpress.org/reference/functions/get_query_var/