/includes/recaptcha.php

  1. <?php 
  2. function pmpro_init_recaptcha() 
  3. //don't load in admin 
  4. if(is_admin()) 
  5. return; 
  6.  
  7. //use recaptcha? 
  8. global $recaptcha; 
  9. $recaptcha = pmpro_getOption("recaptcha"); 
  10. if($recaptcha) 
  11. global $recaptcha_publickey, $recaptcha_privatekey; 
  12.  
  13. require_once(PMPRO_DIR . "/includes/lib/recaptchalib.php"); 
  14.  
  15. function pmpro_recaptcha_get_html ($pubkey, $error = null, $use_ssl = false) 
  16. $locale = get_locale(); 
  17. if(!empty($locale)) 
  18. $parts = explode("_", $locale); 
  19. $lang = $parts[0]; 
  20. else 
  21. $lang = "en"; 
  22.  
  23. //filter 
  24. $lang = apply_filters('pmpro_recaptcha_lang', $lang); 
  25. ?> 
  26. <div class="g-recaptcha" data-sitekey="<?php echo $pubkey;?>"></div> 
  27. <script type="text/javascript" 
  28. src="https://www.google.com/recaptcha/api.js?hl=<?php echo $lang;?>"> 
  29. </script> 
  30. <?php  
  31.  
  32. //for templates using the old recaptcha_get_html 
  33. if(!function_exists('recaptcha_get_html')) 
  34. function recaptcha_get_html($pubkey, $error = null, $use_ssl = false) 
  35. return pmpro_recaptcha_get_html($pubkey, $error, $use_ssl); 
  36.  
  37. $recaptcha_publickey = pmpro_getOption("recaptcha_publickey"); 
  38. $recaptcha_privatekey = pmpro_getOption("recaptcha_privatekey"); 
  39. add_action("init", "pmpro_init_recaptcha", 20); 
.