PluginProbe
WooCommerce / 11.1.0-rc.2
WooCommerce v11.1.0-rc.2
11.1.0 11.1.0-rc.2 11.1.0-rc.1 11.1.0-beta.2 11.1.0-beta.1 11.0.1 11.0.0 11.0.0-rc.3 11.0.0-rc.2 11.0.0-rc.1 11.0.0-beta.2 11.0.0-beta.1 10.9.4 10.9.3 10.9.2 10.9.1 10.9.0 10.9.0-rc.1 10.9.0-beta.2 10.9.0-beta.1 10.8.1 10.8.0 10.8.0-rc.1 10.8.0-beta.2 10.8.0-beta.1 All 648 releases
woocommerce / src / Internal / CustomerEmailVerification / CustomerEmailVerification.php
CustomerEmailVerification.php
65 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 declare( strict_types = 1 );
3
4 namespace Automattic\WooCommerce\Internal\CustomerEmailVerification;
5
6 use Automattic\WooCommerce\Internal\CustomerEmailVerification\Admin\UserProfileField;
7 use Automattic\WooCommerce\Internal\CustomerEmailVerification\Emails\CustomerVerifyEmail;
8
9 /**
10 * Boot class for the customer email verification subsystem.
11 *
12 * Resolves each controller so that their constructors register hooks during the
13 * plugins_loaded action.
14 *
15 * @since 11.0.0
16 */
17 class CustomerEmailVerification {
18
19 /**
20 * Initialize the subsystem.
21 *
22 * @since 11.0.0
23 */
24 public function __construct() {
25 add_action( 'plugins_loaded', array( $this, 'init_hooks' ) );
26 }
27
28 /**
29 * Resolve all subsystem controllers so their constructors register hooks.
30 *
31 * @internal
32 * @since 11.0.0
33 */
34 public function init_hooks(): void {
35 add_filter( 'woocommerce_email_classes', array( $this, 'register_email_classes' ) );
36
37 // Link a customer's matching guest orders to their account once they verify their email.
38 // wc_update_new_customer_past_orders() casts the ID and no-ops for guest/invalid users; the
39 // order count it returns is unused here.
40 // @phpstan-ignore-next-line return.void -- The returned count is intentionally discarded.
41 add_action( 'woocommerce_customer_email_verified', 'wc_update_new_customer_past_orders' );
42
43 $container = wc_get_container();
44 $container->get( VerificationController::class );
45 $container->get( VerificationEventListener::class );
46
47 if ( is_admin() ) {
48 $container->get( UserProfileField::class );
49 }
50 }
51
52 /**
53 * Register the customer email verification email with WooCommerce.
54 *
55 * @internal
56 *
57 * @param array $emails Registered email classes.
58 * @return array
59 */
60 public function register_email_classes( array $emails ): array {
61 $emails['WC_Email_Customer_Verify_Email'] = new CustomerVerifyEmail();
62 return $emails;
63 }
64 }
65