ngd_recaptcha plugin for TextPattern
If you don’t know what a reCAPTCHA is or the difference from a regular CAPTCHA and want all the details, visit http://recaptcha.net/.
[…waits while you do that…]
All clear? Great!
This plugin implements reCAPTCHA for TextPattern comments. When a visitor submits a comment they’ll have to solve a reCAPTCHA on the comments preview. If the preview is not solved after the maximum number of attempts, then the comment is sent to the comment moderation queue.
If you want to use the Mailhide functions, click here to get your reCAPTCHA Mailhide keys if you need them.
Install the plugin and turn it on.
Go to your advanced preferences tab (admin -> preferences -> advanced preferences).
At the bottom you’ll see a section labeled ‘reCAPTCHA’. Fill in the values as follows:
- reCAPTCHA for comments enabled [ngd_recaptcha_enabled]
- Select yes to enable reCAPTCHA for comments. This allows you to disable reCAPTCHA without taking all the tags out of your code. This does not affect the Mailhide functions.
- reCAPTCHA max tries [ngd_recaptcha_max_tries]
- Maximum validation attempts. Defaults to 3.
- reCAPTCHA failure action [ngd_recaptcha_max_try_action]
- Failed comments are sent to the moderation queue. Set to SPAM to additionally mark them as spam.
- reCAPTCHA public key [ngd_recaptcha_publickey]
- The public key for your site that you got a few steps back.
- reCAPTCHA private key [ngd_recaptcha_privatekey]
- Ditto, but strike public, insert private.
- reCAPTCHA Mailhide public key [ngd_recaptcha_mailhide_publickey]
- The reCAPTCHA Mailhide public key. Only needed if want to you want to use the Mailhide functions.
- reCAPTCHA Mailhide private key [ngd_recaptcha_mailhide_privatekey]
- Ditto, but strike public, insert private.
- Display reCAPTCHA debug messages [ngd_recaptcha_debug]
- Turn this off for production sites, but if you are having issues, this will print out a debug message where the reCAPTCHA image or Mailhide should show (missing lib, keys, etc). Note: Incorrect keys will cause an error to display regardless of these settings. If anyone reallllly has a problem with that, let me know (not promising to do anything about it tho).
- reCAPTCHA tabindex [ngd_recaptcha_tabindex] (v1.1)
- Adds a tabindex to the input field, for accessibility goodness
- reCAPTCHA lang [ngd_recaptcha_lang] (v1.1)
- Set the language for your reCAPTCHA. As of this writing, supported languages are: English, Dutch, French, German, Portuguese, Russian, Spanish, Turkish.
If you need another language you can use custom theming to accomplish that.
- reCAPTCHA theme [red | white | blackglass | clean | custom] (v1.1)
- The reCAPTCHA theme you would like to use. Defaults to red.
I think they are pretty self-explanatory- red is red, white is white, blackglass is
purple with cow imagesblack/grey. The clean theme is transparent. – (btw gTxt turns ‘clean’ into \clean\ at least on my install – I know but want it translatable, so it’s not a bug).
See details on custom theming below.
- reCAPTCHA custom theme widget ID [ngd_recaptcha_custom_theme_widget] (v1.1)
- A unique DOM id used for display of the widget. Used in conjunction with custom theming (see below)
Save your preferences and test it out. If it doesn’t work, try turning the debug option on. If you still cannot get it to work, disable it and report the problems.
That’s it! Enjoy your newfound security and the warm fuzzy that comes with helping a good cause.
You can find out more about the reCAPTCHA Mailhide here.
- 0: returns the url only.
- 1: returns a link (default).
- You can also pass the privatekey along here if you prefer.
- You can also pass the publickey along here if you prefer.
Custom Theming (v1.1+)
If you don’t like the standard themes, you can now use reCAPTCHA’s custom theme settings to style the display to your site.
Important: If you use a custom theme you must declare a custom theme widget id and call
<txp:ngd_recaptcha_get_html /> after that element in your comment.
Details are available on the reCAPTCHA site, so I won’t go into them here, but here’s the basic form you would put into your comment template:
|<div id="recaptcha_tag" style="display:none;">|
|<p class="recaptcha_only_if_incorrect_sol" style="color:red"><txp:text item="Incorrect please try again" /></p>|
|<span class="recaptcha_only_if_image"><txp:text item="Enter the words above:" /></span>|
|<span class="recaptcha_only_if_audio"><txp:text item="Enter the numbers you hear:" /></span>|
|<input type="text" id="recaptcha_response_field" name="recaptcha_response_field" />|
The only known issue is if you want to totally uninstall the plugin. This plugin adds some records to your txp_prefs table. If you don’t care if they stay there and you still see the reCAPTCHA settings in your preferences, do nothing. Otherwise, use PHPMyAdmin or the Textpattern db_manager plugin or whatever other program you like and run this query: DELETE FROM txp_prefs WHERE name LIKE ‘ngd_recaptcha_%’ (you may need to add your table prefix if you use one). If that sentence made no sense to you, I suggest you just live with the change rather than attempt something you aren’t familiar with-leaving the records does no harm.
I used the asy_captcha plugin by Sencer Yurdagul as a model.