PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
16.3 16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 All 508 releases
← All changes | jetpack_vendor/automattic/jetpack-forms/src/class-jetpack-forms.php +29 -19 16.3 → 16.3-a.1 View file →
@@ -6,9 +6,9 @@
6 6 */
7 7
8 8 namespace Automattic\Jetpack\Forms;
9 9
10 -use Automattic\Jetpack\Current_Plan;
10 +use Automattic\Jetpack\Feature_Flags\Feature_Flags;
11 11 use Automattic\Jetpack\Forms\ContactForm\Feedback_Source;
12 12 use Automattic\Jetpack\Forms\ContactForm\Util;
13 13 use Automattic\Jetpack\Forms\Dashboard\Dashboard;
14 14 /**
@@ -15,19 +15,41 @@
15 15 * Understands the Jetpack Forms package.
16 16 */
17 17 class Jetpack_Forms {
18 18
19 - const PACKAGE_VERSION = '8.3.0.1';
19 + const PACKAGE_VERSION = '8.1.0';
20 20
21 21 /**
22 - * Plan feature slug gating field conditional logic.
22 + * Name of the feature flag gating field conditional logic.
23 23 */
24 - const CONDITIONAL_LOGIC_FEATURE = 'form-conditional-logic';
24 + const CONDITIONAL_LOGIC_FLAG = 'forms-conditional-logic';
25 25
26 26 /**
27 + * Register the package's feature flags.
28 + *
29 + * Registration is unconditional and happens as the package loads, so the full set stays
30 + * discoverable through `Feature_Flags::all()` and nothing can call `is_enabled()` on an
31 + * unregistered flag.
32 + *
33 + * @return void
34 + */
35 + public static function register_feature_flags() {
36 + Feature_Flags::register(
37 + self::CONDITIONAL_LOGIC_FLAG,
38 + array(
39 + 'default' => false,
40 + 'description' => 'Show or hide a form field based on the answer to another field.',
41 + 'owner' => 'jetpack-forms',
42 + )
43 + );
44 + }
45 +
46 + /**
27 47 * Load the contact form module.
28 48 */
29 49 public static function load_contact_form() {
50 + self::register_feature_flags();
51 +
30 52 Util::init();
31 53
32 54 if ( self::is_feedback_dashboard_enabled() ) {
33 55 $dashboard = new Dashboard();
@@ -138,33 +160,21 @@
138 160 return apply_filters( 'jetpack_forms_is_integrations_enabled', true );
139 161 }
140 162
141 163 /**
142 - * Returns true if the site's plan includes field conditional logic.
164 + * Returns true if field conditional logic is enabled.
143 165 *
144 166 * One switch for the whole feature: the editor panel, the front-end show/hide, and the
145 167 * submission-time enforcement in validation and storage. Gating them together means a
146 168 * form can never hide a field from the visitor while still requiring it on submit.
147 169 *
148 - * Losing the plan on a form that already has conditions is safe: the conditions are
170 + * Turning the flag off on a form that already has conditions is safe: the conditions are
149 171 * simply ignored, so every field renders, validates and stores as an ordinary field.
150 172 *
151 173 * @return boolean
152 174 */
153 175 public static function is_conditional_logic_enabled() {
154 - // Fail closed on WordPress.com until its WPCOM_Features copy knows the slug, or supports()
155 - // falls back to the Jetpack free plan, which includes it. Drop once that copy ships.
156 - $supported = ( ! function_exists( 'wpcom_feature_exists' ) || wpcom_feature_exists( self::CONDITIONAL_LOGIC_FEATURE ) )
157 - && Current_Plan::supports( self::CONDITIONAL_LOGIC_FEATURE );
158 -
159 - /**
160 - * Whether field conditional logic is available on this site.
161 - *
162 - * @since 8.3.0
163 - *
164 - * @param bool $supported Whether the site's plan includes conditional logic.
165 - */
166 - return (bool) apply_filters( 'jetpack_forms_conditional_logic_enabled', $supported );
176 + return Feature_Flags::is_enabled( self::CONDITIONAL_LOGIC_FLAG );
167 177 }
168 178
169 179 /**
170 180 * Returns true if webhooks are enabled.