check `|| ($mode == 'livesearch' && !$config['allow_live_searches'])` here instead