Changeset 2924195
- Timestamp:
- 06/10/2023 10:23:26 AM (3 years ago)
- Location:
- country-code-selector/trunk
- Files:
-
- 3 edited
-
README.txt (modified) (2 diffs)
-
country-code-selector.php (modified) (2 diffs)
-
public/class-country-code-selector-public.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
country-code-selector/trunk/README.txt
r2874090 r2924195 3 3 Donate link: http://www.intolap.com/ 4 4 Tags: woocommerce checkout, shopp checkout, gravity form, contact form 7, phone number validator, phone field validator, country code selector 5 Requires at least: 5.96 Tested up to: 6. 07 WC requires at least: 6.88 WC tested up to: 6.89 Requires PHP: 7. 25 Requires at least: 6.1 6 Tested up to: 6.2 7 WC requires at least: 7.0 8 WC tested up to: 7.7 9 Requires PHP: 7.4 10 10 Stable tag: trunk 11 11 License: GPLv2 or later … … 83 83 == Changelog == 84 84 85 = 1.7 = 86 * INTL Version upgraded to the latest i.e. 18 87 85 88 = 1.6 = 86 89 * Latest WordPress and WooCommerce version compatibility. -
country-code-selector/trunk/country-code-selector.php
r2666731 r2924195 9 9 * Plugin URI: http://www.intolap.com/products/country-code-selector/ 10 10 * Description: Country Code Selector uses a JavaScript base to allow customers checking out in WooCommerce, Shopp, Contact form 7, Gravity form plugins select the country code using a dropdown field. 11 * Version: 1. 612 * WC requires at least: 6.013 * WC tested up to: 6.111 * Version: 1.7 12 * WC requires at least: 7.0 13 * WC tested up to: 7.7 14 14 * Author: INTOLAP 15 15 * Author URI: http://www.intolap.com … … 30 30 * Rename this for your plugin and update it as you release new versions. 31 31 */ 32 define( 'COUNTRY_CODE_SELECTOR_VERSION', '1. 6' );32 define( 'COUNTRY_CODE_SELECTOR_VERSION', '1.7' ); 33 33 34 34 /** -
country-code-selector/trunk/public/class-country-code-selector-public.php
r2874062 r2924195 77 77 */ 78 78 79 wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/country-code-selector-public.css', array(), $this->version, 'all' ); 80 79 // wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/country-code-selector-public.css', array(), $this->version, 'all' ); 80 wp_enqueue_style( $this->plugin_name, 'https://cdn.jsdelivr.net/npm/intl-tel-input@18.1.1/build/css/intlTelInput.css', array(), $this->version, 'all' ); 81 81 82 } 82 83 … … 100 101 */ 101 102 102 wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/country-code-selector-public.js', array( 'jquery' ), $this->version, false ); 103 103 // wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/country-code-selector-public.js', array( 'jquery' ), $this->version, false ); 104 105 wp_enqueue_script( $this->plugin_name, 'https://cdn.jsdelivr.net/npm/intl-tel-input@18.1.1/build/js/intlTelInput.min.js', array( 'jquery' ), $this->version, false ); 106 104 107 } 105 108 … … 133 136 separateDialCode: true, 134 137 formatOnDisplay: true, 138 autoPlaceholder: "polite", 135 139 <?php 136 140 if(!empty(get_option('initial_country'))){ … … 145 149 } 146 150 ?> 147 utilsScript: "<?php echo esc_url( plugin_dir_url( __FILE__ ) .'js/wc-utils.js' );?>",151 utilsScript: "<?php echo esc_url( plugin_dir_url( __FILE__ ) .'js/utils.js' );?>" 148 152 }); 149 153 … … 151 155 jQuery('[name=billing_phone][type=hidden]').val(jQuery('#billing_phone').val()); 152 156 }); 157 158 // Validation program 159 var errorMap = [ 160 "<?php _e( 'Invalid number', 'country-code-selector' ); ?>", 161 "<?php _e( 'Invalid country code', 'country-code-selector' ); ?>", 162 "<?php _e( 'Too short', 'country-code-selector' ); ?>", 163 "<?php _e( 'Too long', 'country-code-selector' ); ?>" 164 ]; 165 166 var preventAlert = true; 167 168 const reset = () => { 169 preventAlert = true; 170 }; 171 172 // on blur: validate 173 input.addEventListener('blur', () => { 174 reset(); 175 if (input.value.trim()) { 176 if (iti.isValidNumber()) { 177 document.getElementById("place_order").disabled = false; 178 } else { 179 const errorCode = iti.getValidationError(); 180 if(preventAlert){ 181 document.getElementById("place_order").disabled = true; 182 alert(errorMap[errorCode]); 183 preventAlert = false; 184 } 185 } 186 } 187 }); 188 189 // on keyup / change flag: reset 190 input.addEventListener('change', reset); 191 input.addEventListener('keyup', reset); 192 193 jQuery('select#billing_country').on( 'change', function (){ 194 var billingCountry = jQuery('#billing_country :selected').val(); 195 iti.setCountry(billingCountry.toLowerCase()); 196 }); 197 198 /* // detect the change 199 jQuery('input#billing_phone').on("keyup paste input",function() { 200 var full_number = iti.getNumber(intlTelInputUtils.numberFormat.E164); 201 jQuery(this).siblings('[name=billing_phone][type=hidden]').val(full_number); 202 }); */ 203 204 input.addEventListener("countrychange", function() { 205 var country_data = iti.getSelectedCountryData(); 206 // alert(country_data.name+'-'+country_data.iso2+'-'+country_data.dialCode); 207 jQuery('input#billing_phone').val(''); 208 jQuery('select#billing_country').val(country_data.iso2.toUpperCase()).trigger('change'); 209 }); 153 210 } 154 211 </script> 155 156 <script>157 var input = document.querySelector("#billing_phone");158 159 var errorMap = [160 "<?php _e( 'Invalid number', 'country-code-selector' ); ?>",161 "<?php _e( 'Invalid country code', 'country-code-selector' ); ?>",162 "<?php _e( 'Too short', 'country-code-selector' ); ?>",163 "<?php _e( 'Too long', 'country-code-selector' ); ?>"164 ];165 166 var preventAlert = true;167 168 var reset = function() {169 preventAlert = true;170 };171 172 input.addEventListener('blur', function() {173 if (input.value.trim()) {174 if (iti.isValidNumber()) {175 document.getElementById("place_order").disabled = false;176 } else {177 var errorCode = iti.getValidationError();178 179 if(preventAlert){180 document.getElementById("place_order").disabled = true;181 alert(errorMap[errorCode]);182 preventAlert = false;183 }184 }185 }186 });187 188 // on keyup / change flag: reset189 input.addEventListener('change', reset);190 input.addEventListener('keyup', reset);191 192 jQuery('select#billing_country').on( 'change', function (){193 var billingCountry = jQuery('#billing_country :selected').val();194 iti.setCountry(billingCountry.toLowerCase());195 });196 197 input.addEventListener("countrychange", function() {198 var country_data = iti.getSelectedCountryData();199 // alert(country_data.name+'-'+country_data.iso2+'-'+country_data.dialCode);200 jQuery('input#billing_phone').val('');201 jQuery('select#billing_country').val(country_data.iso2.toUpperCase()).trigger('change');202 });203 </script>204 212 <?php 205 213 } … … 252 260 } 253 261 ?> 254 utilsScript: "<?php echo esc_url( plugin_dir_url( __FILE__ ) .'js/ wc-utils.js' );?>",262 utilsScript: "<?php echo esc_url( plugin_dir_url( __FILE__ ) .'js/utils.js' );?>", 255 263 }); 256 264 } … … 350 358 } 351 359 352 $script .= 'utilsScript: "' . esc_url( plugin_dir_url( __FILE__ ) .'js/ wc-utils.js' ).'",';360 $script .= 'utilsScript: "' . esc_url( plugin_dir_url( __FILE__ ) .'js/utils.js' ).'",'; 353 361 $script .= '});'; 354 362 … … 471 479 } 472 480 ?> 473 utilsScript: "<?php echo esc_url( plugin_dir_url( __FILE__ ) .'js/ wc-utils.js' );?>",481 utilsScript: "<?php echo esc_url( plugin_dir_url( __FILE__ ) .'js/utils.js' );?>", 474 482 }); 475 483 }
Note: See TracChangeset
for help on using the changeset viewer.