nlemoine / acf-country Goto Github PK
View Code? Open in Web Editor NEWACF Country field - Display a select field of all countries, in any language.
ACF Country field - Display a select field of all countries, in any language.
I'm using this plugin with ACF Pro 5.6.9, but the flags are not loaded.
When I dive, this probably is because a change in Select2, see https://select2.org/upgrading/migrating-from-35#renamed-templating-options.
However, just renaming these options (from formatResult
to templateResult`` for instance) won't work. I get unparsed HTML (http://upload.uprise.nl/Jy8h67) and other JS errors (non-existing methods in $.fn.select2.defaults
).
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!
Dependabot can't resolve your PHP dependency files.
As a result, Dependabot couldn't update your dependencies.
The error Dependabot encountered was:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires dealerdirect/phpcodesniffer-composer-installer ^0.6.2 -> satisfiable by dealerdirect/phpcodesniffer-composer-installer[v0.6.2].
- dealerdirect/phpcodesniffer-composer-installer v0.6.2 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.0.0] but it does not match the constraint.
You are using Composer 2, which some of your plugins seem to be incompatible with. Make sure you update your plugins or report a plugin-issue to ask them to support Composer 2.
If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.
.
Hi,
I don't think you need readme.txt anymore? Readme.MD tells the user to read readme.txt however it's out of date and the code snippet for activating the plugin doesn't work.
There seems to be no way to have county
be not required. Even setting the required
field to 0 and the default_value
field to an empty string will have ACF Country use the first country (Afganistan in English) as the default.
Any way to make the Country field type available for Conditional Logic? Currently, ACF doesn't consider it a toggle field.
Add any new Admin Columns Pro column to an All posts or CPTs list page with ACF Country v3.0.0 activated and you will see a fatal error message in that column.
No JS error.
Fatal error: Uncaught TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, cannot access protected method class@anonymous::admin_column() in /Users/davidbrabyn/Local Sites/roland-cycling-team/app/public/wp-includes/class-wp-hook.php:324 Stack trace: #0 /Users/davidbrabyn/Local Sites/roland-cycling-team/app/public/wp-includes/plugin.php(205): WP_Hook->apply_filters('\n\t\t<span class=...', Array) #1 /Users/davidbrabyn/Local Sites/roland-cycling-team/app/public/wp-content/plugins/admin-columns-pro/admin-columns/classes/Table/ManageValue.php(50): apply_filters('ac/column/value', '\n\t\t<span class=...', 671, Object(ACP\Column\Post\FeaturedImage)) #2 /Users/davidbrabyn/Local Sites/roland-cycling-team/app/public/wp-content/plugins/admin-columns-pro/admin-columns/classes/Table/ManageValue/Post.php(39): AC\Table\ManageValue->render_cell('64d114cfe872b0', 671) #3 /Users/davidbrabyn/Local Sites/roland-cycling-team/app/public/wp-includes/class-wp-hook.php(324): AC\Table\ManageValue\Post->render_value('64d114cfe872b0', 671) #4 /Users/davidbrabyn/Local Sites/roland-cycling-team/app/public/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array) #5 /Users/davidbrabyn/Local Sites/roland-cycling-team/app/public/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #6 /Users/davidbrabyn/Local Sites/roland-cycling-team/app/public/wp-admin/includes/class-wp-posts-list-table.php(1398): do_action('manage_rider_po...', '64d114cfe872b0', 671) #7 /Users/davidbrabyn/Local Sites/roland-cycling-team/app/public/wp-admin/includes/class-wp-list-table.php(1799): WP_Posts_List_Table->column_default(Object(WP_Post), '64d114cfe872b0') #8 /Users/davidbrabyn/Local Sites/roland-cycling-team/app/public/wp-admin/includes/class-wp-posts-list-table.php(1432): WP_List_Table->single_row_columns(Object(WP_Post)) #9 /Users/davidbrabyn/Local Sites/roland-cycling-team/app/public/wp-admin/includes/class-wp-posts-list-table.php(834): WP_Posts_List_Table->single_row(Object(WP_Post), 0) #10 /Users/davidbrabyn/Local Sites/roland-cycling-team/app/public/wp-admin/includes/class-wp-posts-list-table.php(810): WP_Posts_List_Table->_display_rows(Array, 0) #11 /Users/davidbrabyn/Local Sites/roland-cycling-team/app/public/wp-admin/includes/class-wp-list-table.php(1709): WP_Posts_List_Table->display_rows() #12 /Users/davidbrabyn/Local Sites/roland-cycling-team/app/public/wp-admin/includes/class-wp-list-table.php(1636): WP_List_Table->display_rows_or_placeholder() #13 /Users/davidbrabyn/Local Sites/roland-cycling-team/app/public/wp-admin/edit.php(503): WP_List_Table->display() #14 {main} thrown in /Users/davidbrabyn/Local Sites/roland-cycling-team/app/public/wp-includes/class-wp-hook.php on line 324
Given this info, support at ACP tell me: "The following hook throws an error and that should only occur if the hook in our plugin is used incorrectly: 'ac/column/value'."
Peaceful coexistence. Normal display of Admin Columns pro columns and a super useful country field in ACF.
Not working. Showing this error on console
acf-country.js?ver=1.1.0:56 Uncaught TypeError: Cannot read property 'extend' of undefined
at acf-country.js?ver=1.1.0:56
at acf-country.js?ver=1.1.0:127
If you're filing a bug, please describe how to reproduce it. Include as much
relevant information as possible, such as:
Hi,
I just installed the latest acf-country repository and observed that existent custom post types defined by Toolset do brake! CPTs created by Toolset cannot get edited anymore!
Instead of a list of post of the CPT just an error pops up on the admin list page of that CPT saying:
There was a critical error on your website. Please check the inbox of your website administrator email address for further instructions.
Screen of the broken CPT called "CB Firmen", created by Toolset
If I deactivate this county-plugin the CPTis listable and editable again.
Dependabot can't resolve your PHP dependency files.
As a result, Dependabot couldn't update your dependencies.
The error Dependabot encountered was:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires dealerdirect/phpcodesniffer-composer-installer ^0.6.2 -> satisfiable by dealerdirect/phpcodesniffer-composer-installer[v0.6.2].
- dealerdirect/phpcodesniffer-composer-installer v0.6.2 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.0.0] but it does not match the constraint.
You are using Composer 2, which some of your plugins seem to be incompatible with. Make sure you update your plugins or report a plugin-issue to ask them to support Composer 2.
If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.
If you're filing a bug, please describe how to reproduce it. Include as much
relevant information as possible, such as:
Drop down selection is working as expected, so does saving the selected country. But the flags and the country names only show up in the dropdown, the field itself after selection only outputs as [obejct object]. This happens in the backend and in the frontend.
Please see summary.
Disabeling select2 in the field setting seems to fix the problem in a way that at leat the name of the country is displayed correctly.
So seems to be related to select2, In Use: select2.full.min.js, 4.0.10.
https://beerpay.io/nlemoine/acf-country is broken (I think)
Testing v3 branch I've updated the plugin through composer from v2.1.0 to v3.x-dev.
Because the main plugin file is renamed I get the following error in the WordPress plugins overview:
Renaming the main plugin file from plugin.php
to acf-country.php
should fix this and make a more seamless version update possible.
I want to show value of country was chosen from back-end to front-end
i was using this code
get_field(‘country_selling’); // country_selling are field name when setup
but it show value NULL
can you guide me how to show value of country was chosen.
When I create a custom object with ACF and I add to it a country field using this plugin I can select the Return Format:
When I select Country name as the return format I can see that working on the backend:
However it doesn't seem to work on the frontend:
I use FacetWP to search through my custom objects, and when I specify the Data source as the object that contains the country value, it returns the Country code instead of the Country name as specified:
I used to relied on acf_country_helpers::get_countries()
as a very handy helper when it come to create custom select for the frontend.
But it seems you made it private now. I don't see strong reason for that.
Would you please mind reconsidering that choice and providing a tagged fixed release
// create our custom select
$countries = acf_country_helpers::get_countries();
Is it possible to implement option to preserve order of select2, not to put them into abc order.
This can preserve order:
function preserveOrderOnSelect2Choice(e){
var id = e.params.data.id;
var option = $(e.target).children('[value='+id+']');
option.detach();
$(e.target).append(option).change();
}
$acf_country.each(function(){
$(this).on('select2:select',preserveOrderOnSelect2Choice);
});
if done at the end of function init_field( $el ) {
, assets/acf-country.js:27
.
Then it works, need only to add option to turn this on.
Okay I'm forking
If you're filing a bug, please describe how to reproduce it. Include as much
relevant information as possible, such as:
In the CMS, the selection shows '[object Object]' rather than the selected country. It looks fine in the dropdown menu when opened.
[object Object]
In the admin the dropdown list displays the flag icons and country names correctly but the select field shows the following html for the flag icon and country name (in this case South Africa).
<span class="acf-country-flag-icon famfamfam-flags za"></span> <span class="acf-country-flag-name">Afrique du Sud</span>
Regular WP install on local and production sites.
In the admin the select field should display the flag icon and country name -- as it does for the dropdown list .
Hello )
How returnt flag image in plugin ?)
Country select interface displays [object Object] instead of label; country search returns JS error.
The JS request for querying countries is made to the following URL: /wp/wp-admin/post.php?post=785&action=edit&term=[SEARCH_TERM]&_type=query&q=[SEARCH_TERM] - however, this returns the html of the full post edit page.
Using Bedrock, so WP is located in /wp/ folder.
Tested with Twenty Twenty theme.
Thanks for this awesome plugin, btw.
First of all thank you for this great plugin, you've done an incredible work here.
The problem I've found is not yours but umpirsky country list. The problem is that in es_ES (and possibly in all languages) there are some countries that are not countries but Spanish regions, so they are listed in all selects.
The "countries" that are not countries are (at least the Spanish ones that I've found):
'IC' => 'Canarias',
'EA' => 'Ceuta y Melilla',
Seems like it should be easier for us to put a filter in the get_countries function in acf-country/fields/acf-country-helpers.php, in order to be able to remove countries from that list, than making a pull request to umpirsky country-list repo removing those wrong countries and wait for you to update the country files...
Would you mind if I make a PR to your repo creating that filter? I don't know if you want to put an specific name to that filter and that's why I didn't do that PR yet.
In every single select and every single language ;D
version number is still on 3.0.0 in acf-country.php
It's with this plugin https://github.com/wp-graphql/wp-graphql-acf. Can you maybe add support?
If a null value is allowed, why does the add-on default to pre-filling the local country?
I think you're assuming all use cases are for users to fill in a form to indicate their own country, but I imagine other use cases.
I think defaulting to a country should be an option, or not used.
Thanks.
Hello!
Great extension, the only problem is that sometime I go with some server with no php5-intl... Is there a way to use your extension without php5-intl installed? You probably speak french? On peut continuer en Français (I'm from Québec).
Can you create support for other languages?
As the title states, are you planning to add this plugin to the WordPress Plugin Directory? I'd be awesome.
Thanks
You need to update the project with the locale files.
https://github.com/symfony/Locale
Hi there, love this little plugin, thank you!
I've noticed that if I select multiple countries (so the field is set as multiple choice), my template will not show any country at all. Also, going forward, creating new posts with a country set in the country field will not show the country in the template for that newer post, even though only one country is selected.
What I've had to do now is remove the multiple choice option, and then had to go back to the newer posts, and reselect the country (as none was set - the default selection was Afghanistan).
I can link if required.
Install plugin and try to edit a taxonomy in acf, the error occurs and the taxonomy isnt editable until deactivation of acf country
If you're filing a bug, please describe how to reproduce it. Include as much
relevant information as possible, such as:
I add country field for an old group and go to the post to update data. After click update post, data disappears. I query postmeta table and find that data was clean for that post.
1 - Go to an available custom field
2 - Add country field and save
3 - Go to the associated post and add countries for existing row and click update post
Data on the post disappeared.
Data remain.
I use it on my website, however, I have to change all country names to Brazilian Portuguese. Is there a way to put the language option in order to be able to write the name of each country in the native language that is used?
Hello!
What is the data source you use to keep the country list fresh?
Thank you.
When a country field is shown, normally the user can see a flag and the country name.
Now a span html tag is shown - not the flag
If you're filing a bug, please describe how to reproduce it. Include as much
relevant information as possible, such as:
When using the Gutenberg editor, I'd like to find and use a <select>
configured to render my acf-country field.
That'd be a useful addition when building forms requesting a country selection.
the empty option not working for me after you fixed.
please check with screenshot and i will you login website detail for you checking.
login:
http://122.201.118.65/~pickadevelop/wp-admin/
username: admin
password: admin
check image link
https://www.awesomescreenshot.com/image/3115175/51ec6fa8dad0f5043b5b4894202dc3cd
check product link with country file called country_selling
http://122.201.118.65/~pickadevelop/wp-admin/post.php?post=96696&action=edit
hope you will help me solve soon.
If you're filing a bug, please describe how to reproduce it. Include as much
relevant information as possible, such as:
Hello,
i want order my CPT (dealers) query with this countrys. The order is working but i get back the country code, not the country label.
If i dont use this order its show the label.
What i should do to show the label in my template?
i use this function:
function custom_dealers_order($query) {
if (is_post_type_archive('dealers') ) {
$query->set('meta_key', 'country');
$query->set('orderby', 'meta_value');
$query->set('order', 'ASC');
$query->set('posts_per_page', -1);
}
}
add_action('pre_get_posts', 'custom_dealers_order');
this is how i shot it in my template file:
if (is_post_type_archive('dealers')) {
$dealer_country = get_field('country');
echo '<p><b>Country: </b>' . esc_html($dealer_country) . '</p>';
}
Hello and I am really sorry for creating an issue but I am not so sure how else I can get in touch with you!
I want to add a new country field; I've read in the README
file that I can do that by using this function:
You can remove (or add) some countries with the acf/country/countries filter, example:
add_filter( 'acf/country/countries', function( $countries ) {
return array_filter( $countries, function( $code ) {
return !in_array( $code, ['IC', 'EA'], true );
}, ARRAY_FILTER_USE_KEY);
} );
However, I am only able to remove a country by its code but I am not so sure how to add a new country name and code?
I've tried merging or adding a new pair of key & value into the array of countries but it did not work.
If you could please let me know? And I am sorry for any inconvenience.
Thanks,
Marina
Hello,
Do we have selecting a default country option? I see the code for default option in plugin but it doesn't seems to be working.
Please help.
Not work with ACF version 5.3.9.2
If you're filing a bug, please describe how to reproduce it. Include as much
relevant information as possible, such as:
Only country codes are being returned. I selected 'Country code and name' as the return format, but I received a country code string. I tested 'Country name' as well, but stll was left with the country code after updating posts.
Received country code
Receive country code and name in array
Admin Columns Pro does not recognize this field type despite recognizing regular ACF select fields. This mean no bulk editing or correct display of this field in the All Posts/CPTs list page.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.