Giter Site home page Giter Site logo

acf-country's Introduction

ACF Country field

Latest Version Packagist Beerpay Donate

Adds a 'Country' field type for the Advanced Custom Fields WordPress plugin.

⚠️ WARNING ⚠️

From version 2.0.0, ACF Country introduced some important breaking changes:

  • Dropped support for older PHP & ACF versions, new requirements are:
    • ACF 5.7+
    • PHP 5.4+
  • Return format has changed. To better stick to ACF and make use of ACF functions, ACF Country will now return values the same way select field do. ['FR' => 'France'] will now look like ['label' => 'France', 'value' => 'FR']

Looking for a ACF pre 5.7 support? Check the 1.0 branch.

Overview

Display a select list of all countries in your language.

Country names are available in every language (see available list). By default, country names are localized in your current WordPress language.

Select a single value:

ACF Country field

Or multiple ones:

ACF Country field

Compatibility

  • ACF 5.7+
  • PHP 5.4+

Field options

Option Default Description
Default value emtpy Set a default value for the country field (as country code)
Allow null false Enable/disable null value
Allow multiple false Enable/disable multiple countries selection
Stylised UI true Enable/disable enhanced select field thanks to Select2
Return format value  See ACF Select field

Filters

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);
} );

Note: PHP5.6+ example

Installation

Zip

Download the plugin and extract the archive to your plugins folder.

Composer

composer require hellonico/acf-country

Contributing

See CONTRIBUTING.

Support

This ACF field was originally developed for a personal project I don't use anymore. I still decided to maintain it anyway. If you use it in a commercial project, please consider buying me a beer.

acf-country's People

Contributors

dependabot-preview[bot] avatar drzraf avatar ninodevo avatar nlemoine avatar skatox avatar

Watchers

 avatar

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.