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/helpers/FrmStylesPreviewHelper.php +46 -14 6.26 → trunk View file →
@@ -56,11 +56,52 @@
56 56 add_filter( 'frm_run_honeypot', '__return_false' );
57 57 $this->hide_captcha_fields();
58 58 $this->disable_javascript_validation();
59 59 $this->add_a_div_class_for_default_label_positions();
60 + $this->add_a_div_class_for_style_driven_alignment();
60 61 }
61 62
62 63 /**
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 + /**
63 104 * Add a frm-default-label-position class to any field with a default label position.
64 105 * A field with a custom label position shouldn't ever change in the styler preview.
65 106 *
66 107 * @since 6.0.1
@@ -123,12 +164,9 @@
123 164 *
124 165 * @return bool
125 166 */
126 167 function ( $show, $field_type ) {
127 - if ( 'captcha' === $field_type ) {
128 - $show = false;
129 - }
130 - return $show;
168 + return 'captcha' === $field_type ? false : $show;
131 169 },
132 170 10,
133 171 2
134 172 );
@@ -188,15 +226,12 @@
188 226
189 227 /**
190 228 * @since 6.0
191 229 *
192 - * @todo Only show the note once for a form per user per month or something.
193 - *
194 230 * @return array<string>
195 231 */
196 232 public function get_notes_for_styler_preview() {
197 - $notes = array();
198 -
233 + $notes = array();
199 234 $fallback_form_note = $this->get_fallback_form_note();
200 235
201 236 if ( is_string( $fallback_form_note ) ) {
202 237 $notes[] = $fallback_form_note;
@@ -214,12 +249,8 @@
214 249 );
215 250 };
216 251 }
217 252
218 - if ( class_exists( 'FrmProStylesController' ) && ! class_exists( 'FrmProStylesPreviewHelper' ) ) {
219 - $notes[] = __( 'You are using an outdated version of Formidable Pro. Please update to version 6.0 to get access to all styler features.', 'formidable' );
220 - }
221 -
222 253 if ( is_callable( 'FrmProStylesController::get_notes_for_styler_preview' ) ) {
223 254 $notes = array_merge( $notes, FrmProStylesController::get_notes_for_styler_preview() );
224 255 }
225 256
@@ -327,9 +358,9 @@
327 358
328 359 $styles->remove( 'edit' );
329 360
330 361 $wp_admin_dependencies = $styles->registered['wp-admin']->deps;
331 - $edit_key = array_search( 'edit', $wp_admin_dependencies );
362 + $edit_key = array_search( 'edit', $wp_admin_dependencies, true );
332 363
333 364 if ( false === $edit_key ) {
334 365 return;
335 366 }
@@ -394,9 +425,10 @@
394 425 * @return void
395 426 */
396 427 private static function remove_wp_admin_dependency( $styles, $key ) {
397 428 $dependencies = $styles->registered['wp-admin']->deps;
398 - $index = array_search( $key, $dependencies );
429 + // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
430 + $index = array_search( $key, $dependencies );
399 431
400 432 if ( false === $index ) {
401 433 return;
402 434 }