Skip to content

Commit

Permalink
Release 7.1.1 (#106)
Browse files Browse the repository at this point in the history
* [create-pull-request] automated changes sync

* Correcting readme

* [create-pull-request] automated changes sync

* Update readme.txt

* [create-pull-request] automated changes sync

* Update readme.txt

* [create-pull-request] automated changes sync

* Update readme.txt

* [create-pull-request] automated changes sync

* Update readme.txt

* [create-pull-request] automated changes sync

* Update readme.txt

* [create-pull-request] automated changes sync (#83)

Co-authored-by: DannyWPWS <[email protected]>

* Correcting readme

* Automated sync from the premium version of the plugin (#84)

* [create-pull-request] automated changes sync

* Correcting readme (removing premium notes)

* Updare readme

* Correct readme

* Update readme from master

Co-authored-by: DannyWPWS <[email protected]>

* Automated sync from the premium version of the plugin (#86)

* [create-pull-request] automated changes sync

* Update readme

Co-authored-by: DannyWPWS <[email protected]>

* Automated sync from the premium version of the plugin (#88)

* [create-pull-request] automated changes sync

* Correcting readme

Co-authored-by: DannyWPWS <[email protected]>

* Automated sync from the premium version of the plugin (#90)

* [create-pull-request] automated changes sync

* Update readme

Co-authored-by: DannyWPWS <[email protected]>

* Automated sync from the premium version of the plugin (#92)

* [create-pull-request] automated changes sync

* Correcting readme

Co-authored-by: DannyWPWS <[email protected]>

* Automated sync from the premium version of the plugin (#96)

* [create-pull-request] automated changes sync

* Update readme.txt

Co-authored-by: DannyWPWS <[email protected]>

* [create-pull-request] automated changes sync (#97)

Co-authored-by: DannyWPWS <[email protected]>

* [create-pull-request] automated changes sync (#99)

Co-authored-by: DannyWPWS <[email protected]>

* [create-pull-request] automated changes sync (#100)

Co-authored-by: DannyWPWS <[email protected]>

* [create-pull-request] automated changes sync (#101)

Co-authored-by: DannyWPWS <[email protected]>

* [create-pull-request] automated changes sync (#103)

Co-authored-by: DannyWPWS <[email protected]>

* [create-pull-request] automated changes sync (#104)

Co-authored-by: DannyWPWS <[email protected]>

* [create-pull-request] automated changes sync (#105)

Co-authored-by: DannyWPWS <[email protected]>

Co-authored-by: DannyWPWS <[email protected]>
  • Loading branch information
DannyWPWS and DannyWPWS authored Aug 18, 2022
1 parent d5ab7b6 commit 5f2bb06
Show file tree
Hide file tree
Showing 8 changed files with 353 additions and 173 deletions.
33 changes: 26 additions & 7 deletions admin/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public function actions_filters() {
* @return void
*/
public function admin_enqueue_scripts() {
wp_register_script( 'c4wp-admin', C4WP_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery' ), C4WP_PLUGIN_VERSION, false );
wp_register_script( 'c4wp-admin', C4WP_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-ui-dialog' ), C4WP_PLUGIN_VERSION, false );
wp_enqueue_style ( 'wp-jquery-ui-dialog');
}

/**
Expand Down Expand Up @@ -212,6 +213,13 @@ public function get_fields() {
'section_id' => 'google_keys',
'required' => true,
),
'key_validation' => array(
'section_id' => 'google_keys',
'type' => 'html',
'label' => esc_html__( 'Key Validation', 'advanced-nocaptcha-recaptcha' ),
'std' => '<p class="description mb-10">' . esc_html__( 'Once you enter the Site and Secret keys above the CAPTCHA method will appear below, depending on the method chosen. If the keys are incorrect, there will be an error notice. If you do see an error, check they provided keys match the method and the domain as well.', 'advanced-nocaptcha-recaptcha' ) . '</p><div id="render-settings-placeholder"></div>',
'class' => '',
),
'score_title' => array(
'section_id' => 'google_keys',
'type' => 'html',
Expand All @@ -221,7 +229,7 @@ public function get_fields() {
),
'class' => 'wrap-around-content',
),
'score)subtitle' => array(
'score_subtitle' => array(
'section_id' => 'google_keys',
'type' => 'html',
'label' => sprintf(
Expand Down Expand Up @@ -351,7 +359,7 @@ public function get_fields() {
'label' => esc_html__( 'Badge', 'advanced-nocaptcha-recaptcha' ),
'section_id' => 'google_keys',
'type' => 'select',
'class' => 'regular toggleable disabled c4wp-show-field-for-v2_invisible',
'class' => 'regular full-hide toggleable disabled c4wp-show-field-for-v2_invisible',
'std' => 'bottomright',
'options' => array(
'bottomright' => esc_html__( 'Bottom Right', 'advanced-nocaptcha-recaptcha' ),
Expand All @@ -361,10 +369,10 @@ public function get_fields() {
'desc' => esc_html__( 'Badge shows for invisible captcha', 'advanced-nocaptcha-recaptcha' ),
),
'badge_v3' => array(
'label' => esc_html__( 'Badge v3', 'advanced-nocaptcha-recaptcha' ),
'label' => esc_html__( 'Badge', 'advanced-nocaptcha-recaptcha' ),
'section_id' => 'google_keys',
'type' => 'select',
'class' => 'regular toggleable disabled c4wp-show-field-for-v3',
'class' => 'regular full-hide toggleable disabled c4wp-show-field-for-v3',
'std' => 'bottomright',
'options' => array(
'bottomright' => esc_html__( 'Bottom Right', 'advanced-nocaptcha-recaptcha' ),
Expand Down Expand Up @@ -804,8 +812,10 @@ public function admin_settings() {
'c4wp-admin',
'anrScripts',
array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
'ipWarning' => esc_html__( 'Please supply a valid IP', 'advanced-nocaptcha-recaptcha' ),
'ajax_url' => admin_url( 'admin-ajax.php' ),
'ipWarning' => esc_html__( 'Please supply a valid IP', 'advanced-nocaptcha-recaptcha' ),
'switchingWarning' => esc_html__( 'Switching CAPTCHA methods will require your Site Key and Secret key to be replaced, do you wish to proceed?', 'advanced-nocaptcha-recaptcha' ),
'switchingWarningTitle' => esc_html__( 'Confirm CAPTCHA method change', 'advanced-nocaptcha-recaptcha' ),
)
);

Expand Down Expand Up @@ -848,6 +858,15 @@ public function admin_settings() {
<div id="post-body" class="metabox-holder columns-2 c4wp-settings">
<div id="post-body-content">
<div id="tab_container">
<div class="overlay" id="overlay" hidden>
<div class="confirm-box">
<div onclick="closeConfirmBox()" class="close">&#10006;</div>
<h2>Confirmation</h2>
<p>Are you sure to execute this action?</p>
<button onclick="isConfirm(true)">Yes</button>
<button onclick="isConfirm(false)">No</button>
</div>
</div>
<?php
if ( 'c4wp-admin-captcha' === $current_tab || 'c4wp-admin-settings' === $current_tab ) {
$this->settings_form();
Expand Down
4 changes: 2 additions & 2 deletions advanced-nocaptcha-recaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
* @wordpress-plugin
* Plugin Name: CAPTCHA 4WP
* Version: 7.1.0
* Version: 7.1.1
* Plugin URI: https://www.wpwhitesecurity.com/wordpress-plugins/captcha-plugin-wordpress/
* Description: Easily add any type of CAPTCHA (such as noCaptcha or invisible Captcha) on any website form, including login pages, comments and password reset forms, and also forms by third party plugins such as Contact Form 7, WooCommerce & BuddyPress.
* Author: WP White Security
Expand Down Expand Up @@ -89,7 +89,7 @@ public static function init() {
* @return void
*/
private function constants() {
define( 'C4WP_PLUGIN_VERSION', '7.1.0' );
define( 'C4WP_PLUGIN_VERSION', '7.1.1' );
define( 'C4WP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'C4WP_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
define( 'C4WP_PLUGIN_FILE', __FILE__ );
Expand Down
15 changes: 11 additions & 4 deletions anr-captcha-class.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public function v2_checkbox_script() {
});
captcha_div.classList.add( 'rendered' );
<?php
$additonal_js = apply_filters( 'c4wp_captcha_callback_additonal_js', false );
$additonal_js = apply_filters( 'c4wp_captcha_callback_additonal_js', '' );
echo $additonal_js;
?>
})(form);
Expand Down Expand Up @@ -214,10 +214,13 @@ public function v2_invisible_script() {
var c4wp_onloadCallback = function() {
for ( var i = 0; i < document.forms.length; i++ ) {
var form = document.forms[i];
var captcha_div = form.querySelector( '.c4wp_captcha_field_div' );

if ( null === captcha_div )
var captcha_div = form.querySelector( '.c4wp_captcha_field_div:not(.rendered)' );
if ( null === captcha_div ) {
continue;
}
if ( !( captcha_div.offsetWidth || captcha_div.offsetHeight || captcha_div.getClientRects().length ) ) {
continue;
}
captcha_div.innerHTML = '';
( function( form ) {
var c4wp_captcha = grecaptcha.render( captcha_div,{
Expand Down Expand Up @@ -264,6 +267,8 @@ public function v2_invisible_script() {
}
});

captcha_div.classList.add( 'rendered' );

<?php
$additonal_js = apply_filters( 'c4wp_captcha_callback_additonal_js', false );
echo $additonal_js;
Expand All @@ -277,6 +282,8 @@ public function v2_invisible_script() {
grecaptcha.execute( c4wp_captcha );
return false;
};
// Remove and append badge on WP login screen.
jQuery( '.login form.shake .grecaptcha-badge' ).appendTo( 'body' );
})(form);
}
};
Expand Down
27 changes: 27 additions & 0 deletions assets/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,31 @@ ul.c4wp-pro-features-ul li.dashicons-yes-alt:before {
}
.h-140 {
height: 290px;
}
.c4wp-alert {
border-radius: 13px;
}
.c4wp-alert .ui-dialog-titlebar {
background: #fff;
border-bottom: none;
height: 33px;
font-size: 16px;
font-weight: 600;
line-height: 2;
padding: 9px 36px 0 9px;
}

.c4wp-alert .ui-dialog-buttonpane {
background: #fff;
border-top: none;
padding: 0 16px 16px;
}

.c4wp-alert .ui-dialog-buttonpane .ui-button + .ui-button {
background: #2271b1;
color: #fff;
border-color: #2271b1;
}
.full-hide.disabled {
display: none;
}
95 changes: 95 additions & 0 deletions assets/js/admin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,100 @@
function createCaptchaScripts( $captcha_version = 'v2_checkbox', $sitekey = false ) {
if ( $captcha_version == 'v2_checkbox' || $captcha_version == 'v2_invisble' ) {
var s = document.createElement("script");
s.type = "text/javascript";
s.src = "https://www.google.com/recaptcha/api.js?render=onload";
s.id = 'gscripts';
jQuery("head").append(s);
} else if ( $sitekey ) {
var s = document.createElement("script");
s.type = "text/javascript";
s.src = "https://www.google.com/recaptcha/api.js?render=" + $sitekey;
s.id = 'gscripts';
jQuery("head").append(s);
}
}

function createRenderArea( $captcha_version = 'v2_checkbox', $sitekey = false ) {
jQuery( '.g-recaptcha, #gscripts, #c4wp-testrender, #warning, #render-wrapper' ).remove();
jQuery('.grecaptcha-badge').parent().remove();
jQuery( '#render-settings-placeholder' ).css( 'height', 'auto' );
if ( $sitekey ) {
if ( $captcha_version == 'v2_checkbox' ) {
jQuery( '#render-settings-placeholder' ).html( '<div class="g-recaptcha" id="c4wp-testrender" data-sitekey="' + $sitekey + '" style="position: absolute; left: 220px;"></div>' ).css( 'height', '78px' );
} else if ( $captcha_version == 'v2_invisble' ) {
jQuery( '#render-settings-placeholder' ).html( '<div class="g-recaptcha" id="c4wp-testrender" data-sitekey="' + $sitekey + '" data-size="invisible"></div>' );
} else {
jQuery( '#render-settings-placeholder' ).html( '<div id="c4wp-testrender" data-sitekey="' + $sitekey + '"></div>' );
setTimeout(function() {
if ( ! jQuery( 'body .grecaptcha-badge' ).length ) {
jQuery( '#c4wp-testrender *' ).remove();
jQuery( '#c4wp-testrender' ).append( '<strong style="color: red" id="warning">Invalid site key</strong>' );
}
}, 500);
}
}
}
function c4wpConfirm(dialogText, okFunc, cancelFunc, dialogTitle) {
jQuery('<div style="padding: 10px; max-width: 500px; word-wrap: break-word;">' + dialogText + '</div>').dialog({
draggable: false,
modal: true,
dialogClass: "c4wp-alert",
resizable: false,
width: 'auto',
title: dialogTitle || 'Confirm',
minHeight: 75,
buttons: {
OK: function () {
if (typeof (okFunc) == 'function') {
setTimeout(okFunc, 50);
}
jQuery(this).dialog('destroy');
},
Cancel: function () {
if (typeof (cancelFunc) == 'function') {
setTimeout(cancelFunc, 50);
}
jQuery(this).dialog('destroy');
}
}
});
}


function testSiteKeys( $captcha_version = 'v2_checkbox', $sitekey = false ) {
createCaptchaScripts( $captcha_version, $sitekey );
createRenderArea( $captcha_version, $sitekey );
}

jQuery(document).ready(function( $ ){

testSiteKeys( $('input[name="c4wp_admin_options[captcha_version]"]:checked').val(), jQuery( '#c4wp_admin_options_site_key' ).attr( 'value' ) );

$('input[name="c4wp_admin_options[site_key]"]').keyup(function(){
testSiteKeys( $('input[name="c4wp_admin_options[captcha_version]"]:checked').val(), $(this).val() );
});

$('.form-table').on( "change", '[name="c4wp_admin_options[captcha_version]"]', function(e) {
testSiteKeys( this.value, $('input[name="c4wp_admin_options[site_key]"]').val() );
c4wp_admin_show_hide_fields();
});

jQuery( 'body' ).on( 'click', '[name="c4wp_admin_options[captcha_version]"]', function ( e ) {
var radio = $(this);
e.preventDefault();
c4wpConfirm( anrScripts.switchingWarning, function () {
$(radio).prop('checked', true);
$( '#c4wp_admin_options_site_key, #c4wp_admin_options_secret_key' ).attr( 'value', '' ).val( '' );
testSiteKeys( $('input[name="c4wp_admin_options[captcha_version]"]:checked').val(), jQuery( '#c4wp_admin_options_site_key' ).attr( 'value' ) );
c4wp_admin_show_hide_fields();
return true;
}, function () {
return false;
},
anrScripts.switchingWarningTitle
);
});

// Tidy desc areas.
function tidySettingsDescs() {
jQuery( '.premium-title-wrapper th' ).each(function(index, value) {
Expand Down
2 changes: 1 addition & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -558,5 +558,5 @@ function c4wp_get_sysinfo() {
* @return bool - Is premium or not.
*/
function c4wp_is_premium_version() {
return ( class_exists( 'C4WP_Pro' ) && ! c4wp_fs()->is_not_paying() ) ? true : false;
return ( ( class_exists( 'C4WP_Pro' ) && ! c4wp_fs()->is_not_paying() ) || ( class_exists( 'C4WP_Pro' ) && c4wp_fs()->is_trial() ) ) ? true : false;
}
Loading

0 comments on commit 5f2bb06

Please sign in to comment.