diff --git a/trunk/places/DZ.php b/trunk/places/DZ.php index 101871b..16bc8a8 100644 --- a/trunk/places/DZ.php +++ b/trunk/places/DZ.php @@ -7,8 +7,8 @@ * Source: * - https://en.wikipedia.org/wiki/Communes_of_Algeria * - * Updated: March 22, 2020 - * By Yordan Soares | https://yordansoar.es + * Updated: December 5, 2024 + * By RAHMANI AbdElFattah | @F7k-B0y * * @author Walid Yacine MAZED * @version 1.0.0 @@ -21,33 +21,22 @@ 'DZ-01' => array( _x('Adrar', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Tamest', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Charouine', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Reggane', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Inozghmir', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Tit', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Ksar Kaddour', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Tsabit', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Timimoun', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Ouled Said', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Zaouiet Kounta', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Aoulef', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Timokten', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Tamentit', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Fenoughil', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Tinerkouk', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Deldoul', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Sali', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Akabli', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Metarfa', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('O Ahmed Timmi', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Ouled Ahmed Timmi', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Bouda', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Aougrout', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Talmine', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('B Badji Mokhtar', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Sbaa', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Ouled Aissa', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Timiaouine', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), ), + 'DZ-02' => array( _x('Chlef', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Tenes', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), @@ -114,7 +103,7 @@ 'DZ-04' => array( _x('Oum El Bouaghi', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Ain Beida', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Ainmlila', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Ain M’lila', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Behir Chergui', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('El Amiria', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Sigus', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), @@ -264,12 +253,6 @@ _x('Oumache', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Branis', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Chetma', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Ouled Djellal', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Ras El Miaad', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Besbes', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Sidi Khaled', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Doucen', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Ech Chaiba', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Sidi Okba', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Mchouneche', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('El Haouch', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), @@ -297,24 +280,14 @@ 'DZ-08' => array( _x('Bechar', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Erg Ferradj', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Ouled Khoudir', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Meridja', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Timoudi', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Lahmar', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Beni Abbes', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Beni Ikhlef', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Mechraa Houari B', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Kenedsa', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Igli', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Tabalbala', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Taghit', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('El Ouata', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Boukais', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Mogheul', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Abadla', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Kerzaz', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Ksabi', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Tamtert', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Beni Ounif', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), ), 'DZ-09' => array( @@ -392,16 +365,11 @@ _x('Oued El Berdi', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), ), 'DZ-11' => array( - _x('Tamanghasset', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Abalessa', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('In Ghar', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('In Guezzam', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Idles', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Tazouk', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Tinzaouatine', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('In Salah', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('In Amguel', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Foggaret Ezzaouia', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Tamanghasset', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Idlès', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Tazrouk', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), ), 'DZ-12' => array( _x('Tebessa', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), @@ -1170,22 +1138,8 @@ _x('Ngoussa', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Hassi Messaoud', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Rouissat', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Balidat Ameur', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Tebesbest', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Nezla', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Zaouia El Abidia', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Sidi Slimane', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Sidi Khouiled', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Hassi Ben Abdellah', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Touggourt', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('El Hadjira', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Taibet', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Tamacine', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Benaceur', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Mnaguer', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Megarine', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('El Allia', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('El Borma', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), ), 'DZ-31' => array( _x('Oran', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), @@ -1241,10 +1195,8 @@ ), 'DZ-33' => array( _x('Illizi', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Djanet', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Debdeb', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Bordj Omar Driss', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Bordj El Haouasse', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('In Amenas', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), ), 'DZ-34' => array( @@ -1392,16 +1344,8 @@ _x('Magrane', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Beni Guecha', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Ourmas', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Still', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Mrara', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Sidi Khellil', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Tendla', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('El Ogla', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Mih Ouansa', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('El Mghair', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Djamaa', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Oum Touyour', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Sidi Amrane', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), ), 'DZ-40' => array( _x('Khenchela', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), @@ -1602,7 +1546,6 @@ ), 'DZ-47' => array( _x('Ghardaia', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('El Meniaa', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Dhayet Bendhahoua', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Berriane', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Metlili', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), @@ -1611,9 +1554,6 @@ _x('Zelfana', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Sebseb', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Bounoura', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Hassi Fehal', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Hassi Gara', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), - _x('Mansoura', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), ), 'DZ-48' => array( _x('Relizane', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), @@ -1654,6 +1594,89 @@ _x('El Ouldja', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Merdja Sidi Abed', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), _x('Ouled Sidi Mihoub', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + ), + + // 10 new added provinces communes + 'DZ-49' => array( + _x('Aougrout', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Deldoul', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Metarfa', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Charouine', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Ouled Aissa', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Talmine', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Ouled Said', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Timimoun', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Ksar Kaddour', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Tinerkouk', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + ), + 'DZ-50' => array( + _x('Bordj Badji Mokhtar', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Timiaouine', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + ), + 'DZ-51' => array( + _x('Ouled Djellal', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Ech Chaïba', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Doucen', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Sidi Khaled', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Besbes (Ouled Harkat)', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Ras El Miaad (Ouled Sassi)', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + ), + 'DZ-52' => array( + _x('Beni Abbes', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Beni Ikhlef', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('El Ouata', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Igli', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Kerzaz', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Ksabi', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Ouled Khoudir', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Tabalbala', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Tamtert', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Timoudi', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + ), + 'DZ-53' => array( + _x('In Ghar', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('In Salah', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Foggaret Ezzaouia', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + ), + 'DZ-54' => array( + _x('In Guezzam', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Tinzaouatine', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + ), + 'DZ-55' => array( + _x('Megarine', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Sidi Slimane', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Benaceur', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('M’Naguer', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Taibet', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Balidat Ameur', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Tamacine', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Nezla', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Tebesbest', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Touggourt', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Zaouia El Abidia', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('El Hadjira', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('El Allia', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('El Borma', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + ), + 'DZ-56' => array( + _x('Bordj El Haouas', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Djanet', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + ), + 'DZ-57' => array( + _x('El M’Ghair', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Oum Touyour', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Sidi Khellil', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Still', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Djamaa', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('M’Rara', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Sidi Amrane', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Tendla', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + ), + 'DZ-58' => array( + _x('Mansoura', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Hassi Fehal', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('El Meniaa', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), + _x('Hassi Gara', 'Algerian Communes', 'states-cities-and-places-for-woocommerce'), ) ); diff --git a/trunk/states-cities-and-places-for-woocommerce.php b/trunk/states-cities-and-places-for-woocommerce.php index 3011854..5558f13 100644 --- a/trunk/states-cities-and-places-for-woocommerce.php +++ b/trunk/states-cities-and-places-for-woocommerce.php @@ -4,7 +4,7 @@ * Plugin Name: States, Cities, and Places for WooCommerce * Plugin URI: https://github.com/chitezh/woocommerce_states_places * Description: WooCommerce plugin for listing states, cities, places, local government areas and towns in all countries of the world. - * Version: 1.3.2 + * Version: 1.4.0 * Author: Kingsley Ochu * Author URI: https://github.com/chitezh * Developer: Kingsley Ochu @@ -13,41 +13,47 @@ * Text Domain: states-cities-and-places-for-woocommerce * License: GPLv2 or later * License URI: http://www.gnu.org/licenses/gpl-2.0.html - * Requires at least: 4.0 - * Tested up to: 5.9 - * WC requires at least: 3.0.x - * WC tested up to: 6.2 + * Requires at least: 5.9 + * Tested up to: 6.4 + * WC requires at least: 8.0 + * WC tested up to: 9.4.3 + * Requires PHP: 7.4 */ /** * Die if accessed directly */ -defined( 'ABSPATH' ) or die( __('You can not access this file directly!', 'states-cities-and-places-for-woocommerce') ); +defined('ABSPATH') or die(__('You can not access this file directly!', 'states-cities-and-places-for-woocommerce')); /** * Check if WooCommerce is active */ -if ( (is_multisite() && array_key_exists('woocommerce/woocommerce.php', get_site_option('active_sitewide_plugins', array()))) || - in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins'))) ) { +if ((is_multisite() && array_key_exists('woocommerce/woocommerce.php', get_site_option('active_sitewide_plugins', array()))) || + in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins'))) +) { - class WC_States_Places { + class WC_States_Places + { - const VERSION = '1.3.2'; + const VERSION = '1.4.0'; private $states; private $places; /** * Construct class */ - public function __construct() { - add_action( 'plugins_loaded', array( $this, 'init') ); + public function __construct() + { + add_action('plugins_loaded', array($this, 'init')); } /** * WC init */ - public function init() { - add_action( 'before_woocommerce_init', array( $this, 'woocommerce_hpos_compatible' ) ); + public function init() + { + add_action('before_woocommerce_init', array($this, 'woocommerce_hpos_compatible')); + $this->init_textdomain(); $this->init_fields(); $this->init_states(); @@ -55,35 +61,41 @@ public function init() { } /** - * Load text domain for internationalitation + * Load text domain for internationalization */ - public function init_textdomain() { - load_plugin_textdomain('states-cities-and-places-for-woocommerce', FALSE, dirname(plugin_basename(__FILE__)) . '/languages' ); + public function init_textdomain() + { + load_plugin_textdomain('states-cities-and-places-for-woocommerce', FALSE, dirname(plugin_basename(__FILE__)) . '/languages'); } /** * WC Fields init */ - public function init_fields() { + public function init_fields() + { add_filter('woocommerce_default_address_fields', array($this, 'wc_change_state_and_city_order')); } /** * WC States init */ - public function init_states() { + public function init_states() + { add_filter('woocommerce_states', array($this, 'wc_states')); } /** * WC Places init */ - public function init_places() { - add_filter( 'woocommerce_billing_fields', array( $this, 'wc_billing_fields' ), 10, 2 ); - add_filter( 'woocommerce_shipping_fields', array( $this, 'wc_shipping_fields' ), 10, 2 ); - add_filter( 'woocommerce_form_field_city', array( $this, 'wc_form_field_city' ), 10, 4 ); + public function init_places() + { + add_filter('woocommerce_billing_fields', array($this, 'wc_billing_fields'), 10, 2); + add_filter('woocommerce_shipping_fields', array($this, 'wc_shipping_fields'), 10, 2); + + // Updated hook to use the more modern 'woocommerce_form_field' + add_filter('woocommerce_form_field', array($this, 'wc_form_field_city'), 10, 4); - add_action( 'wp_enqueue_scripts', array( $this, 'load_scripts' ) ); + add_action('wp_enqueue_scripts', array($this, 'load_scripts')); } /** @@ -91,7 +103,8 @@ public function init_places() { * @param mixed $fields * @return mixed */ - public function wc_change_state_and_city_order($fields) { + public function wc_change_state_and_city_order($fields) + { $fields['state']['priority'] = 70; $fields['city']['priority'] = 80; /* translators: Translate it to the name of the State level territory division, e.g. "State", "Province", "Department" */ @@ -102,22 +115,23 @@ public function wc_change_state_and_city_order($fields) { return $fields; } - /** * Implement WC States * @param mixed $states * @return mixed */ - public function wc_states() { - //get countries allowed by store owner + public function wc_states() + { + // Get countries allowed by store owner $allowed = $this->get_store_allowed_countries(); $states = array(); - if (!empty( $allowed ) ) { + if (!empty($allowed)) { foreach ($allowed as $code => $country) { - if (! isset( $states[$code] ) && file_exists($this->get_plugin_path() . '/states/' . $code . '.php')) { - include($this->get_plugin_path() . '/states/' . $code . '.php'); + $states_file = $this->get_plugin_path() . '/states/' . $code . '.php'; + if (!isset($states[$code]) && file_exists($states_file)) { + include($states_file); } } } @@ -131,9 +145,9 @@ public function wc_states() { * @param mixed $country * @return mixed */ - public function wc_billing_fields( $fields, $country ) { + public function wc_billing_fields($fields, $country) + { $fields['billing_city']['type'] = 'city'; - return $fields; } @@ -143,9 +157,9 @@ public function wc_billing_fields( $fields, $country ) { * @param mixed $country * @return mixed */ - public function wc_shipping_fields( $fields, $country ) { + public function wc_shipping_fields($fields, $country) + { $fields['shipping_city']['type'] = 'city'; - return $fields; } @@ -157,120 +171,101 @@ public function wc_shipping_fields( $fields, $country ) { * @param string $value * @return mixed */ - public function wc_form_field_city($field, $key, $args, $value ) { - // Do we need a clear div? - if ( ( ! empty( $args['clear'] ) ) ) { - $after = '
'; - } else { - $after = ''; - } - - // Required markup - if ( $args['required'] ) { - $args['class'][] = 'validate-required'; - $required = ' *'; - } else { - $required = ''; - } - - // Custom attribute handling - $custom_attributes = array(); - - if ( ! empty( $args['custom_attributes'] ) && is_array( $args['custom_attributes'] ) ) { - foreach ( $args['custom_attributes'] as $attribute => $attribute_value ) { - $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"'; - } - } - - // Validate classes - if ( ! empty( $args['validate'] ) ) { - foreach( $args['validate'] as $validate ) { - $args['class'][] = 'validate-' . $validate; - } - } - - // field p and label - $field = '

'; - if ( $args['label'] ) { - $field .= ''; + public function wc_form_field_city($field, $key, $args, $value) + { + // Check if this is a city field + if ($args['type'] !== 'city') { + return $field; } // Get Country $country_key = $key == 'billing_city' ? 'billing_country' : 'shipping_country'; - $current_cc = WC()->checkout->get_value( $country_key ); + $current_cc = WC()->checkout->get_value($country_key); $state_key = $key == 'billing_city' ? 'billing_state' : 'shipping_state'; - $current_sc = WC()->checkout->get_value( $state_key ); + $current_sc = WC()->checkout->get_value($state_key); // Get country places - $places = $this->get_places( $current_cc ); - - if ( is_array( $places ) ) { - - $field .= ''; + return $field; + } + /** + * Generate city options for dropdown + * @param array $places + * @param string $current_state + * @return array + */ + private function get_city_options($places, $current_state) + { + $options = ['' => __('Select an option…', 'woocommerce')]; + + if ($current_state && array_key_exists($current_state, $places)) { + $dropdown_places = $places[$current_state]; + } else if (is_array($places) && isset($places[0])) { + $dropdown_places = $places; + sort($dropdown_places); } else { - - $field .= ''; + $dropdown_places = $places; } - // field description and close wrapper - if ( $args['description'] ) { - $field .= '' . esc_attr( $args['description'] ) . ''; + foreach ($dropdown_places as $city_name) { + if (!is_array($city_name)) { + $options[$city_name] = $city_name; + } } - $field .= '

' . $after; - - return $field; + return $options; } + /** * Get places - * @param string $p_code(default:) + * @param string $p_code * @return mixed */ - public function get_places( $p_code = null ) { - if ( empty( $this->places ) ) { + public function get_places($p_code = null) + { + if (empty($this->places)) { $this->load_country_places(); } - if ( ! is_null( $p_code ) ) { - return isset( $this->places[ $p_code ] ) ? $this->places[ $p_code ] : false; + if (!is_null($p_code)) { + return isset($this->places[$p_code]) ? $this->places[$p_code] : false; } else { return $this->places; } } + /** * Get country places - * @return mixed + * @return void */ - public function load_country_places() { + public function load_country_places() + { global $places; - $allowed = $this->get_store_allowed_countries(); + $allowed = $this->get_store_allowed_countries(); - if ( $allowed ) { - foreach ( $allowed as $code => $country ) { - if ( ! isset( $places[ $code ] ) && file_exists( $this->get_plugin_path() . '/places/' . $code . '.php' ) ) { - include( $this->get_plugin_path() . '/places/' . $code . '.php' ); + if ($allowed) { + foreach ($allowed as $code => $country) { + $places_file = $this->get_plugin_path() . '/places/' . $code . '.php'; + if (!isset($places[$code]) && file_exists($places_file)) { + include($places_file); } } } @@ -281,52 +276,45 @@ public function load_country_places() { /** * Load scripts */ - public function load_scripts() { - if ( is_cart() || is_checkout() || is_wc_endpoint_url( 'edit-address' ) ) { - - $city_select_path = $this->get_plugin_url() . 'js/place-select.js'; - wp_enqueue_script( 'wc-city-select', $city_select_path, array( 'jquery', 'woocommerce' ), self::VERSION, true ); - - $places = json_encode( $this->get_places() ); - wp_localize_script( 'wc-city-select', 'wc_city_select_params', array( + public function load_scripts() + { + if (is_cart() || is_checkout() || is_wc_endpoint_url('edit-address')) { + $script_path = $this->get_plugin_url() . 'js/place-select.js'; + wp_enqueue_script('wc-city-select', $script_path, array('jquery', 'woocommerce'), self::VERSION, true); + + $places = json_encode($this->get_places()); + wp_localize_script('wc-city-select', 'wc_city_select_params', array( 'cities' => $places, - 'i18n_select_city_text' => esc_attr__( 'Select an option…', 'woocommerce' ) - ) ); + 'i18n_select_city_text' => esc_attr__('Select an option…', 'woocommerce') + )); } } /** * Get plugin root path - * @return mixed + * @return string */ - private function get_plugin_path() { - if (isset($this->plugin_path)) { - return $this->plugin_path; - } - $path = $this->plugin_path = plugin_dir_path( __FILE__ ); - - return untrailingslashit($path); + private function get_plugin_path() + { + return untrailingslashit(plugin_dir_path(__FILE__)); } /** * Get Store allowed countries - * @return mixed + * @return array */ - private function get_store_allowed_countries() { - return array_merge( WC()->countries->get_allowed_countries(), WC()->countries->get_shipping_countries() ); + private function get_store_allowed_countries() + { + return array_merge(WC()->countries->get_allowed_countries(), WC()->countries->get_shipping_countries()); } /** * Get plugin url - * @return mixed + * @return string */ - public function get_plugin_url() { - - if (isset($this->plugin_url)) { - return $this->plugin_url; - } - - return $this->plugin_url = plugin_dir_url( __FILE__ ); + public function get_plugin_url() + { + return plugin_dir_url(__FILE__); } /** @@ -334,14 +322,16 @@ public function get_plugin_url() { * * @return void */ - public function woocommerce_hpos_compatible() { - if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) { - \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); + public function woocommerce_hpos_compatible() + { + if (class_exists('\Automattic\WooCommerce\Utilities\FeaturesUtil')) { + \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true); } } } + /** * Instantiate class */ $GLOBALS['wc_states_places'] = new WC_States_Places(); -}; +} diff --git a/trunk/states/DZ.php b/trunk/states/DZ.php index 031eef9..b1af4ba 100644 --- a/trunk/states/DZ.php +++ b/trunk/states/DZ.php @@ -2,13 +2,13 @@ /** * Provinces of Algeria (Wilayas) - * - 48 provinces + * - 58 provinces * * Source: * - https://en.wikipedia.org/wiki/Provinces_of_Algeria * - * Updated: March 22, 2020 - * By Yordan Soares | https://yordansoar.es + * Updated: December 5, 2024 + * By RAHMANI AbdElFattah | @F7k-B0y * * @author Walid Yacine MAZED * @version 1.0.0 @@ -66,7 +66,19 @@ 'DZ-46' => _x('Aïn Témouchent', 'Algerian Provinces', 'states-cities-and-places-for-woocommerce'), 'DZ-47' => _x('Ghardaïa', 'Algerian Provinces', 'states-cities-and-places-for-woocommerce'), 'DZ-48' => _x('Relizane', 'Algerian Provinces', 'states-cities-and-places-for-woocommerce'), + + // 10 new added provinces + 'DZ-49' => _x('Timimoun', 'Algerian Provinces', 'states-cities-and-places-for-woocommerce'), + 'DZ-50' => _x('Bordj Badji Mokhtar', 'Algerian Provinces', 'states-cities-and-places-for-woocommerce'), + 'DZ-51' => _x('Ouled Djellal', 'Algerian Provinces', 'states-cities-and-places-for-woocommerce'), + 'DZ-52' => _x('Béni Abbès', 'Algerian Provinces', 'states-cities-and-places-for-woocommerce'), + 'DZ-53' => _x('In Salah', 'Algerian Provinces', 'states-cities-and-places-for-woocommerce'), + 'DZ-54' => _x('In Guezzam', 'Algerian Provinces', 'states-cities-and-places-for-woocommerce'), + 'DZ-55' => _x('Touggourt', 'Algerian Provinces', 'states-cities-and-places-for-woocommerce'), + 'DZ-56' => _x('Djanet', 'Algerian Provinces', 'states-cities-and-places-for-woocommerce'), + 'DZ-57' => _x('El M’Ghair', 'Algerian Provinces', 'states-cities-and-places-for-woocommerce'), + 'DZ-58' => _x('El Menia', 'Algerian Provinces', 'states-cities-and-places-for-woocommerce'), ); // Use this filter to handle the Provinces of Algeria -$states['DZ'] = apply_filters('scpwoo_custom_states_dz', $states['DZ']); \ No newline at end of file +$states['DZ'] = apply_filters('scpwoo_custom_states_dz', $states['DZ']);