Skip to content

Commit

Permalink
Merge pull request #31 from wpdev10/master
Browse files Browse the repository at this point in the history
Settings reset to default all the time we activate plugin
  • Loading branch information
wpdev10 authored Jan 23, 2020
2 parents 54b949c + c943bd8 commit 6e99ee2
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 24 deletions.
77 changes: 77 additions & 0 deletions assets/js/captcha.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
var holderId;
jQuery(document).ready(function($) {
//uwp_init_recaptcha();
});

function uwp_init_recaptcha() {
if ( jQuery('.uwp-captcha-render').length) {

jQuery('.uwp-captcha-render').each(function() {
if(jQuery(this).html()==''){
var container = jQuery(this).attr('id');
if (container) {
try {
//uwp_display_captcha(container);
} catch(err) {
console.log(err);
}
}
}
});
}
}

function uwp_display_captcha(element){
try {
if(uwp_recaptcha_data.captcha_version == 'v3'){
grecaptcha.ready(
function() {
holderId = grecaptcha.execute(uwp_recaptcha_data.site_key, {action: 'uwp_captcha'}).then(function (token) {
document.getElementById(element).value = token;
});
}
);
} else if(uwp_recaptcha_data.captcha_version == 'invisible'){
grecaptcha.ready(
function() {
holderId = grecaptcha.render(element, {
'sitekey': uwp_recaptcha_data.site_key,
'size': 'invisible',
'badge': 'bottomright',
'callback': function (token) {
uwp_maybe_check_recaptcha(element);
}
});
}
);
} else {
holderId = grecaptcha.render(element , { 'sitekey' : uwp_recaptcha_data.site_key, 'theme' : uwp_recaptcha_data.captcha_theme, 'size' : uwp_recaptcha_data.captcha_size });
}
} catch(err) {
console.log(err);
}
}

function uwp_reset_captcha(element){
if(uwp_recaptcha_data.captcha_version == 'v3') {
if (typeof grecaptcha != 'undefined') {
holderId = grecaptcha.execute(uwp_recaptcha_data.site_key, {action: 'uwp_captcha'}).then(function (token) {
document.getElementById(element).value = token;
});
}

} else {
if (typeof grecaptcha != 'undefined') {
grecaptcha.reset(holderId);
}
}
}

function uwp_maybe_execute_captcha(element){
if(uwp_recaptcha_data.captcha_version == 'invisible') {
if (typeof grecaptcha != 'undefined') {
grecaptcha.execute(holderId);
}

}
}
43 changes: 30 additions & 13 deletions includes/activator.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,36 @@ public static function add_default_options() {

$settings = get_option( 'uwp_settings', array());

$settings['recaptcha_api_key'] = "";
$settings['recaptcha_api_secret'] = "";

$settings['enable_recaptcha_in_register_form'] = "1";
$settings['enable_recaptcha_in_login_form'] = "1";
$settings['enable_recaptcha_in_forgot_form'] = "1";
$settings['enable_recaptcha_in_account_form'] = "1";
$settings['enable_recaptcha_in_wp_login_form'] = "1";
$settings['enable_recaptcha_in_wp_register_form'] = "1";


$settings['recaptcha_title'] = "";
$settings['recaptcha_theme'] = "light";
if (!isset($settings['recaptcha_api_key'])) {
$settings['recaptcha_api_key'] = "";
}
if (!isset($settings['recaptcha_api_secret'])) {
$settings['recaptcha_api_secret'] = "";
}
if (!isset($settings['enable_recaptcha_in_register_form'])) {
$settings['enable_recaptcha_in_register_form'] = "1";
}
if (!isset($settings['enable_recaptcha_in_login_form'])) {
$settings['enable_recaptcha_in_login_form'] = "1";
}
if (!isset($settings['enable_recaptcha_in_forgot_form'])) {
$settings['enable_recaptcha_in_forgot_form'] = "1";
}
if (!isset($settings['enable_recaptcha_in_account_form'])) {
$settings['enable_recaptcha_in_account_form'] = "1";
}
if (!isset($settings['enable_recaptcha_in_wp_login_form'])) {
$settings['enable_recaptcha_in_wp_login_form'] = "1";
}
if (!isset($settings['enable_recaptcha_in_wp_register_form'])) {
$settings['enable_recaptcha_in_wp_register_form'] = "1";
}
if (!isset($settings['recaptcha_title'])) {
$settings['recaptcha_title'] = "";
}
if (!isset($settings['recaptcha_theme'])) {
$settings['recaptcha_theme'] = "light";
}

update_option( 'uwp_settings', $settings );

Expand Down
1 change: 0 additions & 1 deletion includes/class-uwp-recaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ public function activation_redirect()
public function admin_enqueue_scripts(){
if(1 == uwp_get_option('enable_recaptcha_in_wp_login_form') || 1 == uwp_get_option('enable_recaptcha_in_wp_register_form')){
$this->enqueue_scripts();
add_action('login_footer', array($this, 'add_scripts'));
}
}

Expand Down
Binary file modified languages/uwp-recaptcha-en_US.mo
Binary file not shown.
14 changes: 7 additions & 7 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.2.0\n"
"Project-Id-Version: UsersWP - ReCaptcha 1.2.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-10-30 16:00+0000\n"
"PO-Revision-Date: 2019-10-30 16:00+0000\n"
"POT-Creation-Date: 2020-01-23 19:46+0530\n"
"PO-Revision-Date: 2020-01-23 19:46+0530\n"
"Last-Translator: \n"
"Language-Team: AyeCode <[email protected]>\n"
"Language: en_US\n"
Expand All @@ -15,7 +15,7 @@ msgstr ""
"X-Poedit-Basepath: ..\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Generator: Poedit 1.8.7.1\n"
"X-Generator: Poedit 2.2.1\n"
"X-Poedit-SearchPath-0: .\n"

#: admin/settings.php:6
Expand Down Expand Up @@ -167,19 +167,19 @@ msgstr ""
msgid "Invisible ReCaptcha"
msgstr ""

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

#: includes/class-uwp-recaptcha.php:169
#: includes/class-uwp-recaptcha.php:168
#, php-format
msgid "UsersWP ReCaptcha addon: API Key not set. %sclick here%s to set one."
msgstr ""

#: includes/class-uwp-recaptcha.php:171
#: includes/class-uwp-recaptcha.php:170
#, php-format
msgid "UsersWP ReCaptcha addon: API Secret not set. %sclick here%s to set one."
msgstr ""
Expand Down
5 changes: 4 additions & 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.3
Stable tag: 1.2.0
Stable tag: 1.2.1
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -52,6 +52,9 @@ TBA

== Changelog ==

= 1.2.1 =
* Settings reset to default all the time we activate plugin - FIXED

= 1.2.0 =
* Compatibility with new UWP core style updates - ADDED
* Changes for new login via lightbox - ADDED
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.2.0
Version: 1.2.1
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.2.0' );
define( 'UWP_RECAPTCHA_VERSION', '1.2.1' );

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

Expand Down

0 comments on commit 6e99ee2

Please sign in to comment.