Beee4life / acf-city-selector

An ACF extension to create a new field type, where you can select a city based on country and provence/state.
37 stars 15 forks source link

Raw import not working & some city files not available #106

Closed eduhud closed 1 year ago

eduhud commented 2 years ago

Hi,

I've been trying to import raw text pasted using "Import CSV data (from clipboard)" and when trying to import it drops me an error with the strpos function on line 607 in file /inc/acf-functions.php. I changed that line and now it works:

// Removed line as it receives array instead of file, we check if its array to import raw //if ( strpos( $file_name, '.csv', -4 ) !== false ) { if( !is_array($file_name) ){

Also, the cities for the countries Aruba, Curaçao, Grenada, Haiti are not available.

Regards.

Beee4life commented 2 years ago

If you input an array where a string is expected, then yeah an error is thrown...

I would have to check if any errors are given, when you import just raw... Can't tell for now.

Also, the cities for the countries Aruba, Curaçao, Grenada, Haiti are not available.

Thanks, will look into that. If they don't work, should be fixed by end of day.

eduhud commented 2 years ago

Yes, but it seems you use the same function for the file import and the raw import. When it tries to check if the file is csv (strpos) it throws an error as the content imported has not filename, its directly the raw content. I didn't investigated much more as I only needed to import the cities once and it worked, but I assumed it was that.

Also, found another bug (at least for me), when country_city method is selected and used acf_form() function for front-end display, the ajax function called is get_state_code instead of get_city_code, I changed the inArray 'all' from the first casuistic to the second one and now it loads correctly. I attach the modified city-selector.js so you can check. city-selector.js.zip

eduhud commented 2 years ago

I made a csv with all the countries and cities (more than 15k habitants), I will be happy to send it to you if you want to offer it for your clients. You can sell it or whatever you want, but its an easier way of selling this plugin. Write me to emc@midrocket.com and I'll send it to you.

Regards.

Beee4life commented 2 years ago

@eduhud the missing 4 files are available again

Beee4life commented 2 years ago

@eduhud I confirm the error you encountered and I fixed in this commit. Will be added to master this weekend.
Is now deployed to master.