| 1 |
<?php |
| 2 |
/** |
| 3 |
* Addon Catalog — canonical metadata for every Double Opt-In addon. |
| 4 |
* |
| 5 |
* Single source of truth for addon names and descriptions. Used by: |
| 6 |
* - the Addons admin page to render a marketplace grid (with state- |
| 7 |
* aware CTAs that depend on whether the user has the addon |
| 8 |
* installed, active, or has a bundle license), |
| 9 |
* - the License-page Features Overview to surface bundle-covered |
| 10 |
* addons even before they are installed (via bundle-pro's hook |
| 11 |
* into the `f12_doi_license_features` filter), |
| 12 |
* - bundle-pro's installer to humanize addon IDs in the install row. |
| 13 |
* |
| 14 |
* Under bundle-only licensing there are no per-addon purchase pages: |
| 15 |
* the single Pro bundle unlocks every module, so the UI points users |
| 16 |
* at one bundle upgrade CTA rather than a per-addon buy link. |
| 17 |
* |
| 18 |
* Lives in Core (not bundle-pro) so the marketplace UI works on free |
| 19 |
* sites without bundle-pro: the page can still show what addons exist |
| 20 |
* and point the user at the bundle upgrade. |
| 21 |
* |
| 22 |
* @package Forge12\DoubleOptIn\Addon |
| 23 |
* @since 4.4.0 |
| 24 |
*/ |
| 25 |
|
| 26 |
namespace Forge12\DoubleOptIn\Addon; |
| 27 |
|
| 28 |
if ( ! defined( 'ABSPATH' ) ) { |
| 29 |
exit; |
| 30 |
} |
| 31 |
|
| 32 |
final class AddonCatalog { |
| 33 |
|
| 34 |
/** |
| 35 |
* Canonical catalog metadata. |
| 36 |
* |
| 37 |
* Keep aligned with `AddonManifest::getCoveredAddonIds()` in |
| 38 |
* bundle-pro. Backward-compat aliases (`pro-bundle`, `validators`) |
| 39 |
* are intentionally absent — they are internal license markers, |
| 40 |
* not user-facing addons. |
| 41 |
* |
| 42 |
* @return array<string, array{name:string,description:string,pluginFile:string,bundleMember:bool}> |
| 43 |
*/ |
| 44 |
public static function entries(): array { |
| 45 |
$entry = static function ( string $id, string $name, string $description, bool $bundleMember = true ): array { |
| 46 |
$externalSlug = 'double-opt-in-' . $id; |
| 47 |
return array( |
| 48 |
'id' => $id, |
| 49 |
'name' => $name, |
| 50 |
'description' => $description, |
| 51 |
'pluginFile' => $externalSlug . '/' . $externalSlug . '.php', |
| 52 |
'bundleMember' => $bundleMember, |
| 53 |
); |
| 54 |
}; |
| 55 |
|
| 56 |
$entries = array( |
| 57 |
'analytics' => $entry( |
| 58 |
'analytics', |
| 59 |
__( 'Analytics Dashboard', 'double-opt-in' ), |
| 60 |
__( 'Visualize opt-in funnel performance, conversion rates, and source breakdowns directly in the WP admin.', 'double-opt-in' ) |
| 61 |
), |
| 62 |
'reminder' => $entry( |
| 63 |
'reminder', |
| 64 |
__( 'Reminder Emails', 'double-opt-in' ), |
| 65 |
__( 'Automatically nudge users who never confirmed their opt-in with one or more reminder emails.', 'double-opt-in' ) |
| 66 |
), |
| 67 |
'opt-out' => $entry( |
| 68 |
'opt-out', |
| 69 |
__( 'Opt-Out System', 'double-opt-in' ), |
| 70 |
__( 'GDPR-friendly one-click unsubscribe links and an opt-out audit trail per recipient.', 'double-opt-in' ) |
| 71 |
), |
| 72 |
'user-registration' => $entry( |
| 73 |
'user-registration', |
| 74 |
__( 'Auto User Creation', 'double-opt-in' ), |
| 75 |
__( 'Create a WordPress user account automatically once a confirmation is recorded.', 'double-opt-in' ) |
| 76 |
), |
| 77 |
'mx-validator' => $entry( |
| 78 |
'mx-validator', |
| 79 |
__( 'MX Email Validation', 'double-opt-in' ), |
| 80 |
__( 'Reject addresses whose domain has no valid MX record before they hit your queue.', 'double-opt-in' ) |
| 81 |
), |
| 82 |
'domain-blocklist' => $entry( |
| 83 |
'domain-blocklist', |
| 84 |
__( 'Domain Blocklist', 'double-opt-in' ), |
| 85 |
__( 'Block disposable-mail providers and self-hosted lists of unwanted domains at submit time.', 'double-opt-in' ) |
| 86 |
), |
| 87 |
'unique-email' => $entry( |
| 88 |
'unique-email', |
| 89 |
__( 'Unique Email Validation', 'double-opt-in' ), |
| 90 |
__( 'Refuse duplicate addresses across all your forms — one email, one opt-in.', 'double-opt-in' ) |
| 91 |
), |
| 92 |
'single-mail-registration' => $entry( |
| 93 |
'single-mail-registration', |
| 94 |
__( 'Single-Mail Registration', 'double-opt-in' ), |
| 95 |
__( 'Replace multi-step signup flows with a single email field; the rest is filled in after confirm.', 'double-opt-in' ) |
| 96 |
), |
| 97 |
'consent-export' => $entry( |
| 98 |
'consent-export', |
| 99 |
__( 'Consent Export', 'double-opt-in' ), |
| 100 |
__( 'Export full consent history for any opt-in as audit-ready CSV or JSON.', 'double-opt-in' ) |
| 101 |
), |
| 102 |
'conditional' => $entry( |
| 103 |
'conditional', |
| 104 |
__( 'Conditional Templates', 'double-opt-in' ), |
| 105 |
__( 'Pick which opt-in email a user sees based on form context, language, or category.', 'double-opt-in' ) |
| 106 |
), |
| 107 |
'elementor' => $entry( |
| 108 |
'elementor', |
| 109 |
__( 'Elementor Forms Integration', 'double-opt-in' ), |
| 110 |
__( 'Drop-in double opt-in for any Elementor Pro form, no code required.', 'double-opt-in' ) |
| 111 |
), |
| 112 |
'wpforms' => $entry( |
| 113 |
'wpforms', |
| 114 |
__( 'WPForms Integration', 'double-opt-in' ), |
| 115 |
__( 'Add a confirmation step to any WPForms form with one toggle in the form settings.', 'double-opt-in' ) |
| 116 |
), |
| 117 |
'gravity-forms' => $entry( |
| 118 |
'gravity-forms', |
| 119 |
__( 'Gravity Forms Integration', 'double-opt-in' ), |
| 120 |
__( 'Wire any Gravity Forms feed through a real double opt-in confirmation.', 'double-opt-in' ) |
| 121 |
), |
| 122 |
'avada' => $entry( |
| 123 |
'avada', |
| 124 |
__( 'Avada Forms Integration', 'double-opt-in' ), |
| 125 |
__( 'Restore the Avada Fusion-Forms support that used to ship inside the Pro monolith.', 'double-opt-in' ) |
| 126 |
), |
| 127 |
// Pro feature: SPA-integrated visual email template |
| 128 |
// editor + the Email Templates list/management page. |
| 129 |
// Bundled via the standard Pro bundle license; stand- |
| 130 |
// alone keys are also accepted by addon-email-editor's |
| 131 |
// license bootstrap. |
| 132 |
'email-editor' => $entry( |
| 133 |
'email-editor', |
| 134 |
__( 'Email Editor', 'double-opt-in' ), |
| 135 |
__( 'SPA-integrated visual email template editor and templates manager. Drag-and-drop blocks, custom layouts, and full template lifecycle.', 'double-opt-in' ) |
| 136 |
), |
| 137 |
'cleverreach' => $entry( |
| 138 |
'cleverreach', |
| 139 |
__( 'CleverReach', 'double-opt-in' ), |
| 140 |
__( 'CleverReach API integration: OAuth handshake, list synchronisation, and subscriber export. Forwards confirmed opt-ins to your CleverReach account.', 'double-opt-in' ) |
| 141 |
), |
| 142 |
); |
| 143 |
|
| 144 |
return $entries; |
| 145 |
} |
| 146 |
|
| 147 |
/** |
| 148 |
* Look up a single catalog entry by addon ID. Returns null when the |
| 149 |
* ID is unknown — caller should fall back to humanising the ID. |
| 150 |
* |
| 151 |
* @return array{id:string,name:string,description:string,pluginFile:string,bundleMember:bool}|null |
| 152 |
*/ |
| 153 |
public static function get( string $id ): ?array { |
| 154 |
$entries = self::entries(); |
| 155 |
return $entries[ $id ] ?? null; |
| 156 |
} |
| 157 |
} |
| 158 |
|