File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 529
529
530
530
var setupGooglereCaptcha = function ( evt , $forms , config )
531
531
{
532
+ if ( typeof grecaptcha !== typeof undefined ) {
533
+ throw new Error ( 'reCaptcha API can not be loaded by hand, delete reCaptcha API snippet.' ) ;
534
+ }
535
+
532
536
var src = '//www.google.com/recaptcha/api.js?onload=reCaptchaLoaded&render=explicit' + ( config . lang ? '&hl=' + config . lang : '' ) ;
533
537
if ( $ ( 'body' ) . find ( 'script[src="' + src + '"]' ) . length === 0 )
534
538
{
560
564
$ ( '[data-validation~="recaptcha"]' , $form ) . each ( function ( )
561
565
{
562
566
var $el = $ ( this ) ,
563
- div = document . createElement ( 'DIV' ) ;
567
+ div = document . createElement ( 'DIV' ) ,
568
+ sitekey = sitekey || $el . valAttr ( 'recaptcha-sitekey' ) ;
569
+
570
+ if ( ! sitekey ) {
571
+ throw new Error ( 'Google reCaptcha site key is required.' ) ;
572
+ }
564
573
565
574
$el . hide ( ) ;
566
575
$el . parent ( ) . append ( div ) ;
567
576
568
577
var widget_id = grecaptcha . render ( div , {
569
- sitekey : sitekey || $el . valAttr ( 'recaptcha-sitekey' ) ,
578
+ sitekey : sitekey ,
570
579
theme : theme || $el . valAttr ( 'recaptcha-theme' ) || 'light'
571
580
} ) ;
572
581
You can’t perform that action at this time.
0 commit comments