PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/controllers/FrmTestModeController.php +23 -10 6.25 → trunk View file →
@@ -13,8 +13,9 @@
13 13 *
14 14 * @since 6.25
15 15 *
16 16 * @param string $html
17 + *
17 18 * @return string
18 19 */
19 20 public static function maybe_add_test_mode_container( $html ) {
20 21 if ( '' === $html || ! self::should_add_test_mode_container() ) {
@@ -25,21 +26,19 @@
25 26 * @since 6.25
26 27 */
27 28 do_action( 'frm_test_mode_container' );
28 29
29 - if ( false !== strpos( $html, '<div class="frm_form_fields' ) ) {
30 - $html = preg_replace(
30 + if ( str_contains( $html, '<div class="frm_form_fields' ) ) {
31 + return preg_replace(
31 32 '/<div class="frm_form_fields/',
32 33 self::get_testing_mode_container() . '<div class="frm_form_fields',
33 34 $html,
34 35 1
35 36 );
36 - } else {
37 - // If there no form, add before an error message.
38 - $html = '<div class="with_frm_style">' . self::get_testing_mode_container() . '</div>' . $html;
39 37 }
40 38
41 - return $html;
39 + // If there no form, add before an error message.
40 + return '<div class="with_frm_style">' . self::get_testing_mode_container() . '</div>' . $html;
42 41 }
43 42
44 43 /**
45 44 * @since 6.25
@@ -84,18 +83,22 @@
84 83 * @return void
85 84 */
86 85 private static function render_testing_mode_container() {
87 86 $form_key = self::get_form_key_from_request();
87 +
88 88 if ( ! $form_key ) {
89 89 return;
90 90 }
91 91
92 92 $form = FrmForm::getOne( $form_key );
93 +
93 94 if ( ! $form ) {
94 95 return;
95 96 }
96 97
97 98 if ( ! empty( $form->options['chat'] ) ) {
99 + // Track view test mode with chat form.
100 + FrmUsageController::update_flows_data( 'view_test_mode', 'chat_form' );
98 101 echo '<div class="frm_note_style">' . esc_html__( 'Test Mode is currently not supported for conversational forms.', 'formidable' ) . '</div>';
99 102 return;
100 103 }
101 104
@@ -128,13 +131,15 @@
128 131 'style' => 'margin-left: auto;',
129 132 );
130 133
131 134 $oneclick_data = FrmAddonsController::install_link( 'ai' );
135 +
132 136 if ( isset( $oneclick_data['url'] ) ) {
133 137 $ai_install_span_attrs['data-oneclick'] = json_encode( $oneclick_data );
134 138 }
135 139
136 140 $oneclick_data = FrmAddonsController::install_link( 'test-mode' );
141 +
137 142 if ( isset( $oneclick_data['url'] ) ) {
138 143 $test_mode_install_span_attrs['data-oneclick'] = json_encode( $oneclick_data );
139 144 }
140 145
@@ -139,8 +144,12 @@
139 144 }
140 145
141 146 self::include_svg();
142 147
148 + if ( ! $enabled ) {
149 + FrmUsageController::update_flows_data( 'view_test_mode', 'no_addon' );
150 + }
151 +
143 152 include FrmAppHelper::plugin_path() . '/classes/views/test-mode/container.php';
144 153 }
145 154
146 155 /**
@@ -164,18 +173,21 @@
164 173 * @return false|string
165 174 */
166 175 private static function get_form_key_from_request() {
167 176 $form_key = FrmAppHelper::simple_get( 'form' );
177 +
168 178 if ( $form_key ) {
169 179 return $form_key;
170 180 }
171 181
172 182 $form_key = FrmAppHelper::get_post_param( 'form', '', 'sanitize_text_field' );
183 +
173 184 if ( $form_key ) {
174 185 return $form_key;
175 186 }
176 187
177 188 $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'sanitize_text_field' );
189 +
178 190 if ( $form_id && is_numeric( $form_id ) ) {
179 191 return FrmForm::get_key_by_id( $form_id );
180 192 }
181 193
@@ -187,8 +199,9 @@
187 199 *
188 200 * @since 6.25
189 201 *
190 202 * @param array $form_actions
203 + *
191 204 * @return array
192 205 */
193 206 private static function get_enabled_form_action_ids( $form_actions ) {
194 207 $all_form_action_ids = wp_list_pluck( $form_actions, 'ID' );
@@ -215,9 +228,9 @@
215 228 if ( self::test_mode_addon_exists() ) {
216 229 return false;
217 230 }
218 231
219 - return ! in_array( FrmAddonsController::license_type(), array( 'plus', 'business', 'elite' ) );
232 + return ! in_array( FrmAddonsController::license_type(), array( 'plus', 'business', 'elite' ), true );
220 233 }
221 234
222 235 /**
223 236 * Determine if the Test Mode add-on is installed and active.
@@ -364,11 +377,11 @@
364 377 // Enqueue multiselect dropdown requirements.
365 378 $plugin_url = FrmAppHelper::plugin_url();
366 379 $version = FrmAppHelper::plugin_version();
367 380
368 - wp_register_script( 'popper', FrmAppHelper::plugin_url() . '/js/popper.min.js', array( 'jquery' ), '1.16.0', true );
369 - wp_register_script( 'bootstrap_tooltip', $plugin_url . '/js/bootstrap.min.js', array( 'jquery', 'popper' ), '4.6.1', true );
370 - wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '1.1.1', true );
381 + wp_register_script( 'popper', FrmAppHelper::plugin_url() . '/js/popper.min.js', array(), '2.11.8', true );
382 + wp_register_script( 'bootstrap_tooltip', $plugin_url . '/js/bootstrap.min.js', array( 'jquery', 'popper' ), '5.0.2', true );
383 + wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '2.0', true );
371 384 wp_register_script( 'formidable_dom', $plugin_url . '/js/admin/dom.js', array( 'jquery', 'jquery-ui-dialog', 'wp-i18n' ), $version, true );
372 385
373 386 wp_enqueue_script( 'bootstrap-multiselect' );
374 387 wp_enqueue_script( 'formidable_dom' );