PluginProbe
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification / 5.5.0
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification v5.5.0
5.5.0 5.4.0 5.3.2 5.3.1 5.1.6 5.1.5 trunk 2.1.5 2.11 2.12 2.13 2.15 3.0.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.51 3.0.60 3.0.61 3.0.62 3.0.70 3.0.71 3.0.72 3.1.0 All 34 releases
double-opt-in / src / Providers / EmailTemplateServiceProvider.php

EmailTemplateServiceProvider.php in Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification 5.5.0, at src/Providers/EmailTemplateServiceProvider.php

112 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Email Template Service Provider
4 *
5 * @package Forge12\DoubleOptIn\Providers
6 * @since 4.0.0
7 */
8
9 namespace Forge12\DoubleOptIn\Providers;
10
11 use Forge12\DoubleOptIn\Container\Container;
12 use Forge12\DoubleOptIn\Container\BootableProviderInterface;
13 use Forge12\DoubleOptIn\EmailTemplates\EmailTemplatePostType;
14 use Forge12\DoubleOptIn\EmailTemplates\EmailTemplateRepository;
15 use Forge12\DoubleOptIn\EmailTemplates\EmailTemplateRestController;
16 use Forge12\DoubleOptIn\EmailTemplates\EmailHtmlGenerator;
17 use Forge12\DoubleOptIn\EmailTemplates\EmailTemplateIntegration;
18 use Forge12\DoubleOptIn\EmailTemplates\BlockRegistry;
19
20 if ( ! defined( 'ABSPATH' ) ) {
21 exit;
22 }
23
24 /**
25 * Class EmailTemplateServiceProvider
26 *
27 * Registers email template services.
28 */
29 class EmailTemplateServiceProvider implements BootableProviderInterface {
30
31 /**
32 * {@inheritdoc}
33 */
34 public function register( Container $container ): void {
35 // Register Post Type
36 $container->singleton(
37 EmailTemplatePostType::class,
38 function () {
39 return new EmailTemplatePostType();
40 }
41 );
42
43 // Register Repository
44 $container->singleton(
45 EmailTemplateRepository::class,
46 function () {
47 return new EmailTemplateRepository();
48 }
49 );
50
51 // Register HTML Generator
52 $container->singleton(
53 EmailHtmlGenerator::class,
54 function () {
55 return new EmailHtmlGenerator();
56 }
57 );
58
59 // Register REST Controller
60 $container->singleton(
61 EmailTemplateRestController::class,
62 function ( Container $c ) {
63 return new EmailTemplateRestController(
64 $c->get( EmailTemplateRepository::class ),
65 $c->get( EmailHtmlGenerator::class )
66 );
67 }
68 );
69
70 // Register Block Registry
71 $container->singleton(
72 BlockRegistry::class,
73 function () {
74 return new BlockRegistry();
75 }
76 );
77
78 // Register Integration
79 $container->singleton(
80 EmailTemplateIntegration::class,
81 function () {
82 return new EmailTemplateIntegration();
83 }
84 );
85 }
86
87 /**
88 * {@inheritdoc}
89 */
90 public function boot( Container $container ): void {
91 // Initialize Post Type — needed even on free sites so that
92 // existing template posts in wp_posts continue to behave like
93 // the registered post type (admin column, capabilities, etc.).
94 $postType = $container->get( EmailTemplatePostType::class );
95 $postType->init();
96
97 // REST controller registration is OWNED BY addon-email-editor:
98 // its boot() picks the controller up from the same container
99 // and calls init() only when the addon is licensed + active.
100 // Free / unlicensed sites get no API surface, which is the
101 // intent of Pro-gating the editor + templates feature.
102
103 // Initialize Integration with CF7/Avada — used by the email
104 // pipeline for templates referenced in form settings, so it
105 // stays in Core (otherwise free users couldn't send templated
106 // confirmation mails for templates created earlier or via the
107 // legacy UI).
108 $integration = $container->get( EmailTemplateIntegration::class );
109 $integration->init();
110 }
111 }
112