PluginProbe
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification / 5.6.3
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification v5.6.3
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 / Health / StaleProMarkersCheck.php

StaleProMarkersCheck.php in Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification 5.6.3, at src/Health/StaleProMarkersCheck.php

79 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 * Health check: no leftover Pro setup markers block a fresh install.
4 *
5 * @package Forge12\DoubleOptIn\Health
6 * @since 5.5.0
7 */
8
9 declare( strict_types=1 );
10
11 namespace Forge12\DoubleOptIn\Health;
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * Explains the second half of the "I reinstalled everything and nothing
19 * changed" ticket.
20 *
21 * bundle-pro records that it has migrated the licence and installed the
22 * bundled addons in one-shot options. It ships no `uninstall.php`, so
23 * deleting the plugin leaves those options behind — and a fresh install
24 * then finds them already set and skips both steps. The customer ends up
25 * with a Pro plugin that has no licence and no modules, and the SPA's
26 * install button answering `rest_no_route`, because the route lives in the
27 * bundle that never finished starting.
28 *
29 * Only flagged while bundle-pro is NOT active: with it running, the markers
30 * describe a completed setup and are exactly what they should be. The
31 * narrow rule is on purpose — a repair offered to someone whose site is
32 * fine is a repair that gets clicked for the wrong reason.
33 */
34 final class StaleProMarkersCheck implements HealthCheckInterface {
35
36 public function getId(): string {
37 return 'f12_doi_pro_setup_markers';
38 }
39
40 public function getLabel(): string {
41 return __( 'Pro setup markers', 'double-opt-in' );
42 }
43
44 public function getPackage(): string {
45 return 'core';
46 }
47
48 public function run(): HealthCheckResult {
49 $markers = LegacyProEnvironment::burnedMarkers();
50
51 if ( empty( $markers ) ) {
52 return new HealthCheckResult(
53 HealthCheckResult::STATUS_GOOD,
54 __( 'No leftover Pro setup markers', 'double-opt-in' ),
55 __( 'Nothing in the database would block a Pro installation from setting itself up.', 'double-opt-in' ),
56 'none'
57 );
58 }
59
60 if ( LegacyProEnvironment::isSuccessorActive() ) {
61 return new HealthCheckResult(
62 HealthCheckResult::STATUS_GOOD,
63 __( 'Pro setup markers belong to the running installation', 'double-opt-in' ),
64 __( 'Double Opt-In Pro is active and has completed its setup. The stored markers are expected.', 'double-opt-in' ),
65 'owned:' . count( $markers )
66 );
67 }
68
69 return new HealthCheckResult(
70 HealthCheckResult::STATUS_RECOMMENDED,
71 __( 'Leftover Pro setup markers will block a new installation', 'double-opt-in' ),
72 __( 'Double Opt-In Pro is not active, but this site still stores the markers saying its licence migration and module installation have already run. A fresh install would find them and skip both steps — no licence, no modules, and the "Install" button on the Add-ons screen failing with a routing error. Clearing them lets the setup run again. Your licence key and all form settings stay untouched.', 'double-opt-in' ),
73 'stale:' . count( $markers ),
74 __( 'Clear the setup markers', 'double-opt-in' ),
75 HealthRepairController::repairUrl( HealthRepairController::ACTION_RESET_MARKERS )
76 );
77 }
78 }
79