=' ) ) { add_filter( 'pre_comment_approved', array( $this, 'comment_verify_490' ), 99 ); } else { add_filter( 'preprocess_comment', array( $this, 'comment_verify' ) ); } } if ( function_exists( 'wpcf7_add_form_tag' ) ) { wpcf7_add_form_tag( 'anr_nocaptcha', array( $this, 'wpcf7_form_field' ), array( 'name-attr' => 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 ( anr_is_form_enabled( 'bbp_new' ) ) { add_action( 'bbp_theme_before_topic_form_submit_wrapper', array( $this, 'form_field' ), 99 ); add_action( 'bbp_new_topic_pre_extras', array( $this, 'bbp_new_verify' ) ); } if ( anr_is_form_enabled( 'bbp_reply' ) ) { add_action( 'bbp_theme_before_reply_form_submit_wrapper', array( $this, 'form_field' ), 99 ); add_action( 'bbp_new_reply_pre_extras', array( $this, 'bbp_reply_verify' ), 10, 2 ); } } function add_error_to_mgs( $mgs = false ) { if ( false === $mgs ) { $mgs = anr_get_option( 'error_message', '' ); } return '' . __( 'ERROR', 'advanced-nocaptcha-recaptcha' ) . ': ' . $mgs; } 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 ) { if ( ! $this->verify() ) { $errors->add( 'anr_error', anr_get_option( 'error_message' ) ); } } function login_verify( $user, $username = '', $password = '' ) { global $wpdb; if ( ! $username ) { return $user; } $show_captcha = $this->show_login_captcha(); if ( ! ( $user instanceof WP_User ) ) { if ( ! $show_captcha && ( $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() ) { return new WP_Error( 'anr_error', $this->add_error_to_mgs() ); } 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() ) { $errors->add( 'anr_error', $this->add_error_to_mgs() ); } return $errors; } function wc_registration_verify( $errors, $sanitized_user_login, $user_email ) { if ( defined( 'WOOCOMMERCE_CHECKOUT' ) && ! anr_is_form_enabled( 'wc_checkout' ) ) { return $errors; } if ( ! $this->verify() ) { $errors->add( 'anr_error', anr_get_option( 'error_message' ) ); } return $errors; } function bp_form_field() { $loggedin_hide = anr_get_option( 'loggedin_hide' ); if ( is_user_logged_in() && $loggedin_hide ) { return; } do_action( 'bp_anr_error_errors' ); anr_captcha_form_field( true ); } function bp_registration_verify() { if ( ! $this->verify() ) { buddypress()->signup->errors['anr_error'] = anr_get_option( 'error_message' ); } } function ms_form_field_verify( $result ) { if ( ! $this->verify() ) { $result['errors']->add( 'anr_error', anr_get_option( 'error_message' ) ); } return $result; } function lostpassword_verify( $result, $user_id ) { if ( ! $this->verify() ) { return new WP_Error( 'anr_error', $this->add_error_to_mgs() ); } return $result; } function lostpassword_verify_44( $errors ) { if ( ! $this->verify() ) { $errors->add( 'anr_error', $this->add_error_to_mgs() ); } } function reset_password_verify( $errors, $user ) { if ( ! $this->verify() ) { $errors->add( 'anr_error', $this->add_error_to_mgs() ); } } function comment_verify( $commentdata ) { if ( ! $this->verify() ) { wp_die( '' . $this->add_error_to_mgs() . '
', __( 'Comment Submission Failure' ), array( 'response' => 403, 'back_link' => true, ) ); } return $commentdata; } function comment_verify_490( $approved ) { if ( ! $this->verify() ) { return new WP_Error( 'anr_error', $this->add_error_to_mgs(), 403 ); } return $approved; } 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() ) { $result->invalidate( $tag, anr_get_option( 'error_message' ) ); } return $result; } function bbp_new_verify( $forum_id ) { if ( ! $this->verify() ) { bbp_add_error( 'anr_error', $this->add_error_to_mgs() ); } } function bbp_reply_verify( $topic_id, $forum_id ) { if ( ! $this->verify() ) { bbp_add_error( 'anr_error', $this->add_error_to_mgs() ); } } function wc_checkout_verify( $data, $errors ) { $is_reg_enable = apply_filters( 'woocommerce_checkout_registration_enabled', 'yes' === get_option( 'woocommerce_enable_signup_and_login_from_checkout' ) ); $is_reg_required = apply_filters( 'woocommerce_checkout_registration_required', 'yes' !== get_option( 'woocommerce_enable_guest_checkout' ) ); if ( ! is_user_logged_in() && $is_reg_enable && anr_is_form_enabled( 'registration' ) && ( $is_reg_required || ! empty( $data['createaccount'] ) ) ) { // verification done during ragistration, So no need any more verification } elseif ( ! $this->verify() ) { $errors->add( 'anr_error', anr_get_option( 'error_message' ) ); } } } //END CLASS } //ENDIF add_action( 'init', array( anr_captcha_class::init(), 'actions_filters' ), -9 );