Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output country name with flag icon #14

Closed
Nick-Fiasco opened this issue Mar 14, 2018 · 5 comments
Closed

Output country name with flag icon #14

Nick-Fiasco opened this issue Mar 14, 2018 · 5 comments

Comments

@Nick-Fiasco
Copy link

Hi @nlemoine

Discovered your plugin add-on through ACF, love the idea and just what I need for project.
Delving into the plugin and using it within the dashboard you include a sprite with flags for the select when choosing a country.

I was wondering if there would/could be an option to display that same flag icon with the country name on the front-end? Rather than having to replicate the same kind of code you may already have going within the plugin elsewhere for the front-end.

Could this be done with your plugin add-on?

Many Thanks!

@nlemoine
Copy link
Owner

Hi @Nick-Fiasco,

Sorry, I can't consider your feature request for many reasons.

  • Some users might not be interested in having those flags. Maybe they'll use their own flag icon set. But the plugin will still load an extra stylesheet and image.
  • It's really easy to add them to your theme stylesheet using any package manager: https://github.com/legacy-icons/famfamfam-flags/tree/master/dist/sprite
  • Moreover, I don't like backend plugins messing with the front-end. I'm mostly a front-end developer and I like to keep things separated. There's enough plugins including scripts and styles out there ;)

@Nick-Fiasco
Copy link
Author

Okay no problem I can look into that.

Would you be able to point me in the direction of how to get the split values from the field?
I'm using the default country code and country name, but struggling to actually output the different values from the array.

So, the country name and the country code as separate values (in order to use the value to control classes for the flags).

I'm sure I'm just being a bit stupid, but what I've tried to far doesn't yield both the country code and name, only the name.

Any ideas?

Thanks

@nlemoine
Copy link
Owner

nlemoine commented Mar 21, 2018

I assume you get your field value with something like:

$country = get_field('my_country_field');

Then you can get values with:

$country_name = reset($country);
$country_code = key($country);

@Nick-Fiasco
Copy link
Author

Excellent, that is exactly what I needed!

Thank you very much.

@bramroos
Copy link

bramroos commented Dec 1, 2019

Hi, I'm stuck with the same. I've looked at your suggestion but have no idea how to get that to work. Do you have a working example?
Many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants