Chèn số cờ nước vào số điện thoại contact 7 không dùng Plugin

admin09/03/2024 263

Bạn đang muốn chèn cờ và tên nước vào trường điện thoại của contact 7 giống như hình dưới.

Vui lòng copy đoạn code sau vào file function:

function chen_css_js_phone_country() {
wp_enqueue_style( 'nb-intlTelInput-style', 'https://abweb.vn/wp-content/themes/flatsome-child/tools/contact7-flag/flag.css' );
wp_enqueue_script( 'nb-intlTelInput-script','https://abweb.vn/wp-content/themes/flatsome-child/tools/contact7-flag/flag.js', array( 'jquery' ) ); 
}
add_action( 'wp_enqueue_scripts', 'chen_css_js_phone_country' );
function custom_js_phone_country(){
?>
<script>(function($) {
$(function() {
$(".wpcf7-tel").intlTelInput({
autoPlaceholder: "off",
hiddenInput: "full_number",
nationalMode: false,
placeholderNumberType: "MOBILE",
geoIpLookup: function(callback) {
$.get("https://ipinfo.io", function() {}, "jsonp").always(function(resp) {
var countryCode = (resp && resp.country) ? resp.country : "";
callback(countryCode);
});
},
initialCountry: "auto",

});
});
})(jQuery);
</script> 
<?php 
}
add_action('wp_footer','custom_js_phone_country');

 

Nếu bạn lười không muốn copy code này thì có thể dùng plugin mình đóng gói tại đây(tí viết xong uplên):

 

Hỏi đáp

Bài viết mới nhất
admin05/05/2024 69
admin05/05/2024 30
admin30/04/2024 67
admin26/03/2024 145
admin09/03/2024 263
admin20/02/2024 216
admin19/02/2024 585
admin18/02/2024 497
Chia sẻ mới nhất
admin09/03/2024 263
admin20/02/2024 216
admin19/02/2024 585
admin18/02/2024 497
admin01/02/2024 274
admin31/01/2024 221
admin21/01/2024 224
admin21/01/2024 225
admin18/01/2024 277
admin16/01/2024 224