Skip to content

Commit

Permalink
Merge pull request #30 from wpdev10/master
Browse files Browse the repository at this point in the history
Changes for releasing 1.0.5
  • Loading branch information
wpdev10 authored Jun 28, 2019
2 parents 822723a + a8e7a5a commit cfd2dde
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 70 deletions.
7 changes: 7 additions & 0 deletions includes/class-uwp-recaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ public function recaptcha_key_notices() {
}

public function add_captcha_for_uwp_forms($type){
if(!uwp_recaptcha_enabled()){
return;
}
$enable_register_form = uwp_get_option('enable_recaptcha_in_register_form');
$enable_login_form = uwp_get_option('enable_recaptcha_in_login_form');
$enable_forgot_form = uwp_get_option('enable_recaptcha_in_forgot_form');
Expand Down Expand Up @@ -195,6 +198,10 @@ public function validate_recaptcha($result, $type, $data) {
return $result;
}

if ( uwp_recaptcha_check_role() ) { // disable captcha as per user role settings
return $result;
}

if(!uwp_recaptcha_enabled() || 1 != uwp_get_option('enable_recaptcha_in_'.$type.'_form') || is_wp_error($result)){
return $result;
}
Expand Down
10 changes: 9 additions & 1 deletion includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function uwp_recaptcha_check_role() {
global $current_user;
$role = !empty( $current_user ) && isset( $current_user->roles[0] ) ? $current_user->roles[0] : '';

if ( $role != '' && ((int)uwp_get_option('disable_recaptcha_role_' . $role, 0) == 1 || in_array($role, uwp_get_option('disable_recaptcha_role_for', false)) )) { // disable captcha
if ( $role != '' && ((int)uwp_get_option('disable_recaptcha_role_' . $role, 0) == 1 || in_array($role, uwp_get_option('disable_recaptcha_role_for', array())) )) { // disable captcha
return true;
}
else { // enable captcha
Expand Down Expand Up @@ -178,6 +178,10 @@ function uwp_recaptcha_display( $form ) {

function uwp_recaptcha_check( $form ) {

if ( uwp_recaptcha_check_role() ) { // disable captcha as per user role settings
return '';
}

$secret_key = uwp_get_option('recaptcha_api_secret', '');
$remote_addr = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP );
$response = uwp_recaptcha_get_response( $secret_key, $remote_addr );
Expand Down Expand Up @@ -252,6 +256,10 @@ function uwp_recaptcha_enabled(){
}

function uwp_recaptcha_get_response( $privatekey, $remote_ip ) {
if(empty($_POST["g-recaptcha-response"])){
return array('success' => false, 'error-codes' => 'missing-input-secret');
}

$args = array(
'body' => array(
'secret' => $privatekey,
Expand Down
Binary file modified languages/uwp-recaptcha-en_US.mo
Binary file not shown.
156 changes: 90 additions & 66 deletions languages/uwp-recaptcha-en_US.po
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
msgid ""
msgstr ""
"Project-Id-Version: UsersWP - ReCaptcha 1.0.4\n"
"Project-Id-Version: UsersWP - ReCaptcha 1.0.5\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-02 19:42+0530\n"
"PO-Revision-Date: 2019-05-02 19:43+0530\n"
"POT-Creation-Date: 2019-06-28 12:01+0530\n"
"PO-Revision-Date: 2019-06-28 12:01+0530\n"
"Last-Translator: \n"
"Language-Team: AyeCode <[email protected]>\n"
"Language: en_US\n"
Expand All @@ -27,165 +27,189 @@ msgid "ReCaptcha Settings"
msgstr ""

#: admin/settings.php:27
msgid "Google ReCaptcha API Key"
msgid "ReCaptcha version"
msgstr ""

#: admin/settings.php:28
msgid ""
"Select the ReCaptcha version. <b style=\"color: red;\">Heads Up! V2, V3 and "
"invisible recaptcha has different keys. So use keys based on version you "
"select here.</b>"
msgstr ""

#: admin/settings.php:32
msgid "Select Option"
msgstr ""

#: admin/settings.php:38
msgid "Google ReCaptcha API Key"
msgstr ""

#: admin/settings.php:39
msgid ""
"Enter Re-Captcha site key that you get after site registration at <a target="
"\"_blank\" href=\"https://www.google.com/recaptcha/admin#list\">here</a>."
"\"_blank\" href=\"https://www.google.com/recaptcha/admin#list\">here</a>. "
"Recaptcha V2 and V3 has different API key."
msgstr ""

#: admin/settings.php:31
#: admin/settings.php:42
msgid "Enter Google ReCaptcha API Key"
msgstr ""

#: admin/settings.php:36
#: admin/settings.php:47
msgid "Google ReCaptcha API Secret"
msgstr ""

#: admin/settings.php:37
#: admin/settings.php:48
msgid ""
"Enter Re-Captcha secret key that you get after site registration at <a "
"target=\"_blank\" href=\"https://www.google.com/recaptcha/admin#list\">here</"
"a>"
"a>. Recaptcha V2 and V3 has different API secret"
msgstr ""

#: admin/settings.php:40
#: admin/settings.php:51
msgid "Enter Google ReCaptcha API Secret"
msgstr ""

#: admin/settings.php:45
msgid "ReCaptcha version"
#: admin/settings.php:56
msgid "Minimum verification score"
msgstr ""

#: admin/settings.php:46
#: admin/settings.php:57
msgid ""
"Select the ReCaptcha version. <b style=\"color: red;\">Heads Up! V2 keys "
"will not work with invisible recaptcha, you will have to create new ones.</b>"
msgstr ""

#: admin/settings.php:50
msgid "Select Option"
"Set the minimum verification score from 0 to 1 (for Recaptcha V3 only). See "
"more <a target=\"_blank\" href=\"https://developers.google.com/recaptcha/"
"docs/v3#score\">here</a>"
msgstr ""

#: admin/settings.php:56
#: admin/settings.php:70
msgid "Enable ReCaptcha in"
msgstr ""

#: admin/settings.php:57
msgid "UsersWP Register Form."
#: admin/settings.php:71
msgid "UsersWP Register Form"
msgstr ""

#: admin/settings.php:65
msgid "UsersWP Login Form."
#: admin/settings.php:79
msgid "UsersWP Login Form"
msgstr ""

#: admin/settings.php:73
msgid "UsersWP Forgot Form."
#: admin/settings.php:87
msgid "UsersWP Forgot Form"
msgstr ""

#: admin/settings.php:81
msgid "UsersWP Account Form."
#: admin/settings.php:95
msgid "UsersWP Account Form"
msgstr ""

#: admin/settings.php:89
msgid "WP Login Form."
#: admin/settings.php:103
msgid "WordPress Login Form"
msgstr ""

#: admin/settings.php:97
msgid "WP Register Form."
#: admin/settings.php:111
msgid "WordPress Registeration Form"
msgstr ""

#: admin/settings.php:118
#: admin/settings.php:132
msgid "Disable reCAPTCHA for"
msgstr ""

#: admin/settings.php:119
#: admin/settings.php:133
msgid "Select the roles to disable ReCaptcha for."
msgstr ""

#: admin/settings.php:123
#: admin/settings.php:137
msgid "Select Roles"
msgstr ""

#: admin/settings.php:131
#: admin/settings.php:145
msgid "Captcha Title"
msgstr ""

#: admin/settings.php:132
#: admin/settings.php:146
msgid "Captcha title to be displayed above captcha code, leave blank to hide."
msgstr ""

#: admin/settings.php:140
#: admin/settings.php:154
msgid "ReCaptcha Theme"
msgstr ""

#: admin/settings.php:141
#: admin/settings.php:155
#, php-format
msgid "Select color theme of captcha widget. %sLearn more%s"
msgstr ""

#: admin/settings.php:145
#: admin/settings.php:159
msgid "Light"
msgstr ""

#: admin/settings.php:146
#: admin/settings.php:160
msgid "Dark"
msgstr ""

#: admin/settings.php:163
#: admin/settings.php:177
msgid "UsersWP - Recaptcha"
msgstr ""

#: admin/settings.php:164
#: admin/settings.php:178
msgid "Remove all data when deleted?"
msgstr ""

#: admin/settings.php:175
#: admin/settings.php:189
msgid "ReCaptcha V3"
msgstr ""

#: admin/settings.php:190
msgid "ReCaptcha V2"
msgstr ""

#: admin/settings.php:176
#: admin/settings.php:191
msgid "Invisible ReCaptcha"
msgstr ""

#: includes/class-uwp-recaptcha.php:157 includes/class-uwp-recaptcha.php:181
msgid "<strong>ERROR</strong>: reCAPTCHA verification failed. Try again."
#: includes/class-uwp-recaptcha.php:140
#, php-format
msgid ""
"UsersWP ReCaptcha addon: API Key and API Secret not set. %sclick here%s to "
"set one."
msgstr ""

#: includes/functions.php:121
#: includes/class-uwp-recaptcha.php:142
#, php-format
msgid ""
"To use reCAPTCHA you must get an API key from <a target=\"_blank\" href="
"\"https://www.google.com/recaptcha/admin\">here</a> and enter keys in the "
"plugin settings page at <a target=\"_blank\" href=\"%s\">here</a>"
msgid "UsersWP ReCaptcha addon: API Key not set. %sclick here%s to set one."
msgstr ""

#: includes/functions.php:123
#: includes/class-uwp-recaptcha.php:144
#, php-format
msgid "UsersWP ReCaptcha addon: API Secret not set. %sclick here%s to set one."
msgstr ""

#: includes/functions.php:191
msgid ""
"<strong>Error</strong>: Something went wrong. Please contact site admin."
"<strong>ERROR</strong>: reCAPTCHA verification failed. Please try again."
msgstr ""

#: includes/functions.php:143
msgid "<strong>Error</strong>: reCAPTCHA verification failed. Try again."
#: includes/functions.php:208
msgid ""
"<strong>reCAPTCHA ERROR</strong>: The secret parameter is missing or "
"invalid. Please try again."
msgstr ""

#: includes/functions.php:328
#, php-format
#: includes/functions.php:212
msgid ""
"UsersWP ReCaptcha addon: API Key and API Secret not set. %sclick here%s to "
"set one."
"<strong>reCAPTCHA ERROR</strong>: The response parameter is missing or "
"invalid. Please try again."
msgstr ""

#: includes/functions.php:330
#, php-format
msgid "UsersWP ReCaptcha addon: API Key not set. %sclick here%s to set one."
#: includes/functions.php:215
msgid ""
"<strong>reCAPTCHA ERROR</strong>: The request is invalid. Please try again."
msgstr ""

#: includes/functions.php:332
#, php-format
msgid "UsersWP ReCaptcha addon: API Secret not set. %sclick here%s to set one."
#: includes/functions.php:218
msgid ""
"<strong>reCAPTCHA ERROR</strong>: The response is no longer valid: either is "
"too old or has been used previously. Please try again."
msgstr ""

#: uwp_recaptcha.php:36
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: http://userswp.io/
Tags: recaptcha, frontend, login, register, account, users, restrict, userswp
Requires at least: 4.9
Tested up to: 5.2
Stable tag: 1.0.4
Stable tag: 1.0.5
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html

Expand Down
4 changes: 2 additions & 2 deletions uwp_recaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: UsersWP - ReCaptcha
Plugin URI: https://userswp.io
Description: ReCaptcha add-on for UsersWP.
Version: 1.0.4
Version: 1.0.5
Author: AyeCode Ltd
Author URI: https://userswp.io
License: GPL-2.0+
Expand All @@ -16,7 +16,7 @@
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;

define( 'UWP_RECAPTCHA_VERSION', '1.0.4' );
define( 'UWP_RECAPTCHA_VERSION', '1.0.5' );

define( 'UWP_RECAPTCHA_PATH', plugin_dir_path( __FILE__ ) );

Expand Down

0 comments on commit cfd2dde

Please sign in to comment.