WP Country

Provides the WP_Country PHP class to get countries list as an array and dropdown countries html list in other plugins and themes.

To use the WP Country plugin in your theme or plugin add global $wp_country; into your function code, then:

  • $wp_country->all_counties is an array of country names.
  • $wp_country->dropdown() prints or returns countries as dropdown HTML SELECT tag.
  • $wp_country->name($alpha2) returns  name of a country by it’s 2-character code.

Installation

1. Upload the wp-country folder to the /wp-content/plugins/ directory.

2. Activate the plugin.

Frequently Asked Questions

Parameters Description

Advanced usage: dropdown($blank, $echo, $args); where:

  • blank: if not empty then will be added into dropdown list. Default: '' (empty string).
  • echo: prints the list if true else returns. Default: true.
  • args: an array of extra parameters. Default: array('include' => array(), 'exclude' => array(), 'name' => 'country', 'id' => '', 'selected' => array(), 'multiple' => false).

Description of args components:

  • include, exclude: an array of country codes (alpha2) should be included into dropdown list or excluded from it.
  • name: name attribute of the SELECT tag.
  • id: id attribute of the SELECT tag (not displayed by default).
  • multiple: enables multiple select.
  • selected: adds the `selected` attribute.

Changelog

1.0 First release.

Download

Transation

Now I have Russian translation. If you translate it to any other language — please let me know to add it into the package.

1 комментарий на «WP Country»

  1. Can you please make the ability to delete country objects that are in the beginning of list? (Currently I have to delete ALL countries until I get to the one I want to delete, then I must re-enter them.

    for example:
    Algeria, Canada, Russia.

    If I want to delete ONLY Canada, I have to delete Russia, then Canada. Then I have to re-add Russia again.

Комментирование закрыто.