true ) ); add_filter('wpcf7_validate_anr_nocaptcha', array($this, 'wpcf7_verify'), 10, 2); } elseif( function_exists( 'wpcf7_add_shortcode' ) ){ wpcf7_add_shortcode('anr_nocaptcha', array($this, 'wpcf7_form_field'), true); add_filter('wpcf7_validate_anr_nocaptcha', array($this, 'wpcf7_verify'), 10, 2); } if ( '1' == anr_get_option( 'bb_new' )) { add_action ('bbp_theme_before_topic_form_submit_wrapper', array($this, 'form_field'), 99); add_action ('bbp_new_topic_pre_extras', array($this, 'bb_new_verify') ); } if ( '1' == anr_get_option( 'bb_reply' )) { add_action ('bbp_theme_before_reply_form_submit_wrapper', array($this, 'form_field'), 99); add_action ('bbp_new_reply_pre_extras', array($this, 'bb_reply_verify'), 10, 2 ); } } function total_captcha() { return self::$captcha_count; } function captcha_form_field() { self::$captcha_count++; $no_js = anr_get_option( 'no_js' ); $site_key = trim(anr_get_option( 'site_key' )); $number = $this->total_captcha(); $field = '
' . $errmsg . '
'; } anr_captcha_form_field( true ); } function comment_form_field( $defaults ) { $loggedin_hide = anr_get_option( 'loggedin_hide' ); if ( is_user_logged_in() && $loggedin_hide ) return $defaults; $defaults = $defaults . anr_captcha_form_field( false ); return $defaults; } function verify() { $loggedin_hide = anr_get_option( 'loggedin_hide' ); if ( is_user_logged_in() && $loggedin_hide ) return true; return anr_verify_captcha(); } function fepcf_verify ( $errors ) { $error_message = str_replace(__('ERROR: ', 'advanced-nocaptcha-recaptcha'), '', anr_get_option( 'error_message' )); if ( ! $this->verify() ){ $errors->add('anr_error', $error_message); } } function login_verify ( $user, $username = '', $password = '' ) { global $wpdb; $show_captcha = $this->show_login_captcha(); if ( ! ( $user instanceof WP_User ) ){ if( ! $show_captcha && $username && ( $post_id = $this->post_id() ) ){ if( is_email( $username ) ){ $user_data = get_user_by( 'email', $username ); if( $user_data ){ $username = $user_data->user_login; } } $wpdb->insert( $wpdb->postmeta, array( 'post_id' => $post_id, 'meta_key' => md5( $_SERVER['REMOTE_ADDR'] ), 'meta_value' => $username ), array( '%d', '%s', '%s' ) ); } return $user; } if ( $show_captcha && ! $this->verify() ) { $error_message = anr_get_option( 'error_message' ); return new WP_Error( 'anr_error', $error_message ); } return $user; } function clear_data( $user_login, $user ){ global $wpdb; if( $post_id = $this->post_id() ){ $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d AND ( meta_key = %s OR meta_value = %s )", $post_id, md5( $_SERVER['REMOTE_ADDR'] ), $user_login ) ); } } function registration_verify ( $errors, $sanitized_user_login, $user_email ) { if ( ! $this->verify() ) { $error_message = anr_get_option( 'error_message' ); $errors->add( 'anr_error', $error_message ); } return $errors; } function wc_registration_verify ( $errors, $sanitized_user_login, $user_email ){ if ( defined( 'WOOCOMMERCE_CHECKOUT' ) && ! anr_get_option( 'wc_checkout' ) ) { return $errors; } if ( ! $this->verify() ) { $error_message = anr_get_option( 'error_message' ); $errors->add( 'anr_error', $error_message ); } return $errors; } function ms_form_field_verify( $result ) { if ( ! $this->verify() ) { $error_message = str_replace(__('ERROR: ', 'advanced-nocaptcha-recaptcha'), '', anr_get_option( 'error_message' )); $result['errors']->add( 'anr_error', $error_message ); } return $result; } function lostpassword_verify( $result, $user_id ) { if ( ! $this->verify() ) { $error_message = anr_get_option( 'error_message' ); return new WP_Error( 'anr_error', $error_message ); } return $result; } function lostpassword_verify_44( $errors ) { if ( ! $this->verify() ) { $error_message = anr_get_option( 'error_message' ); $errors->add('anr_error', $error_message); } } function reset_password_verify( $errors, $user ) { if ( ! $this->verify() ) { $error_message = anr_get_option( 'error_message' ); $errors->add('anr_error', $error_message); } } function comment_verify( $commentdata ) { if ( ! $this->verify() ) { $error_message = anr_get_option( 'error_message' ); wp_die( $error_message, 200 ); } return $commentdata; } function wpcf7_form_field( $tag ) { $loggedin_hide = anr_get_option( 'loggedin_hide' ); if ( is_user_logged_in() && $loggedin_hide ) return ''; return anr_captcha_form_field( false ). sprintf( '', $tag->name ); } function wpcf7_verify( $result, $tag ) { if ( ! $this->verify() ) { $error_message = str_replace(__('ERROR: ', 'advanced-nocaptcha-recaptcha'), '', anr_get_option( 'error_message' )); $result->invalidate( $tag, $error_message ); } return $result; } function bb_new_verify( $forum_id ) { if ( ! $this->verify() ) { $error_message = anr_get_option( 'error_message' ); bbp_add_error('anr_error', $error_message); } } function bb_reply_verify( $topic_id, $forum_id ) { if ( ! $this->verify() ) { $error_message = anr_get_option( 'error_message' ); bbp_add_error('anr_error', $error_message); } } function wc_checkout_verify() { $is_reg_enable = apply_filters( 'woocommerce_checkout_registration_enabled', 'yes' === get_option( 'woocommerce_enable_signup_and_login_from_checkout' ) ); if( ! is_user_logged_in() && $is_reg_enable && '1' == anr_get_option( 'registration' ) ){ // verification done during ragistration, So no need any more verification } elseif( ! $this->verify() ){ $error_message = anr_get_option( 'error_message' ); wc_add_notice( $error_message, 'error' ); } } } //END CLASS } //ENDIF add_action('init', array(anr_captcha_class::init(), 'actions_filters'), -99 );