PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.16.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.16.1
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/helpers/FrmStylesPreviewHelper.php +14 -64 6.346.16.1 View file →
@@ -32,9 +32,8 @@
32 32 private $default_label_position_field_ids;
33 33
34 34 /**
35 35 * @param int|string $form_id
36 - *
37 36 * @return void
38 37 */
39 38 public function __construct( $form_id ) {
40 39 $this->form_id = (int) $form_id;
@@ -56,57 +55,15 @@
56 55 add_filter( 'frm_run_honeypot', '__return_false' );
57 56 $this->hide_captcha_fields();
58 57 $this->disable_javascript_validation();
59 58 $this->add_a_div_class_for_default_label_positions();
60 - $this->add_a_div_class_for_style_driven_alignment();
61 59 }
62 60
63 61 /**
64 - * Add a marker class to radio and checkbox fields that use the style's option
65 - * alignment setting rather than a field level override.
66 - *
67 - * Only fields with this class change when the radio or checkbox alignment style
68 - * setting is updated in the styler preview. Fields with their own alignment
69 - * override are left untouched.
70 - *
71 - * @since 6.32
72 - *
73 - * @return void
74 - */
75 - private function add_a_div_class_for_style_driven_alignment() {
76 - add_filter(
77 - 'frm_field_div_classes',
78 - /**
79 - * @param string $classes
80 - * @param array|object $field
81 - *
82 - * @return string
83 - */
84 - function ( $classes, $field ) {
85 - if ( ! FrmField::is_radio( $field ) && ! FrmField::is_checkbox( $field ) ) {
86 - return $classes;
87 - }
88 -
89 - // Mirror FrmFieldType::get_container_class(): an override only exists in Pro.
90 - $align = FrmAppHelper::pro_is_installed() ? FrmField::get_option( $field, 'align' ) : '';
91 -
92 - if ( ! $align ) {
93 - $classes .= ' frm-default-option-align';
94 - }
95 -
96 - return $classes;
97 - },
98 - 10,
99 - 2
100 - );
101 - }
102 -
103 - /**
104 62 * Add a frm-default-label-position class to any field with a default label position.
105 63 * A field with a custom label position shouldn't ever change in the styler preview.
106 64 *
107 65 * @since 6.0.1
108 - *
109 66 * @return void
110 67 */
111 68 private function add_a_div_class_for_default_label_positions() {
112 69 // Only fields with no label position set hit this filter, so track those for the frm_field_div_classes filter.
@@ -114,9 +71,8 @@
114 71 'frm_html_label_position',
115 72 /**
116 73 * @param string $position
117 74 * @param array|object $field
118 - *
119 75 * @return string
120 76 */
121 77 function ( $position, $field ) {
122 78 if ( is_array( $field ) ) {
@@ -132,9 +88,8 @@
132 88 'frm_field_div_classes',
133 89 /**
134 90 * @param string $classes
135 91 * @param array|object $field
136 - *
137 92 * @return string
138 93 */
139 94 function ( $classes, $field ) {
140 95 if ( is_array( $field ) && in_array( (int) $field['id'], $this->default_label_position_field_ids, true ) ) {
@@ -160,13 +115,15 @@
160 115 /**
161 116 * @param bool $show
162 117 * @param string $field_type
163 118 * @param string $target_field_type
164 - *
165 119 * @return bool
166 120 */
167 121 function ( $show, $field_type ) {
168 - return 'captcha' === $field_type ? false : $show;
122 + if ( 'captcha' === $field_type ) {
123 + $show = false;
124 + }
125 + return $show;
169 126 },
170 127 10,
171 128 2
172 129 );
@@ -186,9 +143,8 @@
186 143 'frm_form_object',
187 144 /**
188 145 * @param stdClass|null $form
189 146 * @param int $form_id
190 - *
191 147 * @return stdClass|null
192 148 */
193 149 function ( $form ) {
194 150 if ( is_object( $form ) && is_array( $form->options ) ) {
@@ -210,9 +166,8 @@
210 166
211 167 $target_form_preview_html = FrmFormsController::show_form( $this->form_id, '', 'auto', 'auto' );
212 168
213 169 $this->form_includes_captcha = wp_script_is( 'captcha-api', 'enqueued' );
214 -
215 170 if ( $this->form_includes_captcha ) {
216 171 // If a form includes a CAPTCHA field, don't try to load the CAPTCHA scripts for the visual styler preview.
217 172 wp_dequeue_script( 'captcha-api' );
218 173 }
@@ -226,20 +181,21 @@
226 181
227 182 /**
228 183 * @since 6.0
229 184 *
185 + * @todo Only show the note once for a form per user per month or something.
186 + *
230 187 * @return array<string>
231 188 */
232 189 public function get_notes_for_styler_preview() {
233 - $notes = array();
190 + $notes = array();
191 +
234 192 $fallback_form_note = $this->get_fallback_form_note();
235 -
236 193 if ( is_string( $fallback_form_note ) ) {
237 194 $notes[] = $fallback_form_note;
238 195 }
239 196
240 197 $frm_settings = FrmAppHelper::get_settings();
241 -
242 198 if ( 'none' === $frm_settings->load_style ) {
243 199 $notes[] = function () {
244 200 printf(
245 201 // translators: %1$s: Anchor tag open, %2$s: Anchor tag close.
@@ -249,14 +205,17 @@
249 205 );
250 206 };
251 207 }
252 208
209 + if ( class_exists( 'FrmProStylesController' ) && ! class_exists( 'FrmProStylesPreviewHelper' ) ) {
210 + $notes[] = __( 'You are using an outdated version of Formidable Pro. Please update to version 6.0 to get access to all styler features.', 'formidable' );
211 + }
212 +
253 213 if ( is_callable( 'FrmProStylesController::get_notes_for_styler_preview' ) ) {
254 214 $notes = array_merge( $notes, FrmProStylesController::get_notes_for_styler_preview() );
255 215 }
256 216
257 217 $disabled_features_note = $this->get_disabled_features_note();
258 -
259 218 if ( is_string( $disabled_features_note ) ) {
260 219 $notes[] = $disabled_features_note;
261 220 }
262 221
@@ -291,9 +250,8 @@
291 250 *
292 251 * @param stdClass|WP_Post $style A new style is not a WP_Post object.
293 252 * @param WP_Post $default_style
294 253 * @param string $view Either 'list' or 'edit'.
295 - *
296 254 * @return array<string>
297 255 */
298 256 public function get_warnings_for_styler_preview( $style, $default_style, $view ) {
299 257 $warnings = array();
@@ -309,9 +267,8 @@
309 267 * @since 6.0
310 268 *
311 269 * @param int $style_id
312 270 * @param int $default_style_id
313 - *
314 271 * @return bool
315 272 */
316 273 private function should_show_multiple_forms_warning( $style_id, $default_style_id ) {
317 274 $is_default_style = $style_id === $default_style_id;
@@ -318,9 +275,8 @@
318 275
319 276 if ( ! $is_default_style ) {
320 277 // Also check for the conversational default.
321 278 $conversational_style_id = FrmDb::get_var( 'posts', array( 'post_name' => 'lines-no-boxes' ), 'ID' );
322 -
323 279 if ( $conversational_style_id && (int) $conversational_style_id === $style_id ) {
324 280 $is_default_style = true;
325 281 }
326 282 }
@@ -347,9 +303,8 @@
347 303 /**
348 304 * @since 6.0
349 305 *
350 306 * @param WP_Styles $styles
351 - *
352 307 * @return void
353 308 */
354 309 public static function disable_conflicting_wp_admin_css( $styles ) {
355 310 if ( ! is_callable( array( $styles, 'remove' ) ) || ! array_key_exists( 'wp-admin', $styles->registered ) ) {
@@ -358,10 +313,9 @@
358 313
359 314 $styles->remove( 'edit' );
360 315
361 316 $wp_admin_dependencies = $styles->registered['wp-admin']->deps;
362 - $edit_key = array_search( 'edit', $wp_admin_dependencies, true );
363 -
317 + $edit_key = array_search( 'edit', $wp_admin_dependencies );
364 318 if ( false === $edit_key ) {
365 319 return;
366 320 }
367 321
@@ -384,9 +338,8 @@
384 338 public static function get_additional_preview_style( $settings, $is_preview = false ) {
385 339 if ( ! $is_preview ) {
386 340 return;
387 341 }
388 -
389 342 $radio_display_type = 'inline' === $settings['radio_align'] ? 'inline-block' : 'block';
390 343 $check_display_type = 'inline' === $settings['check_align'] ? 'inline-block' : 'block';
391 344
392 345 $style = '#frm_style_preview .with_frm_style input[type=text],
@@ -420,16 +373,13 @@
420 373 * @since 6.0
421 374 *
422 375 * @param WP_Styles $styles
423 376 * @param string $key
424 - *
425 377 * @return void
426 378 */
427 379 private static function remove_wp_admin_dependency( $styles, $key ) {
428 380 $dependencies = $styles->registered['wp-admin']->deps;
429 - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
430 - $index = array_search( $key, $dependencies );
431 -
381 + $index = array_search( $key, $dependencies );
432 382 if ( false === $index ) {
433 383 return;
434 384 }
435 385