Coder Social home page Coder Social logo

nlemoine / acf-country Goto Github PK

View Code? Open in Web Editor NEW
114.0 7.0 16.0 3.77 MB

ACF Country field - Display a select field of all countries, in any language.

PHP 99.96% JavaScript 0.04% CSS 0.01%
acf acf-country-field wordpress wordpress-plugin country advanced-custom-fields

acf-country's Introduction

Hi there 👋

acf-country's People

Contributors

dependabot-preview[bot] avatar github-actions[bot] avatar ninodevo avatar nlemoine avatar skatox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

acf-country's Issues

Output country name with flag icon

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

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.

View the update logs.

Readme.txt

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.

Country is effectively a required field.

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.

Usable in Conditional Logic

Any way to make the Country field type available for Conditional Logic? Currently, ACF doesn't consider it a toggle field.

Conflict with Admin Columns Pro

Details

  • WordPress version: [ 6.4.3 ]
  • ACF version: [ ACF Pro 6.2.7 ]
  • For UX/UI issues: [ macOS Sonoma 14.3.1, Safari 17.3.1 ]
  • Allow null: [ true ]
  • Multiple values: [ false ]
  • Stylised UI: [ true ]
  • Condtional logic: [ false ]
  • Admin Columns Pro version: [ 6.4.6 ]

Reproduction

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.

Bug summary

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'."

Expected result

Peaceful coexistence. Normal display of Admin Columns pro columns and a super useful country field in ACF.

Not working with ACF Pro 5.7.6

Details

  • WordPress version: 4.9.8
  • ACF version: Pro 5.7.6
  • For UX/UI issues: Chrome Versión 69.0.3497.100

Reproduction

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

Breaks "Toolset" Custom Post Types

Details

  • WordPress version: 6.3.1
  • ACF version: 6.2.1.1
  • For UX/UI issues: Mac, OS Sonoma, Safari Version 17.0 (19616.1.27.211.1)
  • Allow null: false
  • Multiple values: false
  • Stylised UI: false
  • Condtional logic: false

Reproduction

If you're filing a bug, please describe how to reproduce it. Include as much
relevant information as possible, such as:

Bug summary

Steps to reproduce

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!

Actual result

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
Bildschirmfoto 2023-10-05 um 13 12 34

Expected result

If I deactivate this county-plugin the CPTis listable and editable again.

Dependabot can't resolve your PHP dependency files

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.

View the update logs.

Country Flag and Name not diplayed, but [object object]

Details

  • WordPress version: 5.4.2
  • PHP version: 7.4.3
  • ACF version: 5.8.12 Pro
  • For UX/UI issues: Windows 10, Chrome 83.0.4103.97 (Offizieller Build) (64-Bit)
  • Allow null: true
  • Multiple values: false
  • Stylised UI: true (if this means select2?)
  • Condtional logic: false
  • Rules: none

Reproduction

If you're filing a bug, please describe how to reproduce it. Include as much
relevant information as possible, such as:

Bug summary

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.

Steps to reproduce

Please see summary.

First ideas

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.

rename v3 main plugin file

Details

  • WordPress version: v6.4.3
  • ACF version: v6.2.2 Pro

Reproduction

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:

image

Renaming the main plugin file from plugin.php to acf-country.php should fix this and make a more seamless version update possible.

How to show the country value was choose to front-end

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.

Country code received instead of country name as selected

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:
Screenshot 2019-04-16 at 10 43 15

When I select Country name as the return format I can see that working on the backend:
Screenshot 2019-04-16 at 10 43 46

However it doesn't seem to work on the frontend:
Screenshot 2019-04-16 at 10 44 27

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:
Screenshot 2019-04-16 at 10 48 25

  • WordPress version: 5.1.1
  • ACF Pro version: 5.7.12
  • ACF Country version: 2.0.0
  • FacetWP version: 3.3.5

Make get_countries() public

Details

  • WordPress version: 5.5
  • ACF version: 5.9

Bug summary

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

Steps to reproduce

// create our custom select
$countries = acf_country_helpers::get_countries();

Custom Order required

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

Countries displaying as '[object Object]' after being selected

Details

  • WordPress version: 5.4.2
  • ACF version: 5.8.12 (Pro)
  • For UX/UI issues: Mac, Chrome 83.0.4103.97
  • Multiple: False

Reproduction

If you're filing a bug, please describe how to reproduce it. Include as much
relevant information as possible, such as:

Bug summary

In the CMS, the selection shows '[object Object]' rather than the selected country. It looks fine in the dropdown menu when opened.

Steps to reproduce

Actual result

[object Object]

Expected result

The select field would display the current selection
Screen Shot 2020-06-11 at 14 24 55
Screen Shot 2020-06-11 at 14 24 25

In admin select field selected choice displays as html

Details

  • WordPress version: 5.7.2
  • ACF version: Pro 5.9.8
  • For UX/UI issues: MacOS, Safari v 14.1.1 and Chrome v 91.0.4472.114 (Official Build) (x86_64)
  • Allow null: true
  • Multiple values: false
  • Stylised UI: true
  • Condtional logic: false

Reproduction

Bug summary

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>

Steps to reproduce

Regular WP install on local and production sites.

Actual result

See screen grab:
CleanShot 2021-07-16 at 18 19 23@2x

Expected result

In the admin the select field should display the flag icon and country name -- as it does for the dropdown list .

Return flag

Hello )
How returnt flag image in plugin ?)

Flags not loading

Hi there,

The plugin works great but the flags are not loading - do they need to be switched on?

All dependent files are present and have loaded properly.

Thanks

country_markup

Country select interface doesn't work, throws JS error

Details

  • WordPress version: 5.5.1
  • ACF version: 5.9.2
  • For UX/UI issues: Windows 10, Chrome 86.0.4240.111 (latest at the time of writing)
  • Allow null: false
  • Multiple values: false
  • Stylised UI: true
  • Condtional logic: false

Reproduction

Bug summary

Country select interface displays [object Object] instead of label; country search returns JS error.

image

Steps to reproduce

  1. Create country field with default settings, attach to regular Post
  2. Check the field in "Create post" admin page

Additional information

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.

Spanish regions that are not countries

Details

  • WordPress version: [ 4.9.8 ]
  • ACF Pro version: [ 5.7.7 ]

Bug summary

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.

Steps to reproduce

In every single select and every single language ;D

Should not default to local country

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.

Problem with php5-intl

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).

Multiple countries selected shows no countries, affects any new post thereafter

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.

Data was clean after saving

Details

  • WordPress version: 5.4.10
  • ACF version: 5.8.3
  • For UX/UI issues: [ OS, browser name and version ]
  • Allow null: true
  • Multiple values: true
  • Stylised UI: false
  • Condtional logic: false
  • Rules: []

Reproduction

If you're filing a bug, please describe how to reproduce it. Include as much
relevant information as possible, such as:

Bug summary

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.

Steps to reproduce

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

Actual result

Data on the post disappeared.

Expected result

Data remain.

Option for other languages

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?

Flags not shown after updating til ACF Pro

Details

  • WordPress version: 5.8
  • ACF version: Pro 5.10.1
  • For UX/UI issues: [ OS, browser name and version ]
  • Allow null: [ true | false ]
  • Multiple values: [ true | false ]
  • Stylised UI: [ true | false ]
  • Condtional logic: [ true | false ]
  • Rules: []

Reproduction

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
Skærmbillede 2021-09-01 kl  10 05 27

If you're filing a bug, please describe how to reproduce it. Include as much
relevant information as possible, such as:

Bug summary

Steps to reproduce

Actual result

Expected result

Provide corresponding Gutenberg block

Details

  • WordPress version: 5.3
  • ACF version: 5.8.7

Feature request

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 if choose country and then remove it for update

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.

Country name does not display on front end

Details

  • WordPress version: [ 6.4.2 ]
  • ACF version: [ 6.2.4 ]
  • For UX/UI issues: [ Ubuntu 22.04, Firefox 120.0 (64-bit) Snap for Ubuntu]
  • Allow null: [ true ]
  • Multiple values: [ false ]
  • Stylised UI: [ false ]
  • Condtional logic: [ false ]
  • Rules: []

Reproduction

If you're filing a bug, please describe how to reproduce it. Include as much
relevant information as possible, such as:

Bug summary

Steps to reproduce

Actual result

Expected result

If i order the query i lost country name

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>';

}

Add new country key and value

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

Default country option

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.

Countries not being returned as value label array

Details

  • WordPress version: 5.4.2
  • ACF version: 5.8.12 (Pro)
  • For UX/UI issues: Mac, Chrome 83.0.4103.97
  • Multiple: False

Reproduction

If you're filing a bug, please describe how to reproduce it. Include as much
relevant information as possible, such as:

Bug summary

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.

Steps to reproduce

  • Add new country field
  • Choose 'Country code and name' as the return format
  • Choose country on post
  • Query post meta and check results

Actual result

Received country code

Expected result

Receive country code and name in array

Not compatible with Admin Columns Pro

Details

  • WordPress version: 6.1.1
  • ACF version: 6.0.6
  • ACF Country version: 2.0.2
  • Admin Columns Pro version: 6.0.3
  • Allow null: true
  • Multiple values: false
  • Stylised UI: true

Bug summary

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.