PluginProbe
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification / 5.8.0
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification v5.8.0
5.8.0 5.8.1 5.7.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 All 41 releases
← All changes | src/EmailTemplates/BlockRegistry.php +31 -76 5.6.3 → 5.8.0 View file →
@@ -1,10 +1,17 @@
1 1 <?php
2 2 /**
3 3 * Block Registry
4 4 *
5 - * Central registry for email editor blocks with Free/Pro availability.
5 + * Which block types the email renderer knows.
6 6 *
7 + * Up to Core 5.7 this class also decided, by licence, which blocks and how
8 + * many templates were allowed. Core on wordpress.org may not lock
9 + * functionality behind a licence (plugin guideline 5), and editing
10 + * templates is the email editor add-on's feature anyway; since 5.8 nothing
11 + * here depends on a licence. The methods the add-on up to 1.0.5 calls are
12 + * kept so an older add-on keeps working, but they no longer restrict.
13 + *
7 14 * @package Forge12\DoubleOptIn\EmailTemplates
8 15 * @since 4.2.0
9 16 */
10 17
@@ -15,15 +22,13 @@
15 22 }
16 23
17 24 /**
18 25 * Class BlockRegistry
19 - *
20 - * Manages block availability based on Free/Pro status.
21 26 */
22 27 class BlockRegistry {
23 28
24 29 /**
25 - * Blocks available in the Free version.
30 + * Basic blocks.
26 31 *
27 32 * @var string[]
28 33 */
29 34 const FREE_BLOCKS = array(
@@ -43,9 +48,10 @@
43 48 'placeholder-custom',
44 49 );
45 50
46 51 /**
47 - * Blocks that require the Pro version.
52 + * Blocks the editor add-on labels as Pro. The renderer handles them
53 + * like any other block.
48 54 *
49 55 * @var string[]
50 56 */
51 57 const PRO_BLOCKS = array(
@@ -59,42 +65,34 @@
59 65 'conditional-content',
60 66 );
61 67
62 68 /**
63 - * Get the template limit based on Pro status.
69 + * Maximum number of published templates: no limit.
64 70 *
65 - * @return int Maximum number of published templates allowed.
71 + * @deprecated 5.8.0 Kept for the email editor add-on up to 1.0.5.
66 72 */
67 73 public function getTemplateLimit(): int {
68 - return $this->isProActive() ? PHP_INT_MAX : 1;
74 + return PHP_INT_MAX;
69 75 }
70 76
71 77 /**
72 - * Check if Pro is active.
78 + * Always true: Core no longer checks licences here.
73 79 *
74 - * @return bool
80 + * @deprecated 5.8.0 Kept for the email editor add-on up to 1.0.5, which
81 + * only runs with a licence anyway.
75 82 */
76 83 public function isProActive(): bool {
77 - /**
78 - * Filter to check if the Pro version is active and licensed.
79 - *
80 - * @param bool $isActive Whether Pro is active. Default false.
81 - *
82 - * @since 4.2.0
83 - */
84 - return (bool) apply_filters( 'f12_doi_is_pro_active', false );
84 + return true;
85 85 }
86 86
87 87 /**
88 - * Get block availability for all blocks.
88 + * Every known block, all available.
89 89 *
90 - * Returns an associative array where each key is a block type
91 - * and the value indicates its availability status.
90 + * @deprecated 5.8.0 Kept for the email editor add-on up to 1.0.5.
92 91 *
93 - * @return array
92 + * @return array<string, array{type: string, available: bool, requiresPro: bool}>
94 93 */
95 94 public function getBlockAvailability(): array {
96 - $isProActive = $this->isProActive();
97 95 $availability = array();
98 96
99 97 foreach ( self::FREE_BLOCKS as $blockType ) {
100 98 $availability[ $blockType ] = array(
@@ -106,78 +104,35 @@
106 104
107 105 foreach ( self::PRO_BLOCKS as $blockType ) {
108 106 $availability[ $blockType ] = array(
109 107 'type' => $blockType,
110 - 'available' => $isProActive,
108 + 'available' => true,
111 109 'requiresPro' => true,
112 110 );
113 111 }
114 112
115 - /**
116 - * Filter block availability.
117 - *
118 - * Allows extensions to modify block availability.
119 - *
120 - * @param array $availability The block availability array.
121 - * @param bool $isProActive Whether Pro is active.
122 - *
123 - * @since 4.2.0
124 - */
125 - return apply_filters( 'f12_doi_block_availability', $availability, $isProActive );
113 + return $availability;
126 114 }
127 115
128 116 /**
129 - * Check if a specific block type is available.
117 + * Every block type is available.
130 118 *
119 + * @deprecated 5.8.0
120 + *
131 121 * @param string $blockType The block type to check.
132 - *
133 - * @return bool True if the block is available.
134 122 */
135 123 public function isBlockAvailable( string $blockType ): bool {
136 - if ( in_array( $blockType, self::FREE_BLOCKS, true ) ) {
137 - return true;
138 - }
139 -
140 - if ( in_array( $blockType, self::PRO_BLOCKS, true ) ) {
141 - return $this->isProActive();
142 - }
143 -
144 - // Unknown block types are allowed by default
145 124 return true;
146 125 }
147 126
148 127 /**
149 - * Validate blocks recursively, checking that no Pro blocks are used without a license.
128 + * No block is refused.
150 129 *
151 - * @param array $blocks The blocks array to validate.
130 + * @deprecated 5.8.0
152 131 *
153 - * @return array Array of invalid block types found. Empty if all valid.
132 + * @param array $blocks The blocks array.
133 + * @return array Always empty.
154 134 */
155 135 public function validateBlocks( array $blocks ): array {
156 - $invalidBlocks = array();
157 - $this->validateBlocksRecursive( $blocks, $invalidBlocks );
158 -
159 - return $invalidBlocks;
160 - }
161 -
162 - /**
163 - * Recursively validate blocks.
164 - *
165 - * @param array $blocks The blocks to validate.
166 - * @param array $invalidBlocks Reference to collect invalid block types.
167 - *
168 - * @return void
169 - */
170 - private function validateBlocksRecursive( array $blocks, array &$invalidBlocks ): void {
171 - foreach ( $blocks as $block ) {
172 - $type = $block['type'] ?? '';
173 -
174 - if ( ! empty( $type ) && ! $this->isBlockAvailable( $type ) ) {
175 - $invalidBlocks[] = $type;
176 - }
177 -
178 - if ( ! empty( $block['children'] ) && is_array( $block['children'] ) ) {
179 - $this->validateBlocksRecursive( $block['children'], $invalidBlocks );
180 - }
181 - }
136 + return array();
182 137 }
183 138 }