PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
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 13.7.2 All 507 releases
← All changes | jetpack_vendor/automattic/jetpack-forms/src/class-jetpack-forms.php +24 -31 16.2-beta → 16.3-beta View file →
@@ -6,9 +6,9 @@
6 6 */
7 7
8 8 namespace Automattic\Jetpack\Forms;
9 9
10 -use Automattic\Jetpack\Feature_Flags\Feature_Flags;
10 +use Automattic\Jetpack\Current_Plan;
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,41 +15,19 @@
15 15 * Understands the Jetpack Forms package.
16 16 */
17 17 class Jetpack_Forms {
18 18
19 - const PACKAGE_VERSION = '8.0.1';
19 + const PACKAGE_VERSION = '8.3.0';
20 20
21 21 /**
22 - * Name of the feature flag gating field conditional logic.
22 + * Plan feature slug gating field conditional logic.
23 23 */
24 - const CONDITIONAL_LOGIC_FLAG = 'forms-conditional-logic';
24 + const CONDITIONAL_LOGIC_FEATURE = 'form-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 - /**
47 27 * Load the contact form module.
48 28 */
49 29 public static function load_contact_form() {
50 - self::register_feature_flags();
51 -
52 30 Util::init();
53 31
54 32 if ( self::is_feedback_dashboard_enabled() ) {
55 33 $dashboard = new Dashboard();
@@ -95,14 +73,17 @@
95 73 * @return boolean
96 74 */
97 75 public static function is_feedback_dashboard_enabled() {
98 76 /**
99 - * Enable the new Jetpack Forms dashboard.
77 + * Enable the Jetpack Forms dashboard.
100 78 *
79 + * Returning false hides the Forms admin menu entry and skips the dashboard
80 + * entirely. Unrelated to which dashboard renders — there is only one.
81 + *
101 82 * @module contact-form
102 83 * @since 0.3.0
103 84 *
104 - * @param bool false Should the new Jetpack Forms dashboard be enabled? Default to false.
85 + * @param bool $enabled Should the Jetpack Forms dashboard be enabled? Default true.
105 86 */
106 87 return apply_filters( 'jetpack_forms_dashboard_enable', true );
107 88 }
108 89
@@ -157,21 +138,33 @@
157 138 return apply_filters( 'jetpack_forms_is_integrations_enabled', true );
158 139 }
159 140
160 141 /**
161 - * Returns true if field conditional logic is enabled.
142 + * Returns true if the site's plan includes field conditional logic.
162 143 *
163 144 * One switch for the whole feature: the editor panel, the front-end show/hide, and the
164 145 * submission-time enforcement in validation and storage. Gating them together means a
165 146 * form can never hide a field from the visitor while still requiring it on submit.
166 147 *
167 - * Turning the flag off on a form that already has conditions is safe: the conditions are
148 + * Losing the plan on a form that already has conditions is safe: the conditions are
168 149 * simply ignored, so every field renders, validates and stores as an ordinary field.
169 150 *
170 151 * @return boolean
171 152 */
172 153 public static function is_conditional_logic_enabled() {
173 - return Feature_Flags::is_enabled( self::CONDITIONAL_LOGIC_FLAG );
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 );
174 167 }
175 168
176 169 /**
177 170 * Returns true if webhooks are enabled.