• The list of countries is great.
    Could be interesting to add a list of nationalities (portuguese, spanish, english…)

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @pribeiro,

    You can already achieve it using with a code snippet like this:

    /**
     * Add a list of languages to Listo
     */
    // Filter to enqueu the language list
    if ( interface_exists( 'Listo' ) ) {
    	add_filter( 'listo_list_types', function( $list_types ) {
    		$list_types = array(
    			'languages' => 'Listo_Languages',
    		);
    		return $list_types;
    	}, 10, 1 );
    	// Class to handle the language list
    	class Listo_Languages implements Listo {
    		private function __construct() {}
    	
    		public static function items() {
    			return array(
    				'en' => _x( 'English', 'language', 'listo' ),
    				'es' => _x( 'Spanish', 'language', 'listo' ),
    				'it' => _x( 'Italian', 'language', 'listo' ),
    				'fr' => _x( 'French', 'language', 'listo' ),
    				'nl' => _x( 'Dutch', 'language', 'listo' ),
    				'de' => _x( 'German', 'language', 'listo' ),
    			);
    		}
    		public static function groups() {
    			return array();
    		}
    	}
    }

    Then, add a new field like this to your contact form to display your language list:

    <label> Your Language
        [select your-language data:languages] </label>

    Hope it helps!

    Thread Starter pribeiro

    (@pribeiro)

    Yes it helps, it’s an alternative, thank you.
    But… I still have to manually list all the nationalities in the world, right?
    (note: although it’s similar, I was talking about nationalities, not languages. but both could be a good addon)

    Plugin Contributor Yordan Soares

    (@yordansoares)

    But… I still have to manually list all the nationalities in the world, right?

    That’s right. This is a way to add your own lists, so you need to customize it manually as you like.

    Thread Starter pribeiro

    (@pribeiro)

    ok, thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘New dataset: Nationality’ is closed to new replies.