/** * a country's constructor * * @access public * * @since 3.8.14 * * @param int|string|array required $country_identifier the country identifier, can be the string ISO code, * or the integer country id, or an array of data used * to create a new country * * @return object WPSC_Country */ public function __construct($country, $deprecated = null) { if ($country) { if (is_array($country)) { // if we get an array as an argument we are making a new country $country_id_or_isocode = WPSC_Countries::_save_country_data($country); } else { // we are constructing a country using a numeric id or ISO code $country_id_or_isocode = $country; } // make sure we have a valid country id $country_id = WPSC_Countries::get_country_id($country_id_or_isocode); if ($country_id) { $wpsc_country = WPSC_Countries::get_country($country_id); foreach ($wpsc_country as $property => $value) { // copy the properties in this copy of the country $this->{$property} = $value; } } } // if the regions maps has not been initialized we should create an empty map now if (empty($this->_regions)) { $this->_regions = new WPSC_Data_Map(); } if (empty($this->_region_id_by_region_code)) { $this->_region_id_by_region_code = new WPSC_Data_Map(); } if (empty($this->_region_id_by_region_name)) { $this->_region_id_by_region_name = new WPSC_Data_Map(); } ///////////////////////////////////////////////////////////////////////////////////////////////////////// // As a result of merging the legacy WPSC_Country class we no longer need the "col" constructor parameter // that was in the prior version of this class. // // if deprecated processing is enabled we will give a message, just as if we were allowed to put class // methods in the deprecated file, if deprecated processing is not enabled we exit with the method, much // like would happen with an undefined function call. // // TODO: This processing is added at version 3.8.14 and intended to be removed after a reasonable number // of interim releases. See GitHub Issue https://github.com/wp-e-commerce/WP-e-Commerce/issues/1016 ///////////////////////////////////////////////////////////////////////////////////////////////////////// if (!empty($deprecated)) { if (defined('WPSC_LOAD_DEPRECATED') && WPSC_LOAD_DEPRECATED) { _wpsc_deprecated_argument(__FUNCTION__, '3.8.14', $this->_parameter_no_longer_used_message('col', __FUNCTION__)); } } // setup default properties filter add_filter('wpsc_country_get_property', array(__CLASS__, '_wpsc_country_default_properties'), 10, 2); }