├── assets ├── intl-tel-input │ ├── img │ │ ├── flags.png │ │ └── flags@2x.png │ ├── css │ │ ├── demo.css │ │ └── intlTelInput.css │ └── js │ │ ├── intlTelInput.min.js │ │ └── intlTelInput.js ├── css │ └── input.css └── js │ ├── input.js │ └── js.cookie.js ├── lang └── README.md ├── README.md ├── readme.txt ├── acf-intl-tel-input.php └── fields └── class-jony-acf-field-intl-tel-input-v5.php /assets/intl-tel-input/img/flags.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonyhayama/acf-intl-tel-input/HEAD/assets/intl-tel-input/img/flags.png -------------------------------------------------------------------------------- /assets/intl-tel-input/img/flags@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonyhayama/acf-intl-tel-input/HEAD/assets/intl-tel-input/img/flags@2x.png -------------------------------------------------------------------------------- /lang/README.md: -------------------------------------------------------------------------------- 1 | # Translations directory 2 | 3 | Use this directory to store .po and .mo files. 4 | 5 | This directory can be removed if not used. 6 | -------------------------------------------------------------------------------- /assets/css/input.css: -------------------------------------------------------------------------------- 1 | .acf-input .intl-tel-input{ width:100%; } 2 | .acf-input .intl-tel-input input[type=tel]{ width:100%; padding-top:3px; padding-bottom:3px; line-height:1.4; box-sizing:border-box; margin:0; font-size:14px } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ACF International Telephone Input Field 2 | 3 | Adds International Telephone Input to ACF. 4 | 5 | Allows separate dial code, drop down, initial country (auto or manual), exclude countries, only countries and preferred countries. 6 | 7 | ## Links 8 | 9 | * International Telephone Input[https://intl-tel-input.com/] by jackocnr[https://github.com/jackocnr] 10 | * Advanced Custom Fields[https://www.advancedcustomfields.com/] by Elliot Condon[https://github.com/elliotcondon] 11 | 12 | ## Compatibility 13 | 14 | This ACF field type is compatible with: 15 | * ACF 5 16 | 17 | ## Installation 18 | 19 | 1. Copy the `acf-intl-tel-input` folder into your `wp-content/plugins` folder 20 | 2. Activate the International Telephone Input plugin via the plugins admin page 21 | 3. Create a new field via ACF and select the International Telephone Input type 22 | 4. Read the description above for usage instructions 23 | 24 | ## Changelog 25 | 26 | ### Version 1.0.0 - Inital Commit -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | === Advanced Custom Fields: International Telephone Input Field === 2 | Contributors: Jony Hayama 3 | Tags: acf, acf-pro, intl-tel-input 4 | Requires at least: 3.6.0 5 | Tested up to: 4.9.0 6 | Stable tag: trunk 7 | License: GPLv2 or later 8 | License URI: http://www.gnu.org/licenses/gpl-2.0.html 9 | 10 | Adds International Telephone Input to ACF. 11 | 12 | == Description == 13 | 14 | Adds International Telephone Input to ACF. 15 | 16 | Allows separate dial code, drop down, initial country (auto or manual), exclude countries, only countries and preferred countries. 17 | 18 | = Links = 19 | * International Telephone Input[https://intl-tel-input.com/] by jackocnr[https://github.com/jackocnr] 20 | * Advanced Custom Fields[https://www.advancedcustomfields.com/] by Elliot Condon[https://github.com/elliotcondon] 21 | 22 | = Compatibility = 23 | 24 | This ACF field type is compatible with: 25 | * ACF 5 26 | 27 | == Installation == 28 | 29 | 1. Copy the `acf-intl-tel-input` folder into your `wp-content/plugins` folder 30 | 2. Activate the International Telephone Input plugin via the plugins admin page 31 | 3. Create a new field via ACF and select the International Telephone Input type 32 | 4. Read the description above for usage instructions 33 | 34 | == Changelog == 35 | 36 | = 1.0.0 = 37 | * Initial Release. -------------------------------------------------------------------------------- /assets/intl-tel-input/css/demo.css: -------------------------------------------------------------------------------- 1 | * { 2 | box-sizing: border-box; 3 | -moz-box-sizing: border-box; } 4 | 5 | body { 6 | margin: 20px; 7 | font-size: 14px; 8 | font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; 9 | color: #555; } 10 | 11 | .hide { 12 | display: none; } 13 | 14 | pre { 15 | margin: 0 !important; 16 | display: inline-block; } 17 | 18 | .token.operator, 19 | .token.entity, 20 | .token.url, 21 | .language-css .token.string, 22 | .style .token.string, 23 | .token.variable { 24 | background: none; } 25 | 26 | input, button { 27 | height: 35px; 28 | margin: 0; 29 | padding: 6px 12px; 30 | border-radius: 2px; 31 | font-family: inherit; 32 | font-size: 100%; 33 | color: inherit; } 34 | input[disabled], button[disabled] { 35 | background-color: #eee; } 36 | 37 | input, select { 38 | border: 1px solid #CCC; 39 | width: 250px; } 40 | 41 | ::-webkit-input-placeholder { 42 | color: #BBB; } 43 | 44 | ::-moz-placeholder { 45 | /* Firefox 19+ */ 46 | color: #BBB; 47 | opacity: 1; } 48 | 49 | :-ms-input-placeholder { 50 | color: #BBB; } 51 | 52 | button { 53 | color: #FFF; 54 | background-color: #428BCA; 55 | border: 1px solid #357EBD; } 56 | button:hover { 57 | background-color: #3276B1; 58 | border-color: #285E8E; 59 | cursor: pointer; } 60 | 61 | #result { 62 | margin-bottom: 100px; } 63 | -------------------------------------------------------------------------------- /acf-intl-tel-input.php: -------------------------------------------------------------------------------- 1 | settings = array( 45 | 'version' => '1.0.0', 46 | 'url' => plugin_dir_url( __FILE__ ), 47 | 'path' => plugin_dir_path( __FILE__ ) 48 | ); 49 | 50 | 51 | // set text domain 52 | // https://codex.wordpress.org/Function_Reference/load_plugin_textdomain 53 | load_plugin_textdomain( 'acf-intl-tel-input', false, plugin_basename( dirname( __FILE__ ) ) . '/lang' ); 54 | 55 | 56 | // include field 57 | add_action('acf/include_field_types', array($this, 'include_field_types')); // v5 58 | add_action('acf/register_fields', array($this, 'include_field_types')); // v4 59 | 60 | } 61 | 62 | 63 | /* 64 | * include_field_types 65 | * 66 | * This function will include the field type class 67 | * 68 | * @type function 69 | * @date 17/02/2016 70 | * @since 1.0.0 71 | * 72 | * @param $version (int) major ACF version. Defaults to false 73 | * @return n/a 74 | */ 75 | 76 | function include_field_types( $version = false ) { 77 | 78 | // support empty $version 79 | if( !$version ) $version = 5; 80 | 81 | 82 | // include 83 | include_once('fields/class-jony-acf-field-intl-tel-input-v' . $version . '.php'); 84 | 85 | } 86 | 87 | } 88 | 89 | 90 | // initialize 91 | new jony_acf_plugin_intl_tel_input(); 92 | 93 | 94 | // class_exists check 95 | endif; 96 | 97 | ?> -------------------------------------------------------------------------------- /assets/js/input.js: -------------------------------------------------------------------------------- 1 | (function($){ 2 | // Initialize Cookies in no conflict mode. 3 | var $acf_intl_tel_input_cookies = Cookies.noConflict(); 4 | 5 | /** 6 | * initialize_field 7 | * 8 | * This function will initialize the $field. 9 | * 10 | * @date 30/11/17 11 | * @since 5.6.5 12 | * 13 | * @param n/a 14 | * @return n/a 15 | */ 16 | 17 | function initialize_field( $field ) { 18 | // get input field 19 | var $telInput = $field.find('input'); 20 | // set telInput options 21 | var $telInputOptions = { 22 | autoPlaceholder: "aggressive", 23 | hiddenInput: $telInput.attr('data-hiddenInput'), 24 | separateDialCode: ( $telInput.attr('data-separateDialCode') == '1' ), 25 | allowDropdown: ( $telInput.attr('data-allowDropdown') == '1' ), 26 | initialCountry : $telInput.attr('data-initialCountry'), 27 | preferredCountries : ( $telInput.attr('data-preferredCountries') != '' ) ? $telInput.attr('data-preferredCountries').split(',') : '', 28 | onlyCountries : ( $telInput.attr('data-onlyCountries') != '' ) ? $telInput.attr('data-onlyCountries').split(',') : '', 29 | excludeCountries : ( $telInput.attr('data-excludeCountries') != '' ) ? $telInput.attr('data-excludeCountries').split(',') : '', 30 | // placeholderNumberType: "MOBILE", 31 | }; 32 | // If initialCountry is set to Auto, we need to lookup user location 33 | if( $telInput.attr('data-initialCountry') == 'auto' ){ 34 | $telInputOptions.geoIpLookup = function(callback) { 35 | // Check if we have user location saved in cookies 36 | var $countryCodeCookie = $acf_intl_tel_input_cookies.get( 'acf_intl_tel_input_countryCode' ); 37 | if( $countryCodeCookie === undefined ){ 38 | // If Location is not saved, let's get it! 39 | $.get("https://ipinfo.io", function() {}, "jsonp").always(function(resp) { 40 | var countryCode = (resp && resp.country) ? resp.country : ""; 41 | // Save location to Cookies 42 | $acf_intl_tel_input_cookies.set( 'acf_intl_tel_input_countryCode', countryCode, { expires : 7, path : acf_intl_tel_input_obj.COOKIEPATH, domain : acf_intl_tel_input_obj.COOKIE_DOMAIN } ); 43 | // Execute the callback 44 | callback(countryCode); 45 | }); 46 | } else{ 47 | // Execute the callback 48 | callback($countryCodeCookie); 49 | } 50 | }; 51 | } 52 | // Make input render the mask when user focus out 53 | $telInput.on('blur', function(){ 54 | if( $telInput.intlTelInput("isValidNumber") ){ 55 | $telInput.intlTelInput("setNumber", $telInput.intlTelInput( 'getNumber' ) ); 56 | $telInput.prev('input[type="hidden"]').val($telInput.intlTelInput('getNumber')); 57 | } else { // Clear input if number is not valid 58 | $telInput.val(''); 59 | $telInput.prev('input[type="hidden"]').val(''); 60 | } 61 | }) 62 | // Initialize Input 63 | .intlTelInput( $telInputOptions ); 64 | } 65 | 66 | 67 | if( typeof acf.add_action !== 'undefined' ) { 68 | 69 | /* 70 | * ready & append (ACF5) 71 | * 72 | * These two events are called when a field element is ready for initizliation. 73 | * - ready: on page load similar to $(document).ready() 74 | * - append: on new DOM elements appended via repeater field or other AJAX calls 75 | * 76 | * @param n/a 77 | * @return n/a 78 | */ 79 | 80 | acf.add_action('ready_field/type=intl_tel_input', initialize_field); 81 | acf.add_action('append_field/type=intl_tel_input', initialize_field); 82 | 83 | } 84 | 85 | /** 86 | * Apply the initialize_fields in Frontend acf_form 87 | */ 88 | $('[data-type="intl_tel_input"]').each(function () { 89 | initialize_field($(this)); 90 | }); 91 | 92 | })(jQuery); 93 | -------------------------------------------------------------------------------- /assets/js/js.cookie.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * JavaScript Cookie v2.2.0 3 | * https://github.com/js-cookie/js-cookie 4 | * 5 | * Copyright 2006, 2015 Klaus Hartl & Fagner Brack 6 | * Released under the MIT license 7 | */ 8 | ;(function (factory) { 9 | var registeredInModuleLoader = false; 10 | if (typeof define === 'function' && define.amd) { 11 | define(factory); 12 | registeredInModuleLoader = true; 13 | } 14 | if (typeof exports === 'object') { 15 | module.exports = factory(); 16 | registeredInModuleLoader = true; 17 | } 18 | if (!registeredInModuleLoader) { 19 | var OldCookies = window.Cookies; 20 | var api = window.Cookies = factory(); 21 | api.noConflict = function () { 22 | window.Cookies = OldCookies; 23 | return api; 24 | }; 25 | } 26 | }(function () { 27 | function extend () { 28 | var i = 0; 29 | var result = {}; 30 | for (; i < arguments.length; i++) { 31 | var attributes = arguments[ i ]; 32 | for (var key in attributes) { 33 | result[key] = attributes[key]; 34 | } 35 | } 36 | return result; 37 | } 38 | 39 | function init (converter) { 40 | function api (key, value, attributes) { 41 | var result; 42 | if (typeof document === 'undefined') { 43 | return; 44 | } 45 | 46 | // Write 47 | 48 | if (arguments.length > 1) { 49 | attributes = extend({ 50 | path: '/' 51 | }, api.defaults, attributes); 52 | 53 | if (typeof attributes.expires === 'number') { 54 | var expires = new Date(); 55 | expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5); 56 | attributes.expires = expires; 57 | } 58 | 59 | // We're using "expires" because "max-age" is not supported by IE 60 | attributes.expires = attributes.expires ? attributes.expires.toUTCString() : ''; 61 | 62 | try { 63 | result = JSON.stringify(value); 64 | if (/^[\{\[]/.test(result)) { 65 | value = result; 66 | } 67 | } catch (e) {} 68 | 69 | if (!converter.write) { 70 | value = encodeURIComponent(String(value)) 71 | .replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent); 72 | } else { 73 | value = converter.write(value, key); 74 | } 75 | 76 | key = encodeURIComponent(String(key)); 77 | key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent); 78 | key = key.replace(/[\(\)]/g, escape); 79 | 80 | var stringifiedAttributes = ''; 81 | 82 | for (var attributeName in attributes) { 83 | if (!attributes[attributeName]) { 84 | continue; 85 | } 86 | stringifiedAttributes += '; ' + attributeName; 87 | if (attributes[attributeName] === true) { 88 | continue; 89 | } 90 | stringifiedAttributes += '=' + attributes[attributeName]; 91 | } 92 | return (document.cookie = key + '=' + value + stringifiedAttributes); 93 | } 94 | 95 | // Read 96 | 97 | if (!key) { 98 | result = {}; 99 | } 100 | 101 | // To prevent the for loop in the first place assign an empty array 102 | // in case there are no cookies at all. Also prevents odd result when 103 | // calling "get()" 104 | var cookies = document.cookie ? document.cookie.split('; ') : []; 105 | var rdecode = /(%[0-9A-Z]{2})+/g; 106 | var i = 0; 107 | 108 | for (; i < cookies.length; i++) { 109 | var parts = cookies[i].split('='); 110 | var cookie = parts.slice(1).join('='); 111 | 112 | if (!this.json && cookie.charAt(0) === '"') { 113 | cookie = cookie.slice(1, -1); 114 | } 115 | 116 | try { 117 | var name = parts[0].replace(rdecode, decodeURIComponent); 118 | cookie = converter.read ? 119 | converter.read(cookie, name) : converter(cookie, name) || 120 | cookie.replace(rdecode, decodeURIComponent); 121 | 122 | if (this.json) { 123 | try { 124 | cookie = JSON.parse(cookie); 125 | } catch (e) {} 126 | } 127 | 128 | if (key === name) { 129 | result = cookie; 130 | break; 131 | } 132 | 133 | if (!key) { 134 | result[name] = cookie; 135 | } 136 | } catch (e) {} 137 | } 138 | 139 | return result; 140 | } 141 | 142 | api.set = api; 143 | api.get = function (key) { 144 | return api.call(api, key); 145 | }; 146 | api.getJSON = function () { 147 | return api.apply({ 148 | json: true 149 | }, [].slice.call(arguments)); 150 | }; 151 | api.defaults = {}; 152 | 153 | api.remove = function (key, attributes) { 154 | api(key, '', extend(attributes, { 155 | expires: -1 156 | })); 157 | }; 158 | 159 | api.withConverter = init; 160 | 161 | return api; 162 | } 163 | 164 | return init(function () {}); 165 | })); 166 | -------------------------------------------------------------------------------- /fields/class-jony-acf-field-intl-tel-input-v5.php: -------------------------------------------------------------------------------- 1 | name = 'intl_tel_input'; 34 | 35 | 36 | /* 37 | * label (string) Multiple words, can include spaces, visible when selecting a field type 38 | */ 39 | 40 | $this->label = __('International Telephone Input', 'acf-intl-tel-input'); 41 | 42 | 43 | /* 44 | * category (string) basic | content | choice | relational | jquery | layout | CUSTOM GROUP NAME 45 | */ 46 | 47 | $this->category = 'jquery'; 48 | 49 | 50 | /* 51 | * defaults (array) Array of default settings which are merged into the field object. These are used later in settings 52 | */ 53 | 54 | $this->defaults = array( 55 | 'separateDialCode' => false, 56 | 'allowDropdown' => true, 57 | 'excludeCountries' => '', 58 | 'onlyCountries' => '', 59 | 'preferredCountries' => '', 60 | 'initialCountry' => 'auto' 61 | ); 62 | 63 | 64 | /* 65 | * l10n (array) Array of strings that are used in JavaScript. This allows JS strings to be translated in PHP and loaded via: 66 | * var message = acf._e('intl_tel_input', 'error'); 67 | */ 68 | 69 | $this->l10n = array( 70 | 'error' => __('Error! Please enter a higher value', 'acf-intl-tel-input'), 71 | ); 72 | 73 | 74 | /* 75 | * settings (array) Store plugin settings (url, path, version) as a reference for later use with assets 76 | */ 77 | 78 | $this->settings = $settings; 79 | 80 | 81 | // do not delete! 82 | parent::__construct(); 83 | 84 | } 85 | 86 | 87 | /* 88 | * render_field_settings() 89 | * 90 | * Create extra settings for your field. These are visible when editing a field 91 | * 92 | * @type action 93 | * @since 3.6 94 | * @date 23/01/13 95 | * 96 | * @param $field (array) the $field being edited 97 | * @return n/a 98 | */ 99 | 100 | function render_field_settings( $field ) { 101 | 102 | /* 103 | * acf_render_field_setting 104 | * 105 | * This function will create a setting for your field. Simply pass the $field parameter and an array of field settings. 106 | * The array of settings does not require a `value` or `prefix`; These settings are found from the $field array. 107 | * 108 | * More than one setting can be added by copy/paste the above code. 109 | * Please note that you must also have a matching $defaults value for the field name (font_size) 110 | */ 111 | 112 | // $this->defaults = array( 113 | // 'nationalMode' => true, 114 | // 'separateDialCode' => false, 115 | // 'allowDropdown' => true, 116 | // 'excludeCountries' => '', 117 | // 'onlyCountries' => '', 118 | // 'preferredCountries' => '', 119 | // 'initialCountry' => 'auto' 120 | // ); 121 | 122 | acf_render_field_setting( $field, array( 123 | 'label' => __( 'Separate Dial Code', 'acf-intl-tel-input'), 124 | 'instructions' => '', 125 | 'type' => 'true_false', 126 | 'name' => 'separateDialCode', 127 | 'ui' => 1 128 | ) ); 129 | 130 | acf_render_field_setting( $field, array( 131 | 'label' => __( 'Allow Drop Down', 'acf-intl-tel-input'), 132 | 'instructions' => '', 133 | 'type' => 'true_false', 134 | 'name' => 'allowDropdown', 135 | 'ui' => 1 136 | ) ); 137 | $countryCodeLink = 'ISO 3166-1 alpha-2'; 138 | acf_render_field_setting( $field, array( 139 | 'label' => __( 'Initial Country','acf-intl-tel-input' ), 140 | 'instructions' => sprintf( __( 'Use "auto" to display user country (geo location based) or enter a country code (%s)', 'acf-intl-tel-input' ), $countryCodeLink ), 141 | 'type' => 'text', 142 | 'name' => 'initialCountry', 143 | )); 144 | 145 | acf_render_field_setting( $field, array( 146 | 'label' => __('Exclude Countries','acf-intl-tel-input'), 147 | 'instructions' => sprintf( __( 'Comma separated list of country codes (%s)', 'acf-intl-tel-input' ), $countryCodeLink ), 148 | 'type' => 'textarea', 149 | 'name' => 'excludeCountries', 150 | 'rows' => 2 151 | )); 152 | 153 | acf_render_field_setting( $field, array( 154 | 'label' => __('Only Countries','acf-intl-tel-input'), 155 | 'instructions' => sprintf( __( 'Comma separated list of country codes (%s)', 'acf-intl-tel-input' ), $countryCodeLink ), 156 | 'type' => 'textarea', 157 | 'name' => 'onlyCountries', 158 | 'rows' => 2 159 | )); 160 | 161 | acf_render_field_setting( $field, array( 162 | 'label' => __('Preferred Countries','acf-intl-tel-input'), 163 | 'instructions' => sprintf( __( 'Comma separated list of country codes (%s)', 'acf-intl-tel-input' ), $countryCodeLink ), 164 | 'type' => 'textarea', 165 | 'name' => 'preferredCountries', 166 | 'rows' => 2 167 | )); 168 | 169 | } 170 | 171 | 172 | 173 | /* 174 | * render_field() 175 | * 176 | * Create the HTML interface for your field 177 | * 178 | * @param $field (array) the $field being rendered 179 | * 180 | * @type action 181 | * @since 3.6 182 | * @date 23/01/13 183 | * 184 | * @param $field (array) the $field being edited 185 | * @return n/a 186 | */ 187 | 188 | function render_field( $field ) { 189 | $attr[] = 'data-hiddenInput="' . esc_attr($field['name']) . '"'; 190 | foreach( $this->defaults as $key => $value ){ 191 | $value = $field[$key]; 192 | switch( $key ){ 193 | case 'preferredCountries': 194 | case 'excludeCountries': 195 | case 'onlyCountries': 196 | $value = str_replace(' ', '', $value ); 197 | $value = str_replace(' ', '', apply_filters( "jony-acf-intl-tel-input/render_field/$key", $value, $field ) ); 198 | break; 199 | } 200 | $attr[] = 'data-' . $key .'="' . $value . '"'; 201 | } 202 | $attr = implode( ' ', $attr ); 203 | 204 | ?> >settings['url']; 228 | $version = $this->settings['version']; 229 | $intlTelInputVersion = '12.1.0'; 230 | $jsCookieVersion = '2.2.0'; 231 | 232 | 233 | // register & include JS 234 | wp_register_script('intl-tel-input', "{$url}assets/intl-tel-input/js/intlTelInput.min.js", array('jquery'), $intlTelInputVersion, true); 235 | wp_register_script('intl-tel-input-util', "{$url}assets/intl-tel-input/js/utils.js", array('jquery'), $intlTelInputVersion, true); 236 | wp_register_script('js-cookie', "{$url}assets/js/js.cookie.js", array(), $jsCookieVersion, true); 237 | wp_register_script('acf-intl-tel-input', "{$url}assets/js/input.js", array('acf-input', 'jquery', 'intl-tel-input', 'intl-tel-input-util', 'js-cookie'), $version, true); 238 | wp_localize_script('acf-intl-tel-input', 'acf_intl_tel_input_obj', array( 239 | 'COOKIEPATH' => COOKIEPATH, 240 | 'COOKIE_DOMAIN' => COOKIE_DOMAIN, 241 | ) ); 242 | wp_enqueue_script('acf-intl-tel-input'); 243 | 244 | 245 | // register & include CSS 246 | wp_register_style('intl-tel-input', "{$url}assets/intl-tel-input/css/intlTelInput.css", array(), $intlTelInputVersion); 247 | wp_register_style('acf-intl-tel-input', "{$url}assets/css/input.css", array('acf-input', 'intl-tel-input'), $version); 248 | wp_enqueue_style('acf-intl-tel-input'); 249 | 250 | } 251 | 252 | 253 | 254 | 255 | /* 256 | * input_admin_head() 257 | * 258 | * This action is called in the admin_head action on the edit screen where your field is created. 259 | * Use this action to add CSS and JavaScript to assist your render_field() action. 260 | * 261 | * @type action (admin_head) 262 | * @since 3.6 263 | * @date 23/01/13 264 | * 265 | * @param n/a 266 | * @return n/a 267 | */ 268 | 269 | /* 270 | 271 | function input_admin_head() { 272 | 273 | 274 | 275 | } 276 | 277 | */ 278 | 279 | 280 | /* 281 | * input_form_data() 282 | * 283 | * This function is called once on the 'input' page between the head and footer 284 | * There are 2 situations where ACF did not load during the 'acf/input_admin_enqueue_scripts' and 285 | * 'acf/input_admin_head' actions because ACF did not know it was going to be used. These situations are 286 | * seen on comments / user edit forms on the front end. This function will always be called, and includes 287 | * $args that related to the current screen such as $args['post_id'] 288 | * 289 | * @type function 290 | * @date 6/03/2014 291 | * @since 5.0.0 292 | * 293 | * @param $args (array) 294 | * @return n/a 295 | */ 296 | 297 | /* 298 | 299 | function input_form_data( $args ) { 300 | 301 | 302 | 303 | } 304 | 305 | */ 306 | 307 | 308 | /* 309 | * input_admin_footer() 310 | * 311 | * This action is called in the admin_footer action on the edit screen where your field is created. 312 | * Use this action to add CSS and JavaScript to assist your render_field() action. 313 | * 314 | * @type action (admin_footer) 315 | * @since 3.6 316 | * @date 23/01/13 317 | * 318 | * @param n/a 319 | * @return n/a 320 | */ 321 | 322 | /* 323 | 324 | function input_admin_footer() { 325 | 326 | 327 | 328 | } 329 | 330 | */ 331 | 332 | 333 | /* 334 | * field_group_admin_enqueue_scripts() 335 | * 336 | * This action is called in the admin_enqueue_scripts action on the edit screen where your field is edited. 337 | * Use this action to add CSS + JavaScript to assist your render_field_options() action. 338 | * 339 | * @type action (admin_enqueue_scripts) 340 | * @since 3.6 341 | * @date 23/01/13 342 | * 343 | * @param n/a 344 | * @return n/a 345 | */ 346 | 347 | /* 348 | 349 | function field_group_admin_enqueue_scripts() { 350 | 351 | } 352 | 353 | */ 354 | 355 | 356 | /* 357 | * field_group_admin_head() 358 | * 359 | * This action is called in the admin_head action on the edit screen where your field is edited. 360 | * Use this action to add CSS and JavaScript to assist your render_field_options() action. 361 | * 362 | * @type action (admin_head) 363 | * @since 3.6 364 | * @date 23/01/13 365 | * 366 | * @param n/a 367 | * @return n/a 368 | */ 369 | 370 | /* 371 | 372 | function field_group_admin_head() { 373 | 374 | } 375 | 376 | */ 377 | 378 | 379 | /* 380 | * load_value() 381 | * 382 | * This filter is applied to the $value after it is loaded from the db 383 | * 384 | * @type filter 385 | * @since 3.6 386 | * @date 23/01/13 387 | * 388 | * @param $value (mixed) the value found in the database 389 | * @param $post_id (mixed) the $post_id from which the value was loaded 390 | * @param $field (array) the field array holding all the field options 391 | * @return $value 392 | */ 393 | 394 | /* 395 | 396 | function load_value( $value, $post_id, $field ) { 397 | 398 | return $value; 399 | 400 | } 401 | 402 | */ 403 | 404 | 405 | /* 406 | * update_value() 407 | * 408 | * This filter is applied to the $value before it is saved in the db 409 | * 410 | * @type filter 411 | * @since 3.6 412 | * @date 23/01/13 413 | * 414 | * @param $value (mixed) the value found in the database 415 | * @param $post_id (mixed) the $post_id from which the value was loaded 416 | * @param $field (array) the field array holding all the field options 417 | * @return $value 418 | */ 419 | 420 | /* 421 | 422 | function update_value( $value, $post_id, $field ) { 423 | 424 | return $value; 425 | 426 | } 427 | 428 | */ 429 | 430 | 431 | /* 432 | * format_value() 433 | * 434 | * This filter is appied to the $value after it is loaded from the db and before it is returned to the template 435 | * 436 | * @type filter 437 | * @since 3.6 438 | * @date 23/01/13 439 | * 440 | * @param $value (mixed) the value which was loaded from the database 441 | * @param $post_id (mixed) the $post_id from which the value was loaded 442 | * @param $field (array) the field array holding all the field options 443 | * 444 | * @return $value (mixed) the modified value 445 | */ 446 | 447 | /* 448 | 449 | function format_value( $value, $post_id, $field ) { 450 | 451 | // bail early if no value 452 | if( empty($value) ) { 453 | 454 | return $value; 455 | 456 | } 457 | 458 | 459 | // apply setting 460 | if( $field['font_size'] > 12 ) { 461 | 462 | // format the value 463 | // $value = 'something'; 464 | 465 | } 466 | 467 | 468 | // return 469 | return $value; 470 | } 471 | 472 | */ 473 | 474 | 475 | /* 476 | * validate_value() 477 | * 478 | * This filter is used to perform validation on the value prior to saving. 479 | * All values are validated regardless of the field's required setting. This allows you to validate and return 480 | * messages to the user if the value is not correct 481 | * 482 | * @type filter 483 | * @date 11/02/2014 484 | * @since 5.0.0 485 | * 486 | * @param $valid (boolean) validation status based on the value and the field's required setting 487 | * @param $value (mixed) the $_POST value 488 | * @param $field (array) the field array holding all the field options 489 | * @param $input (string) the corresponding input name for $_POST value 490 | * @return $valid 491 | */ 492 | 493 | /* 494 | 495 | function validate_value( $valid, $value, $field, $input ){ 496 | 497 | // Basic usage 498 | if( $value < $field['custom_minimum_setting'] ) 499 | { 500 | $valid = false; 501 | } 502 | 503 | 504 | // Advanced usage 505 | if( $value < $field['custom_minimum_setting'] ) 506 | { 507 | $valid = __('The value is too little!','acf-intl-tel-input'), 508 | } 509 | 510 | 511 | // return 512 | return $valid; 513 | 514 | } 515 | 516 | */ 517 | 518 | 519 | /* 520 | * delete_value() 521 | * 522 | * This action is fired after a value has been deleted from the db. 523 | * Please note that saving a blank value is treated as an update, not a delete 524 | * 525 | * @type action 526 | * @date 6/03/2014 527 | * @since 5.0.0 528 | * 529 | * @param $post_id (mixed) the $post_id from which the value was deleted 530 | * @param $key (string) the $meta_key which the value was deleted 531 | * @return n/a 532 | */ 533 | 534 | /* 535 | 536 | function delete_value( $post_id, $key ) { 537 | 538 | 539 | 540 | } 541 | 542 | */ 543 | 544 | 545 | /* 546 | * load_field() 547 | * 548 | * This filter is applied to the $field after it is loaded from the database 549 | * 550 | * @type filter 551 | * @date 23/01/2013 552 | * @since 3.6.0 553 | * 554 | * @param $field (array) the field array holding all the field options 555 | * @return $field 556 | */ 557 | 558 | /* 559 | 560 | function load_field( $field ) { 561 | 562 | return $field; 563 | 564 | } 565 | 566 | */ 567 | 568 | 569 | /* 570 | * update_field() 571 | * 572 | * This filter is applied to the $field before it is saved to the database 573 | * 574 | * @type filter 575 | * @date 23/01/2013 576 | * @since 3.6.0 577 | * 578 | * @param $field (array) the field array holding all the field options 579 | * @return $field 580 | */ 581 | 582 | /* 583 | 584 | function update_field( $field ) { 585 | 586 | return $field; 587 | 588 | } 589 | 590 | */ 591 | 592 | 593 | /* 594 | * delete_field() 595 | * 596 | * This action is fired after a field is deleted from the database 597 | * 598 | * @type action 599 | * @date 11/02/2014 600 | * @since 5.0.0 601 | * 602 | * @param $field (array) the field array holding all the field options 603 | * @return n/a 604 | */ 605 | 606 | /* 607 | 608 | function delete_field( $field ) { 609 | 610 | 611 | 612 | } 613 | 614 | */ 615 | 616 | 617 | } 618 | 619 | 620 | // initialize 621 | new jony_acf_field_intl_tel_input( $this->settings ); 622 | 623 | 624 | // class_exists check 625 | endif; 626 | 627 | ?> 628 | -------------------------------------------------------------------------------- /assets/intl-tel-input/js/intlTelInput.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | * International Telephone Input v12.1.0 3 | * https://github.com/jackocnr/intl-tel-input.git 4 | * Licensed under the MIT license 5 | */ 6 | 7 | !function(a){"function"==typeof define&&define.amd?define(["jquery"],function(b){a(b,window,document)}):"object"==typeof module&&module.exports?module.exports=a(require("jquery"),window,document):a(jQuery,window,document)}(function(a,b,c,d){"use strict";function e(b,c){this.a=a(b),this.b=a.extend({},h,c),this.ns="."+f+g++,this.d=Boolean(b.setSelectionRange),this.e=Boolean(a(b).attr("placeholder"))}var f="intlTelInput",g=1,h={allowDropdown:!0,autoHideDialCode:!0,autoPlaceholder:"polite",customPlaceholder:null,dropdownContainer:"",excludeCountries:[],formatOnDisplay:!0,geoIpLookup:null,hiddenInput:"",initialCountry:"",nationalMode:!0,onlyCountries:[],placeholderNumberType:"MOBILE",preferredCountries:["us","gb"],separateDialCode:!1,utilsScript:""},i={b:38,c:40,d:13,e:27,f:43,A:65,Z:90,j:32,k:9},j=["800","822","833","844","855","866","877","880","881","882","883","884","885","886","887","888","889"];a(b).on("load",function(){a.fn[f].windowLoaded=!0}),e.prototype={_a:function(){return this.b.nationalMode&&(this.b.autoHideDialCode=!1),this.b.separateDialCode&&(this.b.autoHideDialCode=this.b.nationalMode=!1),this.g=/Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),this.g&&(a("body").addClass("iti-mobile"),this.b.dropdownContainer||(this.b.dropdownContainer="body")),this.h=new a.Deferred,this.i=new a.Deferred,this.s={},this._b(),this._f(),this._h(),this._i(),this._i2(),[this.h,this.i]},_b:function(){this._d(),this._d2(),this._e()},_c:function(a,b,c){b in this.q||(this.q[b]=[]);var d=c||0;this.q[b][d]=a},_d:function(){if(this.b.onlyCountries.length){var a=this.b.onlyCountries.map(function(a){return a.toLowerCase()});this.p=k.filter(function(b){return a.indexOf(b.iso2)>-1})}else if(this.b.excludeCountries.length){var b=this.b.excludeCountries.map(function(a){return a.toLowerCase()});this.p=k.filter(function(a){return-1===b.indexOf(a.iso2)})}else this.p=k},_d2:function(){this.q={};for(var a=0;a",{"class":b})),this.k=a("
",{"class":"flag-container"}).insertBefore(this.a);var c=a("
",{"class":"selected-flag"});c.appendTo(this.k),this.l=a("
",{"class":"iti-flag"}).appendTo(c),this.b.separateDialCode&&(this.t=a("
",{"class":"selected-dial-code"}).appendTo(c)),this.b.allowDropdown?(c.attr("tabindex","0"),a("
",{"class":"iti-arrow"}).appendTo(c),this.m=a("
    ",{"class":"country-list hide"}),this.preferredCountries.length&&(this._g(this.preferredCountries,"preferred"),a("
  • ",{"class":"divider"}).appendTo(this.m)),this._g(this.p,""),this.o=this.m.children(".country"),this.b.dropdownContainer?this.dropdown=a("
    ",{"class":"intl-tel-input iti-container"}).append(this.m):this.m.appendTo(this.k)):this.o=a(),this.b.hiddenInput&&(this.hiddenInput=a("",{type:"hidden",name:this.b.hiddenInput}).insertBefore(this.a))},_g:function(a,b){for(var c="",d=0;d",c+="
    ",c+=""+e.name+"",c+="+"+e.dialCode+"",c+="
  • "}this.m.append(c)},_h:function(){var a=this.a.val();this._af(a)&&(!this._isRegionlessNanp(a)||this.b.nationalMode&&!this.b.initialCountry)?this._v(a):"auto"!==this.b.initialCountry&&(this.b.initialCountry?this._z(this.b.initialCountry.toLowerCase()):(this.j=this.preferredCountries.length?this.preferredCountries[0].iso2:this.p[0].iso2,a||this._z(this.j)),a||this.b.nationalMode||this.b.autoHideDialCode||this.b.separateDialCode||this.a.val("+"+this.s.dialCode)),a&&this._u(a)},_i:function(){this._j(),this.b.autoHideDialCode&&this._l(),this.b.allowDropdown&&this._i1(),this.hiddenInput&&this._initHiddenInputListener()},_initHiddenInputListener:function(){var a=this,b=this.a.closest("form");b.length&&b.submit(function(){a.hiddenInput.val(a.getNumber())})},_i1:function(){var a=this,b=this.a.closest("label");b.length&&b.on("click"+this.ns,function(b){a.m.hasClass("hide")?a.a.focus():b.preventDefault()}),this.l.parent().on("click"+this.ns,function(b){!a.m.hasClass("hide")||a.a.prop("disabled")||a.a.prop("readonly")||a._n()}),this.k.on("keydown"+a.ns,function(b){!a.m.hasClass("hide")||b.which!=i.b&&b.which!=i.c&&b.which!=i.j&&b.which!=i.d||(b.preventDefault(),b.stopPropagation(),a._n()),b.which==i.k&&a._ac()})},_i2:function(){var c=this;this.b.utilsScript?a.fn[f].windowLoaded?a.fn[f].loadUtils(this.b.utilsScript,this.i):a(b).on("load",function(){a.fn[f].loadUtils(c.b.utilsScript,c.i)}):this.i.resolve(),"auto"===this.b.initialCountry?this._i3():this.h.resolve()},_i3:function(){a.fn[f].autoCountry?this.handleAutoCountry():a.fn[f].startedLoadingAutoCountry||(a.fn[f].startedLoadingAutoCountry=!0,"function"==typeof this.b.geoIpLookup&&this.b.geoIpLookup(function(b){a.fn[f].autoCountry=b.toLowerCase(),setTimeout(function(){a(".intl-tel-input input").intlTelInput("handleAutoCountry")})}))},_j:function(){var a=this;this.a.on("keyup"+this.ns,function(){a._v(a.a.val())&&a._triggerCountryChange()}),this.a.on("cut"+this.ns+" paste"+this.ns,function(){setTimeout(function(){a._v(a.a.val())&&a._triggerCountryChange()})})},_j2:function(a){var b=this.a.attr("maxlength");return b&&a.length>b?a.substr(0,b):a},_l:function(){var b=this;this.a.on("mousedown"+this.ns,function(a){b.a.is(":focus")||b.a.val()||(a.preventDefault(),b.a.focus())}),this.a.on("focus"+this.ns,function(a){b.a.val()||b.a.prop("readonly")||!b.s.dialCode||(b.a.val("+"+b.s.dialCode),b.a.one("keypress.plus"+b.ns,function(a){a.which==i.f&&b.a.val("")}),setTimeout(function(){var a=b.a[0];if(b.d){var c=b.a.val().length;a.setSelectionRange(c,c)}}))});var c=this.a.prop("form");c&&a(c).on("submit"+this.ns,function(){b._removeEmptyDialCode()}),this.a.on("blur"+this.ns,function(){b._removeEmptyDialCode()})},_removeEmptyDialCode:function(){var a=this.a.val();if("+"==a.charAt(0)){var b=this._m(a);b&&this.s.dialCode!=b||this.a.val("")}this.a.off("keypress.plus"+this.ns)},_m:function(a){return a.replace(/\D/g,"")},_n:function(){this._o();var a=this.m.children(".active");a.length&&(this._x(a),this._ad(a)),this._p(),this.l.children(".iti-arrow").addClass("up"),this.a.trigger("open:countrydropdown")},_o:function(){var c=this;if(this.b.dropdownContainer&&this.dropdown.appendTo(this.b.dropdownContainer),this.n=this.m.removeClass("hide").outerHeight(),!this.g){var d=this.a.offset(),e=d.top,f=a(b).scrollTop(),g=e+this.a.outerHeight()+this.nf;if(this.m.toggleClass("dropup",!g&&h),this.b.dropdownContainer){var i=!g&&h?0:this.a.innerHeight();this.dropdown.css({top:e+i,left:d.left}),a(b).on("scroll"+this.ns,function(){c._ac()})}}},_p:function(){var b=this;this.m.on("mouseover"+this.ns,".country",function(c){b._x(a(this))}),this.m.on("click"+this.ns,".country",function(c){b._ab(a(this))});var d=!0;a("html").on("click"+this.ns,function(a){d||b._ac(),d=!1});var e="",f=null;a(c).on("keydown"+this.ns,function(a){a.preventDefault(),a.which==i.b||a.which==i.c?b._q(a.which):a.which==i.d?b._r():a.which==i.e?b._ac():(a.which>=i.A&&a.which<=i.Z||a.which==i.j)&&(f&&clearTimeout(f),e+=String.fromCharCode(a.which),b._s(e),f=setTimeout(function(){e=""},1e3))})},_q:function(a){var b=this.m.children(".highlight").first(),c=a==i.b?b.prev():b.next();c.length&&(c.hasClass("divider")&&(c=a==i.b?c.prev():c.next()),this._x(c),this._ad(c))},_r:function(){var a=this.m.children(".highlight").first();a.length&&this._ab(a)},_s:function(a){for(var b=0;b-1,h="+1"==c&&e.length>=4;if((!("1"==this.s.dialCode)||!this._isRegionlessNanp(e))&&(!g||h))for(var i=0;i-1}return!1},_x:function(a){this.o.removeClass("highlight"),a.addClass("highlight")},_y:function(a,b,c){for(var d=b?k:this.p,e=0;ef){b&&(j+=k);var l=d-g;c.scrollTop(j-l)}},_ae:function(a,b){var c,d=this.a.val();if(a="+"+a,"+"==d.charAt(0)){var e=this._af(d);c=e?d.replace(e,a):a}else{if(this.b.nationalMode||this.b.separateDialCode)return;if(d)c=a+d;else{if(!b&&this.b.autoHideDialCode)return;c=a}}this.a.val(c)},_af:function(b){var c="";if("+"==b.charAt(0))for(var d="",e=0;e