placeholder="">

$email, 'valid' => (bool) is_email( $email ), 'exists' => null, 'disposable' => false, 'accept_all' => false, 'permanent_error' => false, 'error_category' => '', 'verification_status' => 'unavailable', ]; if ( ! Settings::is_verification_enabled() || ! is_email( $email ) ) { return $defaults; } $cache_key = md5( $email ); $cached = ApiClient::get_cached_result( $cache_key ); if ( $cached ) { return wp_parse_args( $cached, $defaults ); } $data = ApiClient::sync_verify( $email ) ?: []; ApiClient::cache_result( $cache_key, $data ); return wp_parse_args( $data, $defaults ); } public static function validation_error( string $email ): string { if ( ! Settings::is_verification_enabled() || '' === $email ) { return ''; } return self::result_error( self::run_sync_validation( $email ) ); } public static function result_error( array $result ): string { $status = ! $result['valid'] ? 'invalid' : $result['verification_status']; $settings = Settings::get_settings(); if ( in_array( $status, $settings['allowed_statuses'], true ) ) { return ''; } if ( 'invalid' === $status ) { return __( 'Invalid email format', 'zbounce-email-validator' ); } if ( 'disposable' === $status ) { return __( 'Disposable emails are not allowed', 'zbounce-email-validator' ); } if ( in_array( $status, [ 'mailbox_not_found', 'no_mx' ], true ) ) { return __( 'Email address does not exist', 'zbounce-email-validator' ); } if ( 'risky' === $status ) { return __( 'Accept-all email domains are not allowed', 'zbounce-email-validator' ); } if ( 'unavailable' === $status ) { return __( 'Email verification is temporarily unavailable. Please try again.', 'zbounce-email-validator' ); } return __( 'The mailbox could not be confirmed. Please use another email address.', 'zbounce-email-validator' ); } public static function validate_store_api_email( $order, $request ) { // PUT/PATCH update checkout drafts; only placing an order spends credits. if ( ! $request instanceof \WP_REST_Request || 'POST' !== $request->get_method() || empty( Settings::get_settings()['wc_enable'] ) ) { return; } if ( ! class_exists( '\Automattic\WooCommerce\StoreApi\Exceptions\RouteException' ) ) { return; } $message = self::validation_error( sanitize_email( $order->get_billing_email() ) ); if ( '' !== $message ) { throw new \Automattic\WooCommerce\StoreApi\Exceptions\RouteException( 'zbounce_email_rejected', esc_html( $message ), 400 ); } } public static function validate_cf7_email( $result, $tag ) { if ( $tag->basetype !== 'email' ) { return $result; } $s = Settings::get_settings(); $form = WPCF7_ContactForm::get_current(); $fid = $form ? $form->id() : null; if ( ! empty( $s['cf7_forms'] ) && $fid && ! in_array( $fid, (array) $s['cf7_forms'], true ) ) { return $result; } // Contact Form 7 performs nonce/submission checks before this validation filter. // phpcs:ignore WordPress.Security.NonceVerification.Missing $email = sanitize_email( isset( $_POST[ $tag->name ] ) && is_string( $_POST[ $tag->name ] ) ? wp_unslash( $_POST[ $tag->name ] ) : '' ); if ( ! $email ) { return $result; } $message = self::validation_error( $email ); if ( '' !== $message ) { $result->invalidate( $tag, $message ); } return $result; } public static function validate_woocommerce_email( $data, $errors ) { $s = Settings::get_settings(); if ( empty( $s['wc_enable'] ) ) { return; } $email = sanitize_email( $data['billing_email'] ?? '' ); if ( ! $email ) { return; } $message = self::validation_error( $email ); if ( '' !== $message ) { $errors->add( 'validation', $message ); } } public static function validate_registration_email( $errors, $user_login, $user_email ) { $s = Settings::get_settings(); if ( empty( $s['reg_enable'] ) ) { return $errors; } $email = sanitize_email( $user_email ); if ( ! $email ) { return $errors; } $message = self::validation_error( $email ); if ( '' !== $message ) { $errors->add( 'zbounce_email_rejected', $message ); } return $errors; } }