1+(function($) { 2 3 "use strict"; 4 5 // Country & Phone Field Contact Form 7 by Narinder Singh Bisht 6 function wpbPcfCountryAndPhoneField(){ 7 if (typeof $.fn.countrySelect === "function" ) { 8 $(".wpcf7-countrytext").countrySelect(); 9 } 10 11 if (typeof $.fn.intlTelInput === "function" ) { 12 $(".wpcf7-phonetext").intlTelInput({ 13 autoPlaceholder: "off", 14 hiddenInput: "full_number", 15 nationalMode: false, 16 }); 17 } 18 } 19 20 /** 21 * WPCF7 Cloudflare Turnstile Support 22 */ 23 function pcfTurnstileSupport(popupEl) { 24 // Wait a short moment for the DOM to render 25 setTimeout(function () { 26 // Check if Cloudflare Turnstile is loaded 27 if (typeof turnstile !== "undefined") { 28 // === Contact Form 7 Support === 29 $(popupEl) 30 .find(".wpcf7-turnstile, .cf-turnstile") 31 .each(function () { 32 var el = this; 33 34 // Clean up any existing widget first 35 var $el = $(el); 36 if ($el.find("iframe").length) { 37 // Remove existing iframe/widget 38 $el.empty(); 39 } 40 41 // Clear any existing widget ID 42 if ($el.data("turnstile-widget-id")) { 43 try { 44 turnstile.remove( 45 $el.data("turnstile-widget-id") 46 ); 47 } catch (e) { 48 console.log("Turnstile widget removal skipped"); 49 } 50 $el.removeData("turnstile-widget-id"); 51 } 52 53 var siteKey = 54 $el.data("sitekey") || $el.attr("data-sitekey"); 55 56 // Render the Turnstile widget 57 var widgetId = turnstile.render(el, { 58 sitekey: siteKey, 59 theme: "auto", 60 callback: function (token) { 61 console.log("Turnstile verified"); 62 }, 63 }); 64 65 // Store widget ID for later cleanup 66 $el.data("turnstile-widget-id", widgetId); 67 }); 68 } 69 }, 200); // slight delay to ensure form HTML is ready 70 } 71 72 /** 73 * Reset Turnstile widgets 74 */ 75 function resetTurnstile(container) { 76 if (typeof turnstile === "undefined") return; 77 78 $(container) 79 .find(".wpcf7-turnstile, .cf-turnstile") 80 .each(function () { 81 var widgetId = $(this).data("turnstile-widget-id"); 82 if (widgetId !== undefined) { 83 try { 84 turnstile.reset(widgetId); 85 } catch (e) { 86 console.log("Turnstile reset failed:", e); 87 } 88 } 89 }); 90 } 91 // Handle validation errors and spam detection 92 $(document).on("wpcf7invalid wpcf7spam wpcf7mailfailed", function (event) { 93 if ($(event.target).closest(".swal2-popup").length) { 94 // Reset Turnstile on error 95 setTimeout(function () { 96 resetTurnstile(event.target); 97 }, 100); 98 } 99 }); 100 101 /** 102 * Clean existing Turnstile before moving form 103 */ 104 function cleanTurnstileBeforeMove(container) { 105 if (typeof turnstile === "undefined") return; 106 107 $(container) 108 .find(".wpcf7-turnstile, .cf-turnstile") 109 .each(function () { 110 var $el = $(this); 111 112 // Remove iframe 113 $el.find("iframe").remove(); 114 115 // Remove widget ID if exists 116 var widgetId = $el.data("turnstile-widget-id"); 117 if (widgetId !== undefined) { 118 try { 119 turnstile.remove(widgetId); 120 } catch (e) { 121 console.log("Turnstile removal skipped"); 122 } 123 $el.removeData("turnstile-widget-id"); 124 } 125 126 // Clear the container 127 $el.empty(); 128 }); 129 } 130 131 // Trigger the popup on click 132 $(document).on("click", ".wpb-pcf-form-fire", function(e) { 133 134 e.preventDefault(); 135 136 var button = $(this), 137 id = button.attr('data-id'), 138 post_id = button.attr('data-post_id'), 139 form_style = button.attr('data-form_style') ? !0 : !1, 140 allow_outside_click = button.attr('data-allow_outside_click') ? !0 : !1, 141 width = button.attr('data-width'), 142 popup_type = button.attr('data-popup_type'); 143 144 145 if (popup_type === "on_page_load") { 146 // Get the actual form element (not clone) 147 var formElement = $('.wpb-pcf-popup-content[data-id="' + id + '"]') 148 .first() 149 .find(".wpcf7"); 150 var originalParent = formElement.parent(); 151 152 // Clean existing Turnstile before moving 153 cleanTurnstileBeforeMove(formElement); 154 155 Swal.fire({ 156 html: '<div id="wpb-pcf-swal-form-wrapper"></div>',
157 showConfirmButton: false, 158 customClass: { 159 container: 'wpb-pcf-form-style-' + form_style, 160 }, 161 padding: '30px', 162 width: width, 163 showCloseButton: true, 164 allowOutsideClick: allow_outside_click, 165 backdrop: true, 166 didOpen: (popupEl) => { 167 // Move the actual initialized form into the popup 168 $("#wpb-pcf-swal-form-wrapper").append(formElement); 169 pcfTurnstileSupport(popupEl); 170 }, 171 willClose: () => { 172 // Clean Turnstile before moving back 173 cleanTurnstileBeforeMove(formElement); 174 175 // Move the form back to its original location 176 originalParent.append(formElement); 177 }, 178 }); 179 } else { 180 wp.ajax.send( { 181 data: { 182 action : 'wpb_pcf_fire_contact_form', 183 pcf_form_id : id, 184 wpb_pcf_post_id : post_id, 185 wpb_pcf_fire_popup_nonce: WPB_PCF_Vars.nonce 186 }, 187 beforeSend : function ( xhr ) { 188 button.addClass('wpb-pcf-btn-loading'); 189 }, 190 success: function( res ) { 191 button.removeClass('wpb-pcf-btn-loading'); 192 193 Swal.fire({ 194 html: res,
195 showConfirmButton: false, 196 customClass: { 197 container: 'wpb-pcf-form-style-' + form_style, 198 }, 199 padding: '30px', 200 width: width, 201 showCloseButton: true, 202 allowOutsideClick: allow_outside_click, 203 backdrop: true, 204 }); 205 206 // For CF7 5.3.1 and before 207 if ( typeof wpcf7.initForm === 'function' ) { 208 wpcf7.initForm( $('.wpcf7-form') ); 209 } 210 211 // For CF7 5.4 and after 212 if ( typeof wpcf7.init === 'function' ) { 213 document.querySelectorAll(".wpb-pcf-wpcf7-form > .wpcf7 > form").forEach(function (e) { 214 wpcf7.init(e); 215 }); 216 } 217 218 // Add support for - Simple Cloudflare Turnstile â CAPTCHA Alternative 219 if( typeof turnstile !== "undefined" ){ 220 221 var cf_turnstile_id = $($.parseHTML(res)).find('.cf-turnstile').attr('id'); 222 if (document.getElementById(cf_turnstile_id)) { 223 setTimeout(function() { 224 turnstile.render('#' + cf_turnstile_id); 225 }, 10); 226 } 227 } 228 229 // Add support for - Drag and Drop Multiple File Upload â Contact Form 7 230 if( typeof initDragDrop === "function" ){ 231 window.initDragDrop(); 232 } 233 234 // ReCaptcha v2 for Contact Form 7 - By IQComputing 235 if( typeof recaptchaCallback === "function" ){ 236 recaptchaCallback(); 237 } 238 239 // Add support for - Conditional Fields for Contact Form 7 240 if ( typeof wpcf7cf !== 'undefined' ) { 241 wpcf7cf.initForm( $('.wpcf7-form') ); 242 } 243 244 // Add post ID to the popup form 245 $("[name='_wpcf7_container_post']").val( post_id ); 246 247 // Country & Phone Field Contact Form 7 by Narinder Singh Bisht 248 wpbPcfCountryAndPhoneField(); 249 250 // WP Armour â Honeypot Anti Spam By Dnesscarkey. 251 if (typeof wpa_add_honeypot_field == 'function') { 252 wpa_add_honeypot_field(); 253 } 254 255 // WP Armour PRO â Honeypot Anti Spam By Dnesscarkey. 256 if (typeof wpae_add_honeypot_field == 'function') { // IF EXTENDED version exists. 257 wpae_add_honeypot_field(); 258 } 259 260 // Adding any custom JS code on form init 261 if( typeof wpb_pcf_on_cf7_form_init === "function" ){ 262 wpb_pcf_on_cf7_form_init(); 263 } 264 265 }, 266 error: function(error) { 267 alert( error ); 268 } 269 }); 270 } 271 }); 272 273})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.