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 / HealthServiceProvider.php

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

113 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Health Service Provider
4 *
5 * @package Forge12\DoubleOptIn\Providers
6 * @since 5.3.0
7 */
8
9 namespace Forge12\DoubleOptIn\Providers;
10
11 use Forge12\DoubleOptIn\Container\BootableProviderInterface;
12 use Forge12\DoubleOptIn\Container\Container;
13 use Forge12\DoubleOptIn\Health\DatabaseTableHealthCheck;
14 use Forge12\DoubleOptIn\Health\HealthCheckRegistry;
15 use Forge12\DoubleOptIn\Health\HealthRepairController;
16 use Forge12\DoubleOptIn\Health\LegacyMonolithCheck;
17 use Forge12\DoubleOptIn\Health\SiteHealthIntegration;
18 use Forge12\DoubleOptIn\Health\StaleConsentFieldCheck;
19 use Forge12\DoubleOptIn\Health\StaleProMarkersCheck;
20
21 if ( ! defined( 'ABSPATH' ) ) {
22 exit;
23 }
24
25 /**
26 * Class HealthServiceProvider
27 *
28 * Wires the health-check registry and its Site Health surfaces.
29 *
30 * Registration of *addon* checks happens through the
31 * `f12_doi_health_checks` filter, which the registry applies lazily on
32 * first read — so this provider does not need to run after addon boot,
33 * and addons do not need a Core new enough to know about this API.
34 *
35 * Only the Core's own tables are registered here. They are the three
36 * that `OnActivation.php` creates; if one of them is missing the plugin
37 * is broken in a way that has, historically, only shown up as a silent
38 * failure much later.
39 */
40 class HealthServiceProvider implements BootableProviderInterface {
41
42 /**
43 * {@inheritdoc}
44 */
45 public function register( Container $container ): void {
46 $container->singleton(
47 HealthCheckRegistry::class,
48 function () {
49 return new HealthCheckRegistry();
50 }
51 );
52 }
53
54 /**
55 * {@inheritdoc}
56 */
57 public function boot( Container $container ): void {
58 $registry = $container->get( HealthCheckRegistry::class );
59
60 $optInsUrl = admin_url( 'admin.php?page=f12-doi-admin' );
61
62 $registry->register(
63 new DatabaseTableHealthCheck(
64 'f12_doi_table_optin',
65 'core',
66 'f12_cf7_doubleoptin',
67 __( 'Opt-in records', 'double-opt-in' ),
68 __( 'Open Double Opt-In', 'double-opt-in' ),
69 $optInsUrl
70 )
71 );
72
73 $registry->register(
74 new DatabaseTableHealthCheck(
75 'f12_doi_table_categories',
76 'core',
77 'f12_cf7_doubleoptin_categories',
78 __( 'Opt-in categories', 'double-opt-in' ),
79 __( 'Open Double Opt-In', 'double-opt-in' ),
80 $optInsUrl
81 )
82 );
83
84 $registry->register(
85 new DatabaseTableHealthCheck(
86 'f12_doi_table_audit_log',
87 'core',
88 'f12_cf7_doubleoptin_audit_log',
89 __( 'Consent audit log', 'double-opt-in' ),
90 __( 'Open Double Opt-In', 'double-opt-in' ),
91 $optInsUrl
92 )
93 );
94
95 // Not a table check: this one asks whether the forms' consent
96 // settings still match the forms. A stale acceptance field does
97 // not break anything visibly — it quietly turns every opt-in of
98 // that form into consent evidence nobody ever confirmed.
99 $registry->register( new StaleConsentFieldCheck() );
100
101 // The two checks around the Pro 3.x -> 4.x upgrade. They live in
102 // free Core on purpose: both describe a site where Pro is broken
103 // or absent, so a check shipped inside bundle-pro would be the one
104 // thing not loaded when it is needed.
105 $registry->register( new LegacyMonolithCheck() );
106 $registry->register( new StaleProMarkersCheck() );
107
108 ( new HealthRepairController() )->register();
109
110 ( new SiteHealthIntegration( $registry ) )->register();
111 }
112 }
113