PHP code example of arraypress / wp-countries
1. Go to this page and download the library: Download arraypress/wp-countries library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
arraypress / wp-countries example snippets
use ArrayPress\Countries\Countries;
// A country dropdown.
foreach ( Countries::all() as $code => $name ) {
printf( '<option value="%s">%s</option>', esc_attr( $code ), esc_html( $name ) );
}
// Turn a stored code back into something readable.
echo esc_html( Countries::get_name( $order->billing_country ) ); // United Kingdom
// VAT applies?
if ( Countries::is_eu( $order->billing_country ) ) {
// ...
}
// Never trust a posted code.
$code = Countries::sanitize( $_POST['country'] ?? '' );