PluginProbe
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification / 5.4.0
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification v5.4.0
5.6.2 5.6.3 5.6.1 5.6.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 All 38 releases
double-opt-in / src / Providers / HealthServiceProvider.php

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

101 lines 2.7 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\SiteHealthIntegration;
16 use Forge12\DoubleOptIn\Health\StaleConsentFieldCheck;
17
18 if ( ! defined( 'ABSPATH' ) ) {
19 exit;
20 }
21
22 /**
23 * Class HealthServiceProvider
24 *
25 * Wires the health-check registry and its Site Health surfaces.
26 *
27 * Registration of *addon* checks happens through the
28 * `f12_doi_health_checks` filter, which the registry applies lazily on
29 * first read — so this provider does not need to run after addon boot,
30 * and addons do not need a Core new enough to know about this API.
31 *
32 * Only the Core's own tables are registered here. They are the three
33 * that `OnActivation.php` creates; if one of them is missing the plugin
34 * is broken in a way that has, historically, only shown up as a silent
35 * failure much later.
36 */
37 class HealthServiceProvider implements BootableProviderInterface {
38
39 /**
40 * {@inheritdoc}
41 */
42 public function register( Container $container ): void {
43 $container->singleton(
44 HealthCheckRegistry::class,
45 function () {
46 return new HealthCheckRegistry();
47 }
48 );
49 }
50
51 /**
52 * {@inheritdoc}
53 */
54 public function boot( Container $container ): void {
55 $registry = $container->get( HealthCheckRegistry::class );
56
57 $optInsUrl = admin_url( 'admin.php?page=f12-doi-admin' );
58
59 $registry->register(
60 new DatabaseTableHealthCheck(
61 'f12_doi_table_optin',
62 'core',
63 'f12_cf7_doubleoptin',
64 __( 'Opt-in records', 'double-opt-in' ),
65 __( 'Open Double Opt-In', 'double-opt-in' ),
66 $optInsUrl
67 )
68 );
69
70 $registry->register(
71 new DatabaseTableHealthCheck(
72 'f12_doi_table_categories',
73 'core',
74 'f12_cf7_doubleoptin_categories',
75 __( 'Opt-in categories', 'double-opt-in' ),
76 __( 'Open Double Opt-In', 'double-opt-in' ),
77 $optInsUrl
78 )
79 );
80
81 $registry->register(
82 new DatabaseTableHealthCheck(
83 'f12_doi_table_audit_log',
84 'core',
85 'f12_cf7_doubleoptin_audit_log',
86 __( 'Consent audit log', 'double-opt-in' ),
87 __( 'Open Double Opt-In', 'double-opt-in' ),
88 $optInsUrl
89 )
90 );
91
92 // Not a table check: this one asks whether the forms' consent
93 // settings still match the forms. A stale acceptance field does
94 // not break anything visibly — it quietly turns every opt-in of
95 // that form into consent evidence nobody ever confirmed.
96 $registry->register( new StaleConsentFieldCheck() );
97
98 ( new SiteHealthIntegration( $registry ) )->register();
99 }
100 }
101