- // Very special case - require 2 letter country param to match the country code found
- if ($bStructuredPhrases && $aToken['country_code'] && !empty($this->aStructuredQuery['country'])
- && strlen($this->aStructuredQuery['country']) == 2 && strtolower($this->aStructuredQuery['country']) != $aToken['country_code']
+ // Filter country tokens that do not match restricted countries.
+ if ($this->aCountryCodes
+ && $aToken['country_code']
+ && !in_array($aToken['country_code'], $this->aCountryCodes)