PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.3
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.3
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/models/FrmStyle.php +174 -460 6.255.3 View file →
@@ -3,48 +3,24 @@
3 3 die( 'You are not allowed to call this page directly.' );
4 4 }
5 5
6 6 class FrmStyle {
7 + public $number = false; // Unique ID number of the current instance.
8 + public $id = 0; // the id of the post
7 9
8 10 /**
9 - * The meta name of default template style.
10 - *
11 - * @since 6.14
12 - * @var string
11 + * @param int|string $id The id of the stylsheet or 'default'
13 12 */
14 - private $default_template_style_meta_name = 'frm_style_default';
15 -
16 - /**
17 - * Unique ID number of the current instance.
18 - *
19 - * @var int
20 - */
21 - public $number = false;
22 -
23 - /**
24 - * The id of the post.
25 - *
26 - * @var int|string
27 - */
28 - public $id = 0;
29 -
30 - /**
31 - * @param int|string $id The id of the stylesheet or 'default'.
32 - */
33 13 public function __construct( $id = 0 ) {
34 14 $this->id = $id;
35 15 }
36 16
37 - /**
38 - * @return stdClass
39 - */
40 17 public function get_new() {
41 18 $this->id = 0;
42 19
43 20 $max_slug_value = 2147483647;
44 - // We want to have at least 2 characters in the slug.
45 - $min_slug_value = 37;
46 - $key = base_convert( random_int( $min_slug_value, $max_slug_value ), 10, 36 );
21 + $min_slug_value = 37; // we want to have at least 2 characters in the slug
22 + $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
47 23
48 24 $style = array(
49 25 'post_type' => FrmStylesController::$post_type,
50 26 'ID' => '',
@@ -57,33 +33,20 @@
57 33
58 34 return (object) $style;
59 35 }
60 36
61 - /**
62 - * @param array $settings
63 - * @return int|WP_Error
64 - */
65 37 public function save( $settings ) {
66 38 return FrmDb::save_settings( $settings, 'frm_styles' );
67 39 }
68 40
69 - /**
70 - * @return void
71 - */
72 41 public function duplicate( $id ) {
73 - // Duplicating is a pro feature. This is handled in FrmProStyle::duplicate instead.
42 + // duplicating is a pro feature
74 43 }
75 44
76 - /**
77 - * Handle save actions in the visual styler edit page.
78 - *
79 - * @param mixed $id
80 - * @return array<int|WP_Error>
81 - */
82 45 public function update( $id = 'default' ) {
83 46 $all_instances = $this->get_all();
84 47
85 - if ( ! $id ) {
48 + if ( empty( $id ) ) {
86 49 $new_style = (array) $this->get_new();
87 50 $all_instances[] = $new_style;
88 51 }
89 52
@@ -88,36 +51,33 @@
88 51 }
89 52
90 53 $action_ids = array();
91 54
92 - foreach ( $all_instances as $new_instance ) {
55 + foreach ( $all_instances as $number => $new_instance ) {
93 56 $new_instance = (array) $new_instance;
94 57 $this->id = $new_instance['ID'];
58 + // phpcs:ignore WordPress.Security.NonceVerification.Missing
59 + if ( $id != $this->id || ! $_POST || ! isset( $_POST['frm_style_setting'] ) ) {
60 + $all_instances[ $number ] = $new_instance;
95 61
96 - if ( $id != $this->id || ! $_POST || ! isset( $_POST['frm_style_setting'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
97 - // Don't continue if not saving this style.
62 + // phpcs:ignore WordPress.Security.NonceVerification.Missing
63 + if ( $new_instance['menu_order'] && $_POST && empty( $_POST['prev_menu_order'] ) && isset( $_POST['frm_style_setting']['menu_order'] ) ) {
64 + // this style was set to default, so remove default setting on previous default style
65 + $new_instance['menu_order'] = 0;
66 + $action_ids[] = $this->save( $new_instance );
67 + }
68 +
69 + // don't continue if not saving this style
98 70 continue;
99 71 }
100 72
101 - // Custom CSS is no longer used from the default style, but it is still checked if the Global Setting is missing.
102 - // Preserve the previous value in case Custom CSS has not been saved as a Global Setting yet.
103 - $custom_css = $new_instance['post_content']['custom_css'] ?? '';
73 + $new_instance['post_title'] = isset( $_POST['frm_style_setting']['post_title'] ) ? sanitize_text_field( wp_unslash( $_POST['frm_style_setting']['post_title'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing
74 + $new_instance['post_content'] = isset( $_POST['frm_style_setting']['post_content'] ) ? $this->sanitize_post_content( $this->unslash_post_content( $_POST['frm_style_setting']['post_content'] ) ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
75 + $new_instance['post_type'] = FrmStylesController::$post_type;
76 + $new_instance['post_status'] = 'publish';
77 + $new_instance['menu_order'] = isset( $_POST['frm_style_setting']['menu_order'] ) ? absint( $_POST['frm_style_setting']['menu_order'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification.Missing
104 78
105 - // phpcs:ignore WordPress.Security.NonceVerification.Missing
106 - if ( ! empty( $_POST['frm_style_setting']['post_title'] ) ) {
107 - // The nonce check happens in FrmStylesController::save_style before this is called.
108 - // phpcs:ignore WordPress.Security.NonceVerification.Missing
109 - $new_instance['post_title'] = sanitize_text_field( wp_unslash( $_POST['frm_style_setting']['post_title'] ) );
110 - }
111 -
112 - $new_instance['post_content'] = isset( $_POST['frm_style_setting']['post_content'] ) ? $this->sanitize_post_content( wp_unslash( $_POST['frm_style_setting']['post_content'] ) ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
113 - $new_instance['post_content']['custom_css'] = $custom_css;
114 - unset( $custom_css );
115 -
116 - $new_instance['post_type'] = FrmStylesController::$post_type;
117 - $new_instance['post_status'] = 'publish';
118 -
119 - if ( ! $id ) {
79 + if ( empty( $id ) ) {
120 80 $new_instance['post_name'] = $new_instance['post_title'];
121 81 }
122 82
123 83 $default_settings = $this->get_defaults();
@@ -127,26 +87,24 @@
127 87 $new_instance['post_content'][ $setting ] = $default;
128 88 }
129 89
130 90 if ( $this->is_color( $setting ) ) {
131 - $color_val = $new_instance['post_content'][ $setting ];
132 - if ( $color_val !== '' && false !== strpos( $color_val, 'rgb' ) ) {
133 - // Maybe sanitize if invalid rgba value is entered.
134 - $this->maybe_sanitize_rgba_value( $color_val );
135 - }
136 - $new_instance['post_content'][ $setting ] = str_replace( '#', '', $color_val );
137 - } elseif ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ), true ) && ! isset( $new_instance['post_content'][ $setting ] ) ) {
91 + $new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] );
92 + } elseif ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) )
93 + && ! isset( $new_instance['post_content'][ $setting ] )
94 + ) {
138 95 $new_instance['post_content'][ $setting ] = 0;
139 - } elseif ( $setting === 'font' ) {
96 + } elseif ( $setting == 'font' ) {
140 97 $new_instance['post_content'][ $setting ] = $this->force_balanced_quotation( $new_instance['post_content'][ $setting ] );
141 98 }
142 99 }
143 100
144 - $new_instance['post_content'] = FrmStylesHelper::update_base_font_size( $new_instance['post_content'], $this->get_defaults() );
101 + $all_instances[ $number ] = $new_instance;
145 102
146 103 $action_ids[] = $this->save( $new_instance );
147 - }//end foreach
148 104
105 + }
106 +
149 107 $this->save_settings();
150 108
151 109 return $action_ids;
152 110 }
@@ -151,90 +109,20 @@
151 109 return $action_ids;
152 110 }
153 111
154 112 /**
155 - * Sanitize custom color values and convert it to valid one filling missing values.
113 + * Unslash everything in post_content but custom_css
156 114 *
157 - * @since 5.3.2
115 + * @since 5.0.13
158 116 *
159 - * @param string $color_val The color value, by reference.
160 - * @return void
117 + * @param array $settings
118 + * @return array
161 119 */
162 - private function maybe_sanitize_rgba_value( &$color_val ) {
163 - if ( preg_match( '/(rgb|rgba)\(/', $color_val ) !== 1 ) {
164 - return;
165 - }
166 -
167 - $color_val = trim( $color_val );
168 - // Remove leading braces so (rgba(1,1,1,1) doesn't cause inconsistent braces.
169 - $color_val = ltrim( $color_val, '(' );
170 - $patterns = array( '/rgba\((\s*\d+\s*,){3}[[0-1]\.]+\)/', '/rgb\((\s*\d+\s*,){2}\s*[\d]+\)/' );
171 - foreach ( $patterns as $pattern ) {
172 - if ( preg_match( $pattern, $color_val ) === 1 ) {
173 - return;
174 - }
175 - }
176 -
177 - // Remove all leading ')' braces, then add one back. This way there's always a single brace.
178 - $color_val = rtrim( $color_val, ')' );
179 - $color_val .= ')';
180 -
181 - $color_rgba = substr( $color_val, strpos( $color_val, '(' ) + 1, strlen( $color_val ) - strpos( $color_val, '(' ) - 2 );
182 - // Remove any excessive braces from the rgba like rgba((.
183 - $color_rgba = trim( $color_rgba, '()' );
184 - $length_of_color_codes = strpos( $color_val, '(' );
185 - $new_color_values = array();
186 -
187 - // replace empty values by 0 or 1 (if alpha position).
188 - foreach ( explode( ',', $color_rgba ) as $index => $value ) {
189 - $new_value = null;
190 - $value_is_empty_string = '' === trim( $value ) || '' === $value;
191 -
192 - if ( 3 === $length_of_color_codes || ( $index !== $length_of_color_codes - 1 ) ) {
193 - // Insert a value for r, g, or b.
194 - if ( $value < 0 ) {
195 - $new_value = 0;
196 - } elseif ( $value > 255 ) {
197 - $new_value = 255;
198 - } elseif ( $value_is_empty_string ) {
199 - $new_value = 0;
200 - } else {
201 - $new_value = absint( $value );
202 - }
203 - } else {
204 - // Insert a value for alpha.
205 - if ( $value_is_empty_string ) {
206 - $new_value = 4 === $length_of_color_codes ? 1 : 0;
207 - } elseif ( $value > 1 || $value < 0 ) {
208 - $new_value = 1;
209 - } else {
210 - $new_value = floatval( $value );
211 - }
212 - }//end if
213 -
214 - $new_color_values[] = $new_value;
215 - }//end foreach
216 -
217 - // add more 0s and 1 (if alpha position) if needed.
218 - $missing_values = $length_of_color_codes - count( $new_color_values );
219 - if ( $missing_values > 1 ) {
220 - $insert_values = array_fill( 0, $missing_values - 1, 0 );
221 - $last_value = 4 === $length_of_color_codes ? 1 : 0;
222 - array_push( $insert_values, $last_value );
223 - } elseif ( $missing_values === 1 ) {
224 - $insert_values = 4 === $length_of_color_codes ? array( 1 ) : array( 0 );
225 - }
226 - if ( ! empty( $insert_values ) ) {
227 - $new_color_values = array_merge( $new_color_values, $insert_values );
228 - }
229 -
230 - $new_color = implode( ',', $new_color_values );
231 - $prefix = substr( $color_val, 0, strpos( $color_val, '(' ) + 1 );
232 - // Limit the number of opening braces after rgb/rgba. There should only be one.
233 - $prefix = rtrim( $prefix, '(' ) . '(';
234 - $new_color = $prefix . $new_color . ')';
235 -
236 - $color_val = $new_color;
120 + private function unslash_post_content( $settings ) {
121 + $custom_css = isset( $settings['custom_css'] ) ? $settings['custom_css'] : '';
122 + $settings = wp_unslash( $settings );
123 + $settings['custom_css'] = $custom_css;
124 + return $settings;
237 125 }
238 126
239 127 /**
240 128 * @since 5.0.13
@@ -251,124 +139,23 @@
251 139 $sanitized_settings[ $key ] = sanitize_textarea_field( $settings[ $key ] );
252 140 } else {
253 141 $sanitized_settings[ $key ] = $defaults[ $key ];
254 142 }
255 -
256 - if ( 'custom_css' !== $key ) {
257 - $sanitized_settings[ $key ] = $this->strip_invalid_characters( $sanitized_settings[ $key ] );
258 - }
259 143 }
260 144 return $sanitized_settings;
261 145 }
262 146
263 147 /**
264 - * Remove any characters that should not be used in CSS.
265 - *
266 - * @since 6.2.3
267 - *
268 - * @param string $setting
269 - * @return string
270 - */
271 - private function strip_invalid_characters( $setting ) {
272 - $characters_to_remove = array( '{', '}', ';', '[', ']' );
273 -
274 - // RGB is handled instead in self::maybe_sanitize_rgba_value.
275 - if ( 0 !== strpos( $setting, 'rgb' ) ) {
276 - $setting = $this->maybe_fix_braces( $setting, $characters_to_remove );
277 - }
278 -
279 - return str_replace( $characters_to_remove, '', $setting );
280 - }
281 -
282 - /**
283 - * @since 6.2.3
284 - *
285 - * @param string $setting
286 - * @param array $characters_to_remove
287 - * @return string
288 - */
289 - private function maybe_fix_braces( $setting, &$characters_to_remove ) {
290 - $number_of_opening_braces = substr_count( $setting, '(' );
291 - $number_of_closing_braces = substr_count( $setting, ')' );
292 -
293 - if ( $number_of_opening_braces === $number_of_closing_braces ) {
294 - return $this->trim_braces( $setting );
295 - }
296 -
297 - if ( $this->should_remove_every_brace( $setting ) ) {
298 - // Add to $characters_to_remove to remove when str_replace is called.
299 - array_push( $characters_to_remove, '(', ')' );
300 - return $setting;
301 - }
302 -
303 - return $this->trim_braces( $setting );
304 - }
305 -
306 - /**
307 - * @since 6.2.3
308 - *
309 - * @param string $input
310 - * @return string
311 - */
312 - private function trim_braces( $input ) {
313 - $output = $input;
314 - // Remove any ( from the start of the string as no CSS values expect at the first character.
315 - if ( $output && in_array( $output[0], array( '(', ')' ), true ) ) {
316 - $output = ltrim( $output, '()' );
317 - }
318 - // Remove extra braces from the end.
319 - if ( in_array( substr( $output, -1 ), array( '(', ')' ), true ) ) {
320 - $output = rtrim( $output, '()' );
321 - if ( false !== strpos( $output, '(' ) ) {
322 - $output .= ')';
323 - }
324 - }
325 - return $output;
326 - }
327 -
328 - /**
329 - * @since 6.2.3
330 - *
331 - * @param string $setting
332 - * @return bool
333 - */
334 - private function should_remove_every_brace( $setting ) {
335 - if ( 0 === strpos( trim( $setting, '()' ), 'calc' ) ) {
336 - // Support calc() sizes. We do not want to remove all braces when calc is used.
337 - return false;
338 - }
339 -
340 - // Matches hex values but also checks for unexpected ( and ).
341 - $looks_like_a_hex_value = preg_match( '/^(?:\()?(?!#?[a-fA-F0-9]*[^\(#\)\da-fA-F])[a-fA-F0-9\(\)]*(?:\))?$/', $setting );
342 - if ( $looks_like_a_hex_value ) {
343 - return true;
344 - }
345 -
346 - // Matches size values but also checks for unexpected ( and ).
347 - // This is case insensitive so it will catch PX, PT, etc, as well.
348 - $looks_like_a_size = preg_match( '/\(?[+-]?\d*\.?\d+(?:px|%|em|rem|ex|pt|pc|mm|cm|in)\)?/i', $setting );
349 - if ( $looks_like_a_size ) {
350 - return true;
351 - }
352 -
353 - return false;
354 - }
355 -
356 - /**
357 148 * @since 3.01.01
358 - *
359 - * @param string $setting
360 - * @return bool
361 149 */
362 150 private function is_color( $setting ) {
363 151 $extra_colors = array( 'error_bg', 'error_border', 'error_text' );
364 - return strpos( $setting, 'color' ) !== false || in_array( $setting, $extra_colors, true );
152 +
153 + return strpos( $setting, 'color' ) !== false || in_array( $setting, $extra_colors );
365 154 }
366 155
367 156 /**
368 157 * @since 3.01.01
369 - *
370 - * @return array
371 158 */
372 159 public function get_color_settings() {
373 160 $defaults = $this->get_defaults();
374 161 $settings = array_keys( $defaults );
@@ -376,11 +163,9 @@
376 163 return array_filter( $settings, array( $this, 'is_color' ) );
377 164 }
378 165
379 166 /**
380 - * Create static CSS file and update the CSS transient alternative.
381 - *
382 - * @return void
167 + * Create static css file
383 168 */
384 169 public function save_settings() {
385 170 $filename = FrmAppHelper::plugin_path() . '/css/custom_theme.css.php';
386 171 update_option( 'frm_last_style_update', gmdate( 'njGi' ) );
@@ -390,9 +175,10 @@
390 175 }
391 176
392 177 $this->clear_cache();
393 178
394 - $css = $this->get_css_content( $filename );
179 + $css = $this->get_css_content( $filename );
180 +
395 181 $create_file = new FrmCreateFile(
396 182 array(
397 183 'file_name' => FrmStylesController::get_file_name(),
398 184 'new_file_path' => FrmAppHelper::plugin_path() . '/css',
@@ -403,12 +189,8 @@
403 189 update_option( 'frmpro_css', $css, 'no' );
404 190 set_transient( 'frmpro_css', $css, MONTH_IN_SECONDS );
405 191 }
406 192
407 - /**
408 - * @param string $filename
409 - * @return string
410 - */
411 193 private function get_css_content( $filename ) {
412 194 $css = '/* ' . __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) . ' */' . "\n";
413 195
414 196 $saving = true;
@@ -414,9 +196,9 @@
414 196 $saving = true;
415 197 $frm_style = $this;
416 198
417 199 ob_start();
418 - include $filename;
200 + include( $filename );
419 201 $css .= preg_replace( '/\/\*(.|\s)*?\*\//', '', str_replace( array( "\r\n", "\r", "\n", "\t", ' ' ), '', ob_get_contents() ) );
420 202 ob_end_clean();
421 203
422 204 return FrmStylesController::replace_relative_url( $css );
@@ -421,11 +203,8 @@
421 203
422 204 return FrmStylesController::replace_relative_url( $css );
423 205 }
424 206
425 - /**
426 - * @return void
427 - */
428 207 private function clear_cache() {
429 208 $default_post_atts = array(
430 209 'post_type' => FrmStylesController::$post_type,
431 210 'post_status' => 'publish',
@@ -438,26 +217,14 @@
438 217 FrmDb::cache_delete_group( 'frm_styles' );
439 218 FrmDb::delete_cache_and_transient( 'frmpro_css' );
440 219 }
441 220
442 - /**
443 - * Delete a style by its post ID.
444 - *
445 - * @param int $id
446 - * @return false|WP_Post|null
447 - */
448 221 public function destroy( $id ) {
449 - if ( $id === $this->get_default_style()->ID ) {
450 - return false;
451 - }
452 222 return wp_delete_post( $id );
453 223 }
454 224
455 - /**
456 - * @return stdClass|WP_Post
457 - */
458 225 public function get_one() {
459 - if ( 'default' === $this->id ) {
226 + if ( 'default' == $this->id ) {
460 227 $style = $this->get_default_style();
461 228 if ( $style ) {
462 229 $this->id = $style->ID;
463 230 } else {
@@ -483,14 +250,8 @@
483 250
484 251 return $style;
485 252 }
486 253
487 - /**
488 - * @param string $orderby
489 - * @param string $order
490 - * @param int $limit
491 - * @return array
492 - */
493 254 public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) {
494 255 $post_atts = array(
495 256 'post_type' => FrmStylesController::$post_type,
496 257 'post_status' => 'publish',
@@ -555,11 +316,8 @@
555 316
556 317 return $styles;
557 318 }
558 319
559 - /**
560 - * @param array|null $styles
561 - */
562 320 public function get_default_style( $styles = null ) {
563 321 if ( ! isset( $styles ) ) {
564 322 $styles = $this->get_all( 'menu_order', 'DESC', 1 );
565 323 }
@@ -570,18 +328,14 @@
570 328 }
571 329 }
572 330 }
573 331
574 - /**
575 - * @param mixed $settings
576 - * @return mixed
577 - */
578 332 public function override_defaults( $settings ) {
579 333 if ( ! is_array( $settings ) ) {
580 334 return $settings;
581 335 }
582 336
583 - $settings['line_height'] = ! isset( $settings['field_height'] ) || $settings['field_height'] == '' || $settings['field_height'] === 'auto' ? 'normal' : $settings['field_height'];
337 + $settings['line_height'] = ( ! isset( $settings['field_height'] ) || $settings['field_height'] == '' || $settings['field_height'] == 'auto' ) ? 'normal' : $settings['field_height'];
584 338
585 339 if ( ! isset( $settings['form_desc_size'] ) && isset( $settings['description_font_size'] ) ) {
586 340 $settings['form_desc_size'] = $settings['description_font_size'];
587 341 $settings['form_desc_color'] = $settings['description_color'];
@@ -605,187 +359,169 @@
605 359
606 360 return apply_filters( 'frm_override_default_styles', $settings );
607 361 }
608 362
609 - /**
610 - * @return array
611 - */
612 363 public function get_defaults() {
613 364 $defaults = array(
614 - 'theme_css' => 'ui-lightness',
615 - 'theme_name' => 'UI Lightness',
365 + 'theme_css' => 'ui-lightness',
366 + 'theme_name' => 'UI Lightness',
616 367
617 - 'center_form' => '',
618 - 'form_width' => '100%',
619 - 'form_align' => 'left',
620 - 'direction' => is_rtl() ? 'rtl' : 'ltr',
621 - 'fieldset' => '0px',
622 - 'fieldset_color' => '000000',
623 - 'fieldset_padding' => '0px 0px 15px 0px',
624 - 'fieldset_bg_color' => '',
368 + 'center_form' => '',
369 + 'form_width' => '100%',
370 + 'form_align' => 'left',
371 + 'direction' => is_rtl() ? 'rtl' : 'ltr',
372 + 'fieldset' => '0px',
373 + 'fieldset_color' => '000000',
374 + 'fieldset_padding' => '0 0 15px 0',
375 + 'fieldset_bg_color' => '',
625 376
626 - 'title_size' => '40px',
627 - 'title_color' => '444444',
628 - 'title_margin_top' => '10px',
629 - 'title_margin_bottom' => '60px',
630 - 'form_desc_size' => '14px',
631 - 'form_desc_color' => '98A2B3',
632 - 'form_desc_margin_top' => '10px',
633 - 'form_desc_margin_bottom' => '25px',
634 - 'form_desc_padding' => '0px',
377 + 'title_size' => '40px',
378 + 'title_color' => '444444',
379 + 'title_margin_top' => '10px',
380 + 'title_margin_bottom' => '60px',
381 + 'form_desc_size' => '14px',
382 + 'form_desc_color' => '666666',
383 + 'form_desc_margin_top' => '10px',
384 + 'form_desc_margin_bottom' => '25px',
385 + 'form_desc_padding' => '0',
635 386
636 - 'font' => '',
637 - 'font_size' => '15px',
638 - 'label_color' => '344054',
639 - 'weight' => 'normal',
640 - 'position' => 'none',
641 - 'align' => 'left',
642 - 'width' => '150px',
643 - 'required_color' => 'F04438',
644 - 'required_weight' => 'bold',
645 - 'label_padding' => '0px 0px 5px 0px',
387 + 'font' => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif',
388 + 'font_size' => '15px',
389 + 'label_color' => '3f4b5b',
390 + 'weight' => 'normal',
391 + 'position' => 'none',
392 + 'align' => 'left',
393 + 'width' => '150px',
394 + 'required_color' => 'B94A48',
395 + 'required_weight' => 'bold',
396 + 'label_padding' => '0 0 3px 0',
646 397
647 - 'description_font_size' => '12px',
648 - 'description_color' => '667085',
649 - 'description_weight' => 'normal',
650 - 'description_style' => 'normal',
651 - 'description_align' => 'left',
652 - 'description_margin' => '0px',
398 + 'description_font_size' => '12px',
399 + 'description_color' => '666666',
400 + 'description_weight' => 'normal',
401 + 'description_style' => 'normal',
402 + 'description_align' => 'left',
403 + 'description_margin' => '0',
653 404
654 - 'field_font_size' => '14px',
655 - 'field_height' => '36px',
656 - 'line_height' => 'normal',
657 - 'field_width' => '100%',
658 - 'auto_width' => false,
659 - 'field_pad' => '8px 12px',
660 - 'field_margin' => '20px',
661 - 'field_weight' => 'normal',
662 - 'text_color' => '1D2939',
663 - // 'border_color_hv' => 'cccccc',
664 - 'border_color' => 'D0D5DD',
665 - 'field_border_width' => '1px',
666 - 'field_border_style' => 'solid',
405 + 'field_font_size' => '14px',
406 + 'field_height' => '32px',
407 + 'line_height' => 'normal',
408 + 'field_width' => '100%',
409 + 'auto_width' => false,
410 + 'field_pad' => '6px 10px',
411 + 'field_margin' => '20px',
412 + 'field_weight' => 'normal',
413 + 'text_color' => '555555',
414 + //'border_color_hv' => 'cccccc',
415 + 'border_color' => 'BFC3C8',
416 + 'field_border_width' => '1px',
417 + 'field_border_style' => 'solid',
667 418
668 - 'bg_color' => 'ffffff',
669 - // 'bg_color_hv' => 'ffffff',
670 - 'remove_box_shadow' => '',
671 - 'bg_color_active' => 'ffffff',
672 - 'border_color_active' => '4199FD',
673 - 'remove_box_shadow_active' => '',
674 - 'text_color_error' => '444444',
675 - 'bg_color_error' => 'ffffff',
676 - 'border_color_error' => 'F04438',
677 - 'border_width_error' => '1px',
678 - 'border_style_error' => 'solid',
679 - 'bg_color_disabled' => 'F9FAFB',
680 - 'border_color_disabled' => 'D0D5DD',
681 - 'text_color_disabled' => '667085',
419 + 'bg_color' => 'ffffff',
420 + //'bg_color_hv' => 'ffffff',
421 + 'remove_box_shadow' => '',
422 + 'bg_color_active' => 'ffffff',
423 + 'border_color_active' => '66afe9',
424 + 'remove_box_shadow_active' => '',
425 + 'text_color_error' => '444444',
426 + 'bg_color_error' => 'ffffff',
427 + 'border_color_error' => 'B94A48',
428 + 'border_width_error' => '1px',
429 + 'border_style_error' => 'solid',
430 + 'bg_color_disabled' => 'ffffff',
431 + 'border_color_disabled' => 'E5E5E5',
432 + 'text_color_disabled' => 'A1A1A1',
682 433
683 - 'radio_align' => 'block',
684 - 'check_align' => 'block',
685 - 'check_font_size' => '14px',
686 - 'check_label_color' => '1D2939',
687 - 'check_weight' => 'normal',
434 + 'radio_align' => 'block',
435 + 'check_align' => 'block',
436 + 'check_font_size' => '13px',
437 + 'check_label_color' => '444444',
438 + 'check_weight' => 'normal',
688 439
689 - 'section_font_size' => '18px',
690 - 'section_color' => '344054',
691 - 'section_weight' => 'bold',
692 - 'section_pad' => '32px 0px 3px 0px',
693 - 'section_mar_top' => '30px',
694 - 'section_mar_bottom' => '30px',
695 - 'section_bg_color' => '',
696 - 'section_border_color' => 'EAECF0',
697 - 'section_border_width' => '1px',
698 - 'section_border_style' => 'solid',
699 - 'section_border_loc' => '-top',
700 - 'collapse_icon' => '6',
701 - 'collapse_pos' => 'after',
702 - 'repeat_icon' => '1',
703 - 'repeat_icon_color' => 'ffffff',
440 + 'section_font_size' => '18px',
441 + 'section_color' => '444444',
442 + 'section_weight' => 'bold',
443 + 'section_pad' => '15px 0 3px 0',
444 + 'section_mar_top' => '15px',
445 + 'section_mar_bottom' => '30px',
446 + 'section_bg_color' => '',
447 + 'section_border_color' => 'e8e8e8',
448 + 'section_border_width' => '2px',
449 + 'section_border_style' => 'solid',
450 + 'section_border_loc' => '-top',
451 + 'collapse_icon' => '6',
452 + 'collapse_pos' => 'after',
453 + 'repeat_icon' => '1',
454 + 'repeat_icon_color' => 'ffffff',
704 455
705 456 'submit_style' => false,
706 - 'submit_font_size' => '14px',
457 + 'submit_font_size' => '15px',
707 458 'submit_width' => 'auto',
708 459 'submit_height' => 'auto',
709 - 'submit_bg_color' => '4199FD',
710 - 'submit_border_color' => '4199FD',
460 + 'submit_bg_color' => '579AF6',
461 + 'submit_border_color' => '579AF6',
711 462 'submit_border_width' => '1px',
712 463 'submit_text_color' => 'ffffff',
713 464 'submit_weight' => 'normal',
714 - 'submit_border_radius' => '8px',
465 + 'submit_border_radius' => '4px',
715 466 'submit_bg_img' => '',
716 467 'submit_margin' => '10px',
717 - 'submit_padding' => '8px 16px',
468 + 'submit_padding' => '10px 20px',
718 469 'submit_shadow_color' => 'eeeeee',
719 - 'submit_hover_bg_color' => '3680D3',
720 - 'submit_hover_color' => 'ffffff',
721 - 'submit_hover_border_color' => '3680D3',
722 - 'submit_active_bg_color' => '3680D3',
723 - 'submit_active_color' => 'ffffff',
724 - 'submit_active_border_color' => '3680D3',
470 + 'submit_hover_bg_color' => 'efefef',
471 + 'submit_hover_color' => '444444',
472 + 'submit_hover_border_color' => 'cccccc',
473 + 'submit_active_bg_color' => 'efefef',
474 + 'submit_active_color' => '444444',
475 + 'submit_active_border_color' => 'cccccc',
725 476
726 - 'border_radius' => '8px',
727 - 'error_bg' => 'FEE4E2',
728 - 'error_border' => 'F5B8AA',
729 - 'error_text' => 'F04438',
730 - 'error_font_size' => '14px',
477 + 'border_radius' => '4px',
478 + 'error_bg' => 'F2DEDE',
479 + 'error_border' => 'EBCCD1',
480 + 'error_text' => 'B94A48',
481 + 'error_font_size' => '14px',
731 482
732 - 'success_bg_color' => 'DFF0D8',
733 - 'success_border_color' => 'D6E9C6',
734 - 'success_text_color' => '468847',
735 - 'success_font_size' => '14px',
483 + 'success_bg_color' => 'DFF0D8',
484 + 'success_border_color' => 'D6E9C6',
485 + 'success_text_color' => '468847',
486 + 'success_font_size' => '14px',
736 487
737 - 'important_style' => false,
488 + 'important_style' => false,
738 489
739 - 'progress_bg_color' => 'EAECF0',
740 - 'progress_color' => '1D2939',
741 - 'progress_active_bg_color' => '4199FD',
742 - 'progress_active_color' => 'ffffff',
743 - 'progress_border_color' => 'EAECF0',
744 - 'progress_border_size' => '1px',
745 - 'progress_size' => '30px',
746 - 'custom_css' => '',
747 - 'use_base_font_size' => false,
748 - 'base_font_size' => '15px',
749 - 'field_shape_type' => 'rounded-corner',
490 + 'progress_bg_color' => 'eaeaea',
491 + 'progress_active_color' => 'ffffff',
492 + 'progress_active_bg_color' => '579AF6',
493 + 'progress_color' => '3f4b5b',
494 + 'progress_border_color' => 'E5E5E5',
495 + 'progress_border_size' => '2px',
496 + 'progress_size' => '30px',
497 +
498 + 'custom_css' => '',
750 499 );
751 500
752 501 return apply_filters( 'frm_default_style_settings', $defaults );
753 502 }
754 503
755 - /**
756 - * Get a name attribute value for a style setting input.
757 - *
758 - * @param string $field_name
759 - * @param string $post_field
760 - * @return string
761 - */
762 504 public function get_field_name( $field_name, $post_field = 'post_content' ) {
763 505 return 'frm_style_setting' . ( empty( $post_field ) ? '' : '[' . $post_field . ']' ) . '[' . $field_name . ']';
764 506 }
765 507
766 - /**
767 - * @return array
768 - */
769 508 public static function get_bold_options() {
770 509 return array(
771 - 100 => __( 'Thin', 'formidable' ),
772 - 200 => __( 'Extra Light', 'formidable' ),
773 - 300 => __( 'Light', 'formidable' ),
774 - 'normal' => __( 'Regular', 'formidable' ),
775 - 500 => __( 'Medium', 'formidable' ),
776 - 600 => __( 'Semi Bold', 'formidable' ),
777 - 'bold' => __( 'Bold', 'formidable' ),
778 - 800 => __( 'Extra Bold', 'formidable' ),
779 - 900 => __( 'Black', 'formidable' ),
510 + 100 => 100,
511 + 200 => 200,
512 + 300 => 300,
513 + 'normal' => __( 'normal', 'formidable' ),
514 + 500 => 500,
515 + 600 => 600,
516 + 'bold' => __( 'bold', 'formidable' ),
517 + 800 => 800,
518 + 900 => 900,
780 519 );
781 520 }
782 521
783 522 /**
784 - * Don't let imbalanced font families ruin the whole stylesheet.
785 - *
786 - * @param string $value
787 - * @return string
523 + * Don't let imbalanced font families ruin the whole stylesheet
788 524 */
789 525 public function force_balanced_quotation( $value ) {
790 526 $balanced_characters = array( '"', "'" );
791 527 foreach ( $balanced_characters as $char ) {
@@ -790,34 +526,12 @@
790 526 $balanced_characters = array( '"', "'" );
791 527 foreach ( $balanced_characters as $char ) {
792 528 $char_count = substr_count( $value, $char );
793 529 $is_balanced = $char_count % 2 == 0;
794 -
795 - if ( $is_balanced ) {
796 - continue;
797 - }
798 -
799 - if ( $value && $char === $value[ strlen( $value ) - 1 ] ) {
800 - $value = $char . $value;
801 - } else {
530 + if ( ! $is_balanced ) {
802 531 $value .= $char;
803 532 }
804 533 }
534 +
805 535 return $value;
806 - }
807 -
808 - /**
809 - * Get the default template style
810 - *
811 - * @since 6.14
812 - * @param int $style_id The post type "frm_styles" ID.
813 - *
814 - * @return string The json encoded template data
815 - */
816 - public function get_default_template_style( $style_id ) {
817 - $default_template = get_post_meta( (int) $style_id, $this->default_template_style_meta_name, true );
818 - if ( empty( $default_template ) ) {
819 - return FrmAppHelper::prepare_and_encode( $this->get_defaults() );
820 - }
821 - return $default_template;
822 536 }
823 537 }