Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
0.4.0 update.
Browse files Browse the repository at this point in the history
git-svn-id: https://plugins.svn.wordpress.org/funcaptcha/trunk@791680 b8457f37-d9ea-0310-8a92-e5e31aec5664
  • Loading branch information
SwipeAds authored and SwipeAds committed Oct 22, 2013
1 parent adc5c31 commit ceaf807
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 15 deletions.
2 changes: 1 addition & 1 deletion funcaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class FUNCAPTCHA {
protected $funcaptcha_challenge_url = '';
protected $funcaptcha_debug = FALSE;
protected $funcaptcha_api_type = "wp";
protected $funcaptcha_plugin_version = "0.3.19";
protected $funcaptcha_plugin_version = "0.4.0";
protected $funcaptcha_security_level = 0;
protected $session_token;

Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: swipeads
Tags: captcha, antispam, comment, login, registration captcha, contact form 7 captcha, gravity forms captcha, buddypress CAPTCHA, spam blocking CAPTCHA, CAPTCHA plugin
Requires at least: 2.8.0
Tested up to: 3.6.1
Stable tag: 0.3.19
Stable tag: 0.4.0

Stop spam with a fun, fast mini-game CAPTCHA! FunCaptcha is free, and works on every desktop and mobile device. For BuddyPress, Gravity Forms, CF7.

Expand Down Expand Up @@ -136,6 +136,9 @@ For a full list of frequently asked questions, please see our [FAQ page](http://

== Changelog ==

= 0.4.0 =
* Support for wordpress multisite registration forms.

= 0.3.19 =
* Made more clear the service connects to the funcaptcha API servers to verify solves.

Expand Down
83 changes: 70 additions & 13 deletions wp_funcaptcha.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?php
/**
* @package FunCaptcha
* @version 0.3.19
* @version 0.4.0
*/
/*
Plugin Name: FunCaptcha
Plugin URI: http://wordpress.org/extend/plugins/funcaptcha/
Description: Stop spammers with a fun, fast mini-game! FunCaptcha is free, and works on every desktop and mobile device.
Author: SwipeAds
Author URI: http://funcaptcha.co/
Version: 0.3.19
Version: 0.4.0
*/


define('FUNCAPTCHA_VERSION', '0.3.19');
define('FUNCAPTCHA_VERSION', '0.4.0');
define('PLUGIN_BASENAME', plugin_basename(__FILE__));
define('FUNCAPTCHA_SETTINGS_URL', 'funcaptcha');
if ( ! defined( 'PLUGIN_PATH' ) ) {
Expand Down Expand Up @@ -61,24 +61,30 @@ function funcaptcha_init() {

// If register_form is set in the options, attach to the register hooks
if( $funcaptcha_options['register_form'] ) {
if (BP_INSTALLED) {
add_action('bp_before_registration_submit_buttons', 'funcaptcha_register_form_bp');
add_action('bp_signup_validate', 'funcaptcha_register_post_bp');
if (is_multisite()) {
if (BP_INSTALLED) {
add_action('bp_before_registration_submit_buttons', 'funcaptcha_register_form_bp');
add_action('bp_signup_validate', 'funcaptcha_register_post_wpmu');
} else {
add_action( 'signup_extra_fields', 'funcaptcha_register_form_wpmu' );
add_filter( 'wpmu_validate_user_signup', 'funcaptcha_register_post_wpmu' );
}
} else {
if (BP_INSTALLED) {
add_action('bp_before_registration_submit_buttons', 'funcaptcha_register_form_bp');
add_action('bp_signup_validate', 'funcaptcha_register_post_bp');
} else {
add_action('register_form', 'funcaptcha_register_form');
add_action('register_post', 'funcaptcha_register_post', 10, 3);
}
}
add_action('register_form', 'funcaptcha_register_form');
add_action('register_post', 'funcaptcha_register_post', 10, 3);
}

if( $funcaptcha_options['login_form'] ) {
add_action('login_form', 'funcaptcha_login_form');
add_filter('authenticate', 'funcaptcha_login_post', 10, 3);
}

if( $funcaptcha_options['register_form'] ) {
add_action('register_form', 'funcaptcha_register_form');
add_action('register_post', 'funcaptcha_register_post', 10, 3);
}

// If password_form is set in the options, attach to the lost password hooks
if( $funcaptcha_options['password_form'] ) {
add_action('lostpassword_form', 'funcaptcha_lost_password_form');
Expand Down Expand Up @@ -716,6 +722,37 @@ function funcaptcha_register_form() {
return true;
}

/**
* display funcaptcha in registration form for multi-sites
*
* @return boolean
*/
function funcaptcha_register_form_wpmu($errors) {
$funcaptcha = funcaptcha_API();
$options = funcaptcha_get_settings();
$error = $errors->get_error_message('funcaptcha_incorrect');
$html = $funcaptcha->getFunCaptcha($options['public_key']);
switch ($options['align']) {
case "left" :
$style = "text-align: left;";
break;
case "right" :
$style = "text-align: right;";
break;
case "center" :
$style = "text-align: center;";
break;
}
if ($error) {
echo '<p class="error">' . $error . '</p>';
}
echo "<div id='funcaptcha-wrapper' style='" . $style . "'>" . $html . "</div>";
echo funcaptcha_resize_mobile();
return true;
}



/**
* display funcaptcha in registration form
*
Expand Down Expand Up @@ -744,6 +781,26 @@ function funcaptcha_register_form_bp() {
return true;
}




/**
* validates registration funcaptcha for multi-site setup
*
* @return array
*/
function funcaptcha_register_post_wpmu($results) {
$funcaptcha = funcaptcha_API();
$options = funcaptcha_get_settings();

if ( $funcaptcha->checkResult($options['private_key']) ) {
return( $results );
} else {
$results['errors']->add('funcaptcha_incorrect', '<strong>'.__('ERROR', 'funcaptcha').'</strong>: '.__(htmlentities($options['error_message']), 'funcaptcha'));
}
return( $results );
}

/**
* validates registration funcaptcha
*
Expand Down

0 comments on commit ceaf807

Please sign in to comment.