gglcptch_recaptcha_get_html

Gets the challenge HTML (javascript and non-javascript version).

Description

(string) gglcptch_recaptcha_get_html( (string) $pubkey, (constant) $error = null, (constant) $use_ssl = false ); 

This is called from the browser, and the resulting reCAPTCHA HTML widget is embedded within the HTML form it was called from.

Returns (string)

- The HTML to be embedded in the user's form.

Parameters (3)

0. $pubkey (string)
A public key for reCAPTCHA
1. $error — Optional. (constant) => null
The error given by reCAPTCHA (optional, default is null)
2. $use_ssl — Optional. (constant) => false
Should the request be made over ssl? (optional, default is false)

Usage

  1. if ( !function_exists( 'gglcptch_recaptcha_get_html' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-captcha-recaptcha-by-bestwebsoft/lib/recaptchalib.php'; 
  3.  
  4. // A public key for reCAPTCHA 
  5. $pubkey = ''; 
  6.  
  7. // The error given by reCAPTCHA (optional, default is null) 
  8. $error = null; 
  9.  
  10. // Should the request be made over ssl? (optional, default is false) 
  11. $use_ssl = false; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = gglcptch_recaptcha_get_html($pubkey, $error, $use_ssl); 
  15.  

Defined (1)

The function is defined in the following location(s).

/lib/recaptchalib.php  
  1. function gglcptch_recaptcha_get_html ($pubkey, $error = null, $use_ssl = false) 
  2. if ($pubkey == null || $pubkey == '') { 
  3. die ("To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>"); 
  4.  
  5. if ($use_ssl) { 
  6. $server = "https://www.google.com/recaptcha/api"; 
  7. } else { 
  8. $server = "http://www.google.com/recaptcha/api"; 
  9.  
  10. $errorpart = ""; 
  11. if ($error) { 
  12. $errorpart = "&error=" . $error; 
  13. return '<noscript> 
  14. <iframe src="'. $server . '/noscript?k=' . $pubkey . $errorpart . '" height="300" width="320" frameborder="0"></iframe><br/> 
  15. <textarea name="recaptcha_challenge_field" rows="3" cols="40" style="width: 320px !important; border: 1px solid #333 !important; resize: none !important;"></textarea> 
  16. <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/> 
  17. </noscript>';