Skip to content

Commit

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

Co-authored-by: DannyWPWS <DannyWPWS@users.noreply.github.com>

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

Co-authored-by: DannyWPWS <DannyWPWS@users.noreply.github.com>

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

Co-authored-by: DannyWPWS <DannyWPWS@users.noreply.github.com>

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

Co-authored-by: DannyWPWS <DannyWPWS@users.noreply.github.com>

---------

Co-authored-by: DannyWPWS <DannyWPWS@users.noreply.github.com>
  • Loading branch information
DannyWPWS and DannyWPWS authored Dec 18, 2023
1 parent e8e0b61 commit 1aa2135
Show file tree
Hide file tree
Showing 14 changed files with 636 additions and 397 deletions.
97 changes: 91 additions & 6 deletions admin/class-c4wp-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public static function get_fields() {
'section_id' => 'google_keys',
'type' => 'select',
'std' => 'en',
'class' => 'regular lang_select',
'class' => 'regular lang_select hide-if-disabled toggleable',
'options' => array(
'ar' => esc_html__( 'Arabic', 'advanced-nocaptcha-recaptcha' ),
'bg' => esc_html__( 'Bulgarian', 'advanced-nocaptcha-recaptcha' ),
Expand Down Expand Up @@ -421,6 +421,38 @@ public static function get_fields() {
'vi' => esc_html__( 'Vietnamese', 'advanced-nocaptcha-recaptcha' ),
),
),
'language_cloudflare' => array(
'label' => '',
'section_id' => 'google_keys',
'type' => 'select',
'std' => 'en',
'class' => 'regular lang_select hide-if-disabled toggleable c4wp-show-field-for-cloudflare',
'options' => array(
'ar-eg' => esc_html__( 'Arabic (Egypt)', 'advanced-nocaptcha-recaptcha' ),
'ar' => esc_html__( 'Arabic', 'advanced-nocaptcha-recaptcha' ),
'de' => esc_html__( 'German', 'advanced-nocaptcha-recaptcha' ),
'en' => esc_html__( 'English (US)', 'advanced-nocaptcha-recaptcha' ),
'es' => esc_html__( 'Spanish', 'advanced-nocaptcha-recaptcha' ),
'fa' => esc_html__( 'Persian', 'advanced-nocaptcha-recaptcha' ),
'fr' => esc_html__( 'French', 'advanced-nocaptcha-recaptcha' ),
'id' => esc_html__( 'Indonesian', 'advanced-nocaptcha-recaptcha' ),
'it' => esc_html__( 'Italian', 'advanced-nocaptcha-recaptcha' ),
'ja' => esc_html__( 'Japanese', 'advanced-nocaptcha-recaptcha' ),
'ko' => esc_html__( 'Korean', 'advanced-nocaptcha-recaptcha' ),
'nl' => esc_html__( 'Dutch', 'advanced-nocaptcha-recaptcha' ),
'pl' => esc_html__( 'Polish', 'advanced-nocaptcha-recaptcha' ),
'pt' => esc_html__( 'Portuguese', 'advanced-nocaptcha-recaptcha' ),
'pt-br' => esc_html__( 'Portuguese (Brazil)', 'advanced-nocaptcha-recaptcha' ),
'ru' => esc_html__( 'Russian', 'advanced-nocaptcha-recaptcha' ),
'tlh' => esc_html__( 'Klingon', 'advanced-nocaptcha-recaptcha' ),
'tr' => esc_html__( 'Turkish', 'advanced-nocaptcha-recaptcha' ),
'uk' => esc_html__( 'Ukrainian', 'advanced-nocaptcha-recaptcha' ),
'uk-ua' => esc_html__( 'Ukrainian (Ukraine)', 'advanced-nocaptcha-recaptcha' ),
'zh' => esc_html__( 'Chinese', 'advanced-nocaptcha-recaptcha' ),
'zh-cm' => esc_html__( 'Chinese (Simplified)', 'advanced-nocaptcha-recaptcha' ),
'zh-tw' => esc_html__( 'Chinese (Traditional)', 'advanced-nocaptcha-recaptcha' ),
),
),
'error_message' => array(
'label' => esc_html__( 'Error message', 'advanced-nocaptcha-recaptcha' ),
'section_id' => 'google_keys',
Expand Down Expand Up @@ -491,7 +523,7 @@ public static function get_fields() {
'label' => esc_html__( 'Remove CSS', 'advanced-nocaptcha-recaptcha' ),
'section_id' => 'google_keys',
'type' => 'checkbox',
'class' => 'checkbox toggleable disabled c4wp-show-field-for-v2_checkbox',
'class' => 'checkbox',
'cb_label' => esc_html__( "Remove this plugin's css from login page?", 'advanced-nocaptcha-recaptcha' ),
'desc' => __( 'This css increase login page width to adjust with Captcha width.', 'advanced-nocaptcha-recaptcha' ),
),
Expand Down Expand Up @@ -1152,12 +1184,11 @@ public static function c4wp_admin_sidebar() {
<li class="dashicons-before dashicons-yes-alt"> ' . esc_html__( 'Exempt logged in users, IP addresses and specific URLs from CAPTCHA checks.', 'advanced-nocaptcha-recaptcha' ) . '</li>
<li class="dashicons-before dashicons-yes-alt"> ' . esc_html__( 'No Ads!', 'advanced-nocaptcha-recaptcha' ) . '</li>
</ul>
<p style="text-align: center; margin: auto"><a class="premium-link" href="%2$s" target="_blank">' . esc_html__( 'Get a FREE 14-day trial', 'advanced-nocaptcha-recaptcha' ) . '</a> <a class="premium-link-not-btn" href="%1$s" target="_blank">' . esc_html__( 'Upgrade to Premium', 'advanced-nocaptcha-recaptcha' ) . '</a></p>
<p style="text-align: center; margin: auto"><a class="premium-link" href="%1$s" target="_blank">' . esc_html__( 'Upgrade to Premium', 'advanced-nocaptcha-recaptcha' ) . '</a></p>
</div>
</div>
</div>',
esc_url( 'https://melapress.com/wordpress-captcha/pricing/?utm_source=wp+repo&utm_medium=repo+link&utm_campaign=wordpress_org&utm_content=c4wp' ),
function_exists( 'c4wp_fs' ) ? c4wp_fs()->get_upgrade_url() : 'https://melapress.com/wordpress-captcha/plugin-trial/?utm_source=wp+repo&utm_medium=repo+link&utm_campaign=wordpress_org&utm_content=c4wp'
esc_url( 'https://melapress.com/wordpress-captcha/pricing/?utm_source=wp+repo&utm_medium=repo+link&utm_campaign=wordpress_org&utm_content=c4wp' )
);
endif;
return $return;
Expand Down Expand Up @@ -1361,7 +1392,7 @@ public static function wizard_markup() {
</div>
<div class="c4wp-wizard-panel" id="c4wp-setup-wizard-v3-fallback">
<div class="c4wp-panel-content">
<strong>' . esc_html__( 'Step 3: Configure a failover action for reCAPTCHA v3 failure', 'advanced-nocaptcha-recaptcha' ) . '</strong>
<strong>' . esc_html__( 'Step 4: Configure a failover action for reCAPTCHA v3 failure', 'advanced-nocaptcha-recaptcha' ) . '</strong>
<p class="description c4wp-desc" style="position: absolute;">' . esc_html__( 'reCAPTCHA v3 is fully automated. This means that by default, if the CAPTCHA check fails the website visitor cannot proceed with what they are doing unless you configure a failover action. Use the below setting to configure the failover action.', 'advanced-nocaptcha-recaptcha' ) . '</p>
<p>' . $fields['failure_action']['label'] . '
' . self::callback( $fields['failure_action'], true ) . '</p>
Expand Down Expand Up @@ -1516,6 +1547,60 @@ public static function add_logging_and_testing_settings( $fields ) {

public static function add_delete_data_settings( $fields ) {
$additonal_hide_fields = array(
'disable_submit_title' => array(
'section_id' => 'forms',
'type' => 'html',
'class' => 'wrap-around-content',
'label' => sprintf(
'<strong style="position: absolute;">%1$s</strong>',
esc_html__( 'Disable submit button untill CAPTCHA response is provided?', 'advanced-nocaptcha-recaptcha' )
),
),
'disable_submit_subtitle' => array(
'section_id' => 'forms',
'type' => 'html',
'class' => 'wrap-around-content',
'label' => sprintf(
'<p class="description c4wp-desc" style="position: absolute;">%1$s</p>',
esc_html__( 'When using a visible CAPTCHA method (V2 checkbox etc), should we disable the submit button untill the CAPTCHA challenge is completed?', 'advanced-nocaptcha-recaptcha' )
),
),
'disable_submit' => array(
'label' => esc_html__( 'Disable submit button', 'advanced-nocaptcha-recaptcha' ),
'section_id' => 'forms',
'std' => 0,
'type' => 'checkbox',
'class' => 'checkbox',
),
'pass_on_no_captcha_found_title' => array(
'section_id' => 'forms',
'type' => 'html',
'class' => 'wrap-around-content',
'label' => sprintf(
'<strong style="position: absolute;">%1$s</strong>',
esc_html__( 'Should CAPTCHA 4WP pass or fail a submission if no CAPTCHA field is found?', 'advanced-nocaptcha-recaptcha' )
),
),
'pass_on_no_captcha_found_subtitle' => array(
'section_id' => 'forms',
'type' => 'html',
'class' => 'wrap-around-content',
'label' => sprintf(
'<p class="description c4wp-desc" style="position: absolute;">%1$s</p>',
esc_html__( 'If a form is passed through our plugin for verification and no CAPTCHA field is present, you can choose to either allow the submission or return a failure.', 'advanced-nocaptcha-recaptcha' )
),
),
'pass_on_no_captcha_found' => array(
'label' => esc_html__( 'Disable CAPTCHA tests for logged in users', 'advanced-nocaptcha-recaptcha' ),
'section_id' => 'forms',
'type' => 'radio',
'class' => 'regular remove-space-below remove-radio-br',
'std' => 'proceed',
'options' => array(
'proceed' => esc_html__( 'Proceed with submission', 'advanced-nocaptcha-recaptcha' ),
'fail' => esc_html__( 'Fail submission', 'advanced-nocaptcha-recaptcha' ),
),
),
'delete_data_subtitle' => array(
'section_id' => 'forms',
'type' => 'html',
Expand Down
4 changes: 2 additions & 2 deletions admin/templates/upgrade/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<p><?php esc_html_e( 'Add antispam protection to block bots and allow real humans to interact with your website. Add CAPTCHA from services such as Google reCAPTCHA, hCaptcha and Cloudflare Turnstile to any form on your website such as comments forms, login pages and checkout forms.', 'c4wp-wpp' ); ?></p>
<p><?php esc_html_e( 'Get started with just a few clicks with CAPTCHA 4WP, the only plugin that supports multiple CAPTCHA services. Upgrade today and benefit from numerous features, some of which are listed below.', 'c4wp-wpp' ); ?></p>
<div class="premium-cta">
<a href=" https://melapress.com/wordpress-captcha/plugin-trial/?utm_source=plugin&utm_medium=banner&utm_campaign=C4WP&utm_content=get+trial" target="_blank" rel="noopener">Get a Free-14 day trial</a> <a class="text-link" href="https://melapress.com/wordpress-captcha/pricing/?utm_source=wp+repo&utm_medium=repo+link&utm_campaign=wordpress_org&utm_content=c4wp" target="_blank" rel="noopener">Upgrade to Premium</a>
<a href="https://melapress.com/wordpress-captcha/pricing/?utm_source=wp+repo&utm_medium=repo+link&utm_campaign=wordpress_org&utm_content=c4wp" target="_blank" rel="noopener">Upgrade to Premium</a>
</div>
</div>

Expand Down Expand Up @@ -324,7 +324,7 @@
</div>

<div class="premium-cta">
<a href="https://melapress.com/wordpress-captcha/plugin-trial/?utm_source=plugin&utm_medium=banner&utm_campaign=C4WP&utm_content=get+trial" target="_blank" rel="noopener">Get a FREE 14-day trial</a> <a class="text-link" href="https://melapress.com/wordpress-captcha/pricing/?utm_source=wp+repo&utm_medium=repo+link&utm_campaign=wordpress_org&utm_content=c4wp" target="_blank" rel="noopener">Upgrade to Premium</a>
<a href="https://melapress.com/wordpress-captcha/pricing/?utm_source=wp+repo&utm_medium=repo+link&utm_campaign=wordpress_org&utm_content=c4wp" target="_blank" rel="noopener">Upgrade to Premium</a>
</div>

</div>
Expand Down
54 changes: 40 additions & 14 deletions advanced-nocaptcha-recaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
*
* @wordpress-plugin
* Plugin Name: CAPTCHA 4WP
* Version: 7.3.1
* Version: 7.4.0
* Plugin URI: https://melapress.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.
* Description: Easily add Google reCAPTCHA to WordPress forms. Upgrade to Premium and gain access to additional features, including hCaptcha and CloudFlare Turnstile integration, CAPTCHA one-click form integration with plugins such as WooCommerce, Contact Form 7, and WP Forms, and many other features.
* Author: Melapress
* Author URI: https://melapress.com/
* Text Domain: advanced-nocaptcha-recaptcha
Expand Down Expand Up @@ -59,13 +59,6 @@ class C4WP {
* Class constructor.
*/
private function __construct() {


if ( is_plugin_active( 'advanced-nocaptcha-and-invisible-captcha-pro/advanced-nocaptcha-and-invisible-captcha-pro.php' ) ) {
deactivate_plugins( 'advanced-nocaptcha-recaptcha/advanced-nocaptcha-recaptcha.php' );
return;
}

$this->constants();
$this->includes();
$this->actions();
Expand All @@ -89,11 +82,24 @@ public static function init() {
* @return void
*/
private function constants() {
define( 'C4WP_PLUGIN_VERSION', '7.3.1' );
define( 'C4WP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'C4WP_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
define( 'C4WP_PLUGIN_FILE', __FILE__ );
define( 'C4WP_TABLE_PREFIX', 'c4wp_' );
if ( ! defined( 'C4WP_PLUGIN_VERSION' ) ) {
define( 'C4WP_PLUGIN_VERSION', '7.4.0' );
}
if ( ! defined( 'C4WP_PLUGIN_DIR' ) ) {
define( 'C4WP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
}
if ( ! defined( 'C4WP_PLUGIN_URL' ) ) {
define( 'C4WP_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
}
if ( ! defined( 'C4WP_PLUGIN_FILE' ) ) {
define( 'C4WP_PLUGIN_FILE', __FILE__ );
}
if ( ! defined( 'C4WP_TABLE_PREFIX' ) ) {
define( 'C4WP_TABLE_PREFIX', 'c4wp_' );
}
if ( ! defined( 'C4WP_BASE_NAME' ) ) {
define( 'C4WP_BASE_NAME', plugin_basename( __FILE__ ) );
}
register_uninstall_hook( C4WP_PLUGIN_FILE, 'c4wp_uninstall' );
}

Expand Down Expand Up @@ -127,6 +133,7 @@ private function actions() {
add_action( 'init', array( 'C4WP\\C4WP_Functions', 'actions' ) );
add_action( 'init', array( 'C4WP\\C4WP_Functions', 'c4wp_plugin_update' ), -15 );
add_action( 'login_enqueue_scripts', array( 'C4WP\\C4WP_Functions', 'c4wp_login_enqueue_scripts' ) );
add_filter( 'plugin_action_links_' . C4WP_BASE_NAME, array( 'C4WP\\C4WP_Functions', 'add_plugin_shortcuts' ), 999, 1 );

}
}
Expand Down Expand Up @@ -244,3 +251,22 @@ function c4wp_verify_captcha( $response = false ) {
return false;
}
}

if ( ! function_exists( 'anr_verify_captcha' ) ) {
function anr_verify_captcha( $response = false ) {
if ( class_exists( 'C4WP\C4WP_Functions' ) ) {
return C4WP\C4WP_Functions::c4wp_verify_captcha( $response );
}
return false;
}
}


if ( ! function_exists( 'c4wp_free_on_plugin_activation' ) ) {
function c4wp_free_on_plugin_activation( $response = false ) {
if ( is_plugin_active( 'advanced-nocaptcha-and-invisible-captcha-pro/advanced-nocaptcha-and-invisible-captcha-pro.php' ) ) {
deactivate_plugins( 'advanced-nocaptcha-and-invisible-captcha-pro/advanced-nocaptcha-and-invisible-captcha-pro.php' );
}
}
}
register_activation_hook( __FILE__, 'c4wp_free_on_plugin_activation' );
4 changes: 4 additions & 0 deletions assets/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -577,4 +577,8 @@ ul.c4wp-pro-features-ul li.dashicons-yes-alt:before {

#cloudflare-render iframe {
display: block !important;
}

.hide-if-disabled.disabled {
display: none;
}
10 changes: 10 additions & 0 deletions assets/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,16 @@ jQuery(document).ready(function( $ ){
var selected_value = $( '[name="c4wp_admin_options[captcha_version]"]:checked' ).val();
$( '.toggleable' ).addClass( 'disabled' );
$( '.c4wp-show-field-for-'+ selected_value ).removeClass( 'disabled' );

if ( selected_value != 'cloudflare' ) {
$( '#c4wp_admin_options_language' ).removeClass( 'disabled' );
$( '#c4wp_admin_options_language_cloudflare' ).remove();
}

var fb_selected_value = jQuery( '.c4wp-wizard-panel select[name="c4wp_admin_options[failure_action]"] option:selected' ).val();
if ( fb_selected_value == 'v2_checkbox' ) {
$( '.c4wp-show-field-for-'+ fb_selected_value ).removeClass( 'disabled' );
}
}

/**
Expand Down
63 changes: 27 additions & 36 deletions includes/class-c4wp-captcha-class.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ public static function c4wp_ajax_verification_scripts() {
$fail_action = C4WP_Functions::c4wp_get_option( 'failure_action', 'nothing' );
$redirect = C4WP_Functions::c4wp_get_option( 'failure_redirect' );
$failure_v2_site_key = C4WP_Functions::c4wp_get_option( 'failure_v2_site_key' );
$size = C4WP_Functions::c4wp_get_option( 'size', 'normal' );
$theme = C4WP_Functions::c4wp_get_option( 'theme', 'normal' );

$code = "
Expand Down Expand Up @@ -260,56 +262,45 @@ public static function c4wp_ajax_verification_scripts() {
res => res.json()
)
.then( data => {
if ( data['success'] ) {
form.classList.add( 'c4wp_verified' );
if ( typeof jQuery !== 'undefined' && form_type == 'wc_checkout' ) {
form.classList.add( 'c4wp_v2_fallback_active' );
jQuery( '.woocommerce-checkout' ).submit();
return true;
} else if ( typeof jQuery !== 'undefined' && form_type == 'wc_login' ) {
jQuery( '.woocommerce-form-login__submit' ).trigger('click');
return true;
} else if ( typeof jQuery !== 'undefined' && form_type == 'wc_reg' ) {
jQuery( '.woocommerce-form-register__submit' ).trigger('click');
return true;
} else if ( typeof jQuery !== 'undefined' && form_type == 'bp_comment' ) {
return true;
} else if ( typeof jQuery !== 'undefined' && form_type == 'bp_group' ) {
jQuery( '#group-creation-create' ).trigger('click');
} else if ( typeof jQuery !== 'undefined' && form_type == 'bp_signup' ) {
jQuery( '#submit' ).trigger('click');
} else {
// Submit as usual.
if ( foundSubmitBtn ) {
foundSubmitBtn.click();
} else {
if ( typeof form.submit === 'function' ) {
form.submit();
} else {
HTMLFormElement.prototype.submit.call(form);
}
}
} else {
";

if ( 'redirect' === $fail_action ) {
$code .= "
window.location.href = '" . $redirect . "';
";
$code .= "window.location.href = '" . $redirect . "';";
}

if ( 'v2_checkbox' === $fail_action ) {
$code .= "
captcha_div.innerHTML = '';
form.classList.add( 'c4wp_v2_fallback_active' );
flagMarkupDiv.firstChild.setAttribute( 'name', 'c4wp_v2_fallback' );
var c4wp_captcha = grecaptcha.render( captcha_div,{
'sitekey' : '" . $failure_v2_site_key . "',
'expired-callback' : function(){
grecaptcha.reset( c4wp_captcha );
}
});
";
captcha_div.innerHTML = '';
form.classList.add( 'c4wp_v2_fallback_active' );
flagMarkupDiv.firstChild.setAttribute( 'name', 'c4wp_v2_fallback' );
var c4wp_captcha = grecaptcha.render( captcha_div,{
'sitekey' : '" . $failure_v2_site_key . "',
'size' : '" . $size . "',
'theme' : '" . $theme . "',
'expired-callback' : function(){
grecaptcha.reset( c4wp_captcha );
}
});
";
}

$code .= '
$code .= '
// Prevent further submission
event.preventDefault();
return false;
Expand Down Expand Up @@ -476,8 +467,8 @@ public static function ms_form_field( $errors ) {
* @param boolean $response - Current response.
* @return bool - Was request valid?
*/
public static function verify( $response = false ) {
$verify = C4WP_Method_Loader::method_verify( C4WP_Method_Loader::get_currently_selected_method( true, false ), $response );
public static function verify( $response = false, $is_fallback_challenge = false ) {
$verify = C4WP_Method_Loader::method_verify( C4WP_Method_Loader::get_currently_selected_method( true, false ), $response, $is_fallback_challenge );
return $verify;
}

Expand Down Expand Up @@ -562,7 +553,7 @@ public static function registration_verify( $errors, $sanitized_user_login, $use
* @return array $result - Error array with ours added, if applicable.
*/
public static function ms_form_field_verify( $result ) {
if ( isset( $_POST['stage'] ) && 'validate-user-signup' === $_POST['stage'] && ! $this->verify() ) { // phpcs:ignore
if ( isset( $_POST['stage'] ) && 'validate-user-signup' === $_POST['stage'] && ! self::verify() ) { // phpcs:ignore
$result['errors']->add( 'c4wp_error', C4WP_Functions::c4wp_get_option( 'error_message' ) );
}

Expand All @@ -576,7 +567,7 @@ public static function ms_form_field_verify( $result ) {
* @return array $result - Error array with ours added, if applicable.
*/
public static function ms_blog_verify( $result ) {
if ( ! $this->verify() ) {
if ( ! self::verify() ) {
$result['errors']->add( 'c4wp_error', C4WP_Functions::c4wp_get_option( 'error_message' ) );
}

Expand Down
Loading

0 comments on commit 1aa2135

Please sign in to comment.