@@ -34,7 +34,7 @@ function influactive_form_shortcode_handler(array $atts): bool|string
3434 $ form_id = (int )$ atts ['id ' ];
3535
3636 if (!$ form_id ) {
37- throw new RuntimeException ("Form ID not found. Exiting... " );
37+ throw new RuntimeException ("Form ID not found. Exiting... " );
3838 }
3939
4040 // Showing the form if it exists
@@ -121,16 +121,16 @@ function influactive_form_shortcode_handler(array $atts): bool|string
121121function enqueue_form_dynamic_style (): void
122122{
123123 if (is_admin ()) {
124- throw new RuntimeException ("WordPress environment not loaded. Exiting... " );
124+ throw new RuntimeException ("WordPress environment not loaded. Exiting... " );
125125 }
126126
127127 $ form_id = get_post_meta (get_the_ID (), 'influactive_form_id ' , true ) ?? 0 ;
128128 if (!$ form_id ) {
129- throw new RuntimeException ("Form ID not found. Exiting... " );
129+ throw new RuntimeException ("Form ID not found. Exiting... " );
130130 }
131131
132132 // Enqueue du fichier dynamic-style.php
133- wp_enqueue_style ('influactive-form-dynamic-style ' , plugin_dir_url (__FILE__ ) . '/dynamic-style.php?post_id= ' . $ form_id , [], '1.2 ' );
133+ wp_enqueue_style ('influactive-form-dynamic-style ' , plugin_dir_url (__FILE__ ) . '/dynamic-style.php?post_id= ' . $ form_id , [], '1.2.1 ' );
134134}
135135
136136add_action ('wp_enqueue_scripts ' , 'enqueue_form_dynamic_style ' );
@@ -155,7 +155,7 @@ function influactive_send_email(): void
155155 if (empty ($ _POST ['form_id ' ])) {
156156 wp_send_json_error (['message ' => __ ('Form ID is required ' , 'influactive-forms ' )]);
157157
158- exit ;
158+ exit ;
159159 }
160160
161161 $ form_id = (int )$ _POST ['form_id ' ];
@@ -170,7 +170,7 @@ function influactive_send_email(): void
170170 $ message = sprintf (__ ('The field %s is required ' , 'influactive-forms ' ), $ name );
171171 wp_send_json_error (['message ' => $ message ]);
172172
173- exit ;
173+ exit ;
174174 }
175175 }
176176
@@ -182,51 +182,51 @@ function influactive_send_email(): void
182182 $ secret_site_key = $ options_captcha ['google-captcha ' ]['secret-site-key ' ] ?? '' ;
183183 $ public_site_key = $ _POST ['recaptcha_site_key ' ] ?? '' ;
184184
185- if (!empty ($ secret_site_key ) && !empty ($ public_site_key ) && isset ($ _POST ['recaptcha_response ' ])) {
186- $ recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify ' ;
187- $ recaptcha_response = $ _POST ['recaptcha_response ' ];
188-
189- $ url = $ recaptcha_url . '?secret= ' . urlencode ($ secret_site_key ) . '&response= ' . urlencode ($ recaptcha_response );
190-
191- $ ch = curl_init ();
192- curl_setopt ($ ch , CURLOPT_URL , $ url );
193- curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , 1 );
194- try {
195- $ response = curl_exec ($ ch );
196- if (curl_errno ($ ch )) {
197- throw new RuntimeException (curl_error ($ ch ));
198- }
199- } catch (Exception $ e ) {
200- wp_send_json_error ([
201- 'message ' => __ ('Failed to verify reCAPTCHA ' , 'influactive-forms ' ),
202- 'error ' => $ e ->getMessage (),
203- ]);
204- curl_close ($ ch );
205- exit ;
206- }
207- curl_close ($ ch );
208-
209- try {
210- $ recaptcha = json_decode ($ response , false , 512 , JSON_THROW_ON_ERROR );
211-
212- if ($ recaptcha ->score < 0.5 ) {
213- // Not likely to be a human
214- wp_send_json_error ([
215- 'message ' => __ ('Bot detected ' , 'influactive-forms ' ),
216- 'score ' => $ recaptcha ->score ,
217- ]);
218-
219- exit ;
220- }
221- } catch (JsonException $ e ) {
222- wp_send_json_error ([
223- 'message ' => __ ('Failed to verify reCAPTCHA ' , 'influactive-forms ' ),
224- 'error ' => $ e ->getMessage (),
225- ]);
226-
227- exit ;
228- }
229- }
185+ if (!empty ($ secret_site_key ) && !empty ($ public_site_key ) && isset ($ _POST ['recaptcha_response ' ])) {
186+ $ recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify ' ;
187+ $ recaptcha_response = $ _POST ['recaptcha_response ' ];
188+
189+ $ url = $ recaptcha_url . '?secret= ' . urlencode ($ secret_site_key ) . '&response= ' . urlencode ($ recaptcha_response );
190+
191+ $ ch = curl_init ();
192+ curl_setopt ($ ch , CURLOPT_URL , $ url );
193+ curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , 1 );
194+ try {
195+ $ response = curl_exec ($ ch );
196+ if (curl_errno ($ ch )) {
197+ throw new RuntimeException (curl_error ($ ch ));
198+ }
199+ } catch (Exception $ e ) {
200+ wp_send_json_error ([
201+ 'message ' => __ ('Failed to verify reCAPTCHA ' , 'influactive-forms ' ),
202+ 'error ' => $ e ->getMessage (),
203+ ]);
204+ curl_close ($ ch );
205+ exit ;
206+ }
207+ curl_close ($ ch );
208+
209+ try {
210+ $ recaptcha = json_decode ($ response , false , 512 , JSON_THROW_ON_ERROR );
211+
212+ if ($ recaptcha ->score < 0.5 ) {
213+ // Not likely to be a human
214+ wp_send_json_error ([
215+ 'message ' => __ ('Bot detected ' , 'influactive-forms ' ),
216+ 'score ' => $ recaptcha ->score ,
217+ ]);
218+
219+ exit ;
220+ }
221+ } catch (JsonException $ e ) {
222+ wp_send_json_error ([
223+ 'message ' => __ ('Failed to verify reCAPTCHA ' , 'influactive-forms ' ),
224+ 'error ' => $ e ->getMessage (),
225+ ]);
226+
227+ exit ;
228+ }
229+ }
230230
231231 $ layouts = $ email_layout ?? [];
232232 $ error = 0 ;
@@ -324,7 +324,7 @@ function influactive_send_email(): void
324324 'message ' => __ ('Failed to send email ' , 'influactive-forms ' ),
325325 ]);
326326
327- exit ;
327+ exit ;
328328 }
329329
330330 exit ;
0 commit comments