PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.10
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.10
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 +135 -138 6.36.10 View file →
@@ -3,14 +3,25 @@
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 + /**
8 + * Unique ID number of the current instance.
9 + *
10 + * @var int
11 + */
12 + public $number = false;
9 13
10 14 /**
11 - * @param int|string $id The id of the stylsheet or 'default'
15 + * The id of the post.
16 + *
17 + * @var int|string
12 18 */
19 + public $id = 0;
20 +
21 + /**
22 + * @param int|string $id The id of the stylsheet or 'default'.
23 + */
13 24 public function __construct( $id = 0 ) {
14 25 $this->id = $id;
15 26 }
16 27
@@ -20,9 +31,10 @@
20 31 public function get_new() {
21 32 $this->id = 0;
22 33
23 34 $max_slug_value = 2147483647;
24 - $min_slug_value = 37; // we want to have at least 2 characters in the slug
35 + // We want to have at least 2 characters in the slug.
36 + $min_slug_value = 37;
25 37 $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
26 38
27 39 $style = array(
28 40 'post_type' => FrmStylesController::$post_type,
@@ -67,9 +79,9 @@
67 79 }
68 80
69 81 $action_ids = array();
70 82
71 - foreach ( $all_instances as $number => $new_instance ) {
83 + foreach ( $all_instances as $new_instance ) {
72 84 $new_instance = (array) $new_instance;
73 85 $this->id = $new_instance['ID'];
74 86
75 87 if ( $id != $this->id || ! $_POST || ! isset( $_POST['frm_style_setting'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
@@ -91,10 +103,10 @@
91 103 $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
92 104 $new_instance['post_content']['custom_css'] = $custom_css;
93 105 unset( $custom_css );
94 106
95 - $new_instance['post_type'] = FrmStylesController::$post_type;
96 - $new_instance['post_status'] = 'publish';
107 + $new_instance['post_type'] = FrmStylesController::$post_type;
108 + $new_instance['post_status'] = 'publish';
97 109
98 110 if ( ! $id ) {
99 111 $new_instance['post_name'] = $new_instance['post_title'];
100 112 }
@@ -120,9 +132,9 @@
120 132 }
121 133 }
122 134
123 135 $action_ids[] = $this->save( $new_instance );
124 - }
136 + }//end foreach
125 137
126 138 $this->save_settings();
127 139
128 140 return $action_ids;
@@ -132,9 +144,9 @@
132 144 * Sanitize custom color values and convert it to valid one filling missing values.
133 145 *
134 146 * @since 5.3.2
135 147 *
136 - * @param string $color_val, The color value, by reference.
148 + * @param string $color_val The color value, by reference.
137 149 * @return void
138 150 */
139 151 private function maybe_sanitize_rgba_value( &$color_val ) {
140 152 if ( preg_match( '/(rgb|rgba)\(/', $color_val ) !== 1 ) {
@@ -141,9 +153,10 @@
141 153 return;
142 154 }
143 155
144 156 $color_val = trim( $color_val );
145 - $color_val = ltrim( $color_val, '(' ); // Remove leading braces so (rgba(1,1,1,1) doesn't cause inconsistent braces.
157 + // Remove leading braces so (rgba(1,1,1,1) doesn't cause inconsistent braces.
158 + $color_val = ltrim( $color_val, '(' );
146 159 $patterns = array( '/rgba\((\s*\d+\s*,){3}[[0-1]\.]+\)/', '/rgb\((\s*\d+\s*,){2}\s*[\d]+\)/' );
147 160 foreach ( $patterns as $pattern ) {
148 161 if ( preg_match( $pattern, $color_val ) === 1 ) {
149 162 return;
@@ -153,10 +166,11 @@
153 166 // Remove all leading ')' braces, then add one back. This way there's always a single brace.
154 167 $color_val = rtrim( $color_val, ')' );
155 168 $color_val .= ')';
156 169
157 - $color_rgba = substr( $color_val, strpos( $color_val, '(' ) + 1, strlen( $color_val ) - strpos( $color_val, '(' ) - 2 );
158 - $color_rgba = trim( $color_rgba, '()' ); // Remove any excessive braces from the rgba like rgba((.
170 + $color_rgba = substr( $color_val, strpos( $color_val, '(' ) + 1, strlen( $color_val ) - strpos( $color_val, '(' ) - 2 );
171 + // Remove any excessive braces from the rgba like rgba((.
172 + $color_rgba = trim( $color_rgba, '()' );
159 173 $length_of_color_codes = strpos( $color_val, '(' );
160 174 $new_color_values = array();
161 175
162 176 // replace empty values by 0 or 1 (if alpha position).
@@ -183,12 +197,12 @@
183 197 $new_value = 1;
184 198 } else {
185 199 $new_value = floatval( $value );
186 200 }
187 - }
201 + }//end if
188 202
189 203 $new_color_values[] = null === $new_value ? $value : $new_value;
190 - }
204 + }//end foreach
191 205
192 206 // add more 0s and 1 (if alpha position) if needed.
193 207 $missing_values = $length_of_color_codes - count( $new_color_values );
194 208 if ( $missing_values > 1 ) {
@@ -203,9 +217,10 @@
203 217 }
204 218
205 219 $new_color = implode( ',', $new_color_values );
206 220 $prefix = substr( $color_val, 0, strpos( $color_val, '(' ) + 1 );
207 - $prefix = rtrim( $prefix, '(' ) . '('; // Limit the number of opening braces after rgb/rgba. There should only be one.
221 + // Limit the number of opening braces after rgb/rgba. There should only be one.
222 + $prefix = rtrim( $prefix, '(' ) . '(';
208 223 $new_color = $prefix . $new_color . ')';
209 224
210 225 $color_val = $new_color;
211 226 }
@@ -210,28 +225,13 @@
210 225 $color_val = $new_color;
211 226 }
212 227
213 228 /**
214 - * Unslash everything in post_content but custom_css
215 - *
216 229 * @since 5.0.13
217 230 *
218 231 * @param array $settings
219 232 * @return array
220 233 */
221 - private function unslash_post_content( $settings ) {
222 - $custom_css = isset( $settings['custom_css'] ) ? $settings['custom_css'] : '';
223 - $settings = wp_unslash( $settings );
224 - $settings['custom_css'] = $custom_css;
225 - return $settings;
226 - }
227 -
228 - /**
229 - * @since 5.0.13
230 - *
231 - * @param array $settings
232 - * @return array
233 - */
234 234 public function sanitize_post_content( $settings ) {
235 235 $defaults = $this->get_defaults();
236 236 $valid_keys = array_keys( $defaults );
237 237 $sanitized_settings = array();
@@ -300,12 +300,10 @@
300 300 */
301 301 private function trim_braces( $input ) {
302 302 $output = $input;
303 303 // Remove any ( from the start of the string as no CSS values expect at the first character.
304 - if ( $output ) {
305 - if ( in_array( $output[0], array( '(', ')' ), true ) ) {
306 - $output = ltrim( $output, '()' );
307 - }
304 + if ( $output && in_array( $output[0], array( '(', ')' ), true ) ) {
305 + $output = ltrim( $output, '()' );
308 306 }
309 307 // Remove extra braces from the end.
310 308 if ( in_array( substr( $output, -1 ), array( '(', ')' ), true ) ) {
311 309 $output = rtrim( $output, '()' );
@@ -433,9 +431,9 @@
433 431 /**
434 432 * Delete a style by its post ID.
435 433 *
436 434 * @param int $id
437 - * @return WP_Post|false|null
435 + * @return false|WP_Post|null
438 436 */
439 437 public function destroy( $id ) {
440 438 if ( $id === $this->get_default_style()->ID ) {
441 439 return false;
@@ -443,9 +441,9 @@
443 441 return wp_delete_post( $id );
444 442 }
445 443
446 444 /**
447 - * @return WP_Post|stdClass
445 + * @return stdClass|WP_Post
448 446 */
449 447 public function get_one() {
450 448 if ( 'default' === $this->id ) {
451 449 $style = $this->get_default_style();
@@ -570,9 +568,9 @@
570 568 if ( ! is_array( $settings ) ) {
571 569 return $settings;
572 570 }
573 571
574 - $settings['line_height'] = ( ! isset( $settings['field_height'] ) || $settings['field_height'] == '' || $settings['field_height'] == 'auto' ) ? 'normal' : $settings['field_height'];
572 + $settings['line_height'] = ! isset( $settings['field_height'] ) || $settings['field_height'] == '' || $settings['field_height'] === 'auto' ? 'normal' : $settings['field_height'];
575 573
576 574 if ( ! isset( $settings['form_desc_size'] ) && isset( $settings['description_font_size'] ) ) {
577 575 $settings['form_desc_size'] = $settings['description_font_size'];
578 576 $settings['form_desc_color'] = $settings['description_color'];
@@ -601,98 +599,98 @@
601 599 * @return array
602 600 */
603 601 public function get_defaults() {
604 602 $defaults = array(
605 - 'theme_css' => 'ui-lightness',
606 - 'theme_name' => 'UI Lightness',
603 + 'theme_css' => 'ui-lightness',
604 + 'theme_name' => 'UI Lightness',
607 605
608 - 'center_form' => '',
609 - 'form_width' => '100%',
610 - 'form_align' => 'left',
611 - 'direction' => is_rtl() ? 'rtl' : 'ltr',
612 - 'fieldset' => '0px',
613 - 'fieldset_color' => '000000',
614 - 'fieldset_padding' => '0 0 15px 0',
615 - 'fieldset_bg_color' => '',
606 + 'center_form' => '',
607 + 'form_width' => '100%',
608 + 'form_align' => 'left',
609 + 'direction' => is_rtl() ? 'rtl' : 'ltr',
610 + 'fieldset' => '0px',
611 + 'fieldset_color' => '000000',
612 + 'fieldset_padding' => '0 0 15px 0',
613 + 'fieldset_bg_color' => '',
616 614
617 - 'title_size' => '40px',
618 - 'title_color' => '444444',
619 - 'title_margin_top' => '10px',
620 - 'title_margin_bottom' => '60px',
621 - 'form_desc_size' => '14px',
622 - 'form_desc_color' => '666666',
623 - 'form_desc_margin_top' => '10px',
624 - 'form_desc_margin_bottom' => '25px',
625 - 'form_desc_padding' => '0',
615 + 'title_size' => '40px',
616 + 'title_color' => '444444',
617 + 'title_margin_top' => '10px',
618 + 'title_margin_bottom' => '60px',
619 + 'form_desc_size' => '14px',
620 + 'form_desc_color' => '666666',
621 + 'form_desc_margin_top' => '10px',
622 + 'form_desc_margin_bottom' => '25px',
623 + 'form_desc_padding' => '0',
626 624
627 - 'font' => '',
628 - 'font_size' => '15px',
629 - 'label_color' => '3f4b5b',
630 - 'weight' => 'normal',
631 - 'position' => 'none',
632 - 'align' => 'left',
633 - 'width' => '150px',
634 - 'required_color' => 'B94A48',
635 - 'required_weight' => 'bold',
636 - 'label_padding' => '0 0 3px 0',
625 + 'font' => '',
626 + 'font_size' => '15px',
627 + 'label_color' => '3f4b5b',
628 + 'weight' => 'normal',
629 + 'position' => 'none',
630 + 'align' => 'left',
631 + 'width' => '150px',
632 + 'required_color' => 'B94A48',
633 + 'required_weight' => 'bold',
634 + 'label_padding' => '0 0 3px 0',
637 635
638 - 'description_font_size' => '12px',
639 - 'description_color' => '666666',
640 - 'description_weight' => 'normal',
641 - 'description_style' => 'normal',
642 - 'description_align' => 'left',
643 - 'description_margin' => '0',
636 + 'description_font_size' => '12px',
637 + 'description_color' => '666666',
638 + 'description_weight' => 'normal',
639 + 'description_style' => 'normal',
640 + 'description_align' => 'left',
641 + 'description_margin' => '0',
644 642
645 - 'field_font_size' => '14px',
646 - 'field_height' => '32px',
647 - 'line_height' => 'normal',
648 - 'field_width' => '100%',
649 - 'auto_width' => false,
650 - 'field_pad' => '6px 10px',
651 - 'field_margin' => '20px',
652 - 'field_weight' => 'normal',
653 - 'text_color' => '555555',
654 - //'border_color_hv' => 'cccccc',
655 - 'border_color' => 'BFC3C8',
656 - 'field_border_width' => '1px',
657 - 'field_border_style' => 'solid',
643 + 'field_font_size' => '14px',
644 + 'field_height' => '32px',
645 + 'line_height' => 'normal',
646 + 'field_width' => '100%',
647 + 'auto_width' => false,
648 + 'field_pad' => '6px 10px',
649 + 'field_margin' => '20px',
650 + 'field_weight' => 'normal',
651 + 'text_color' => '555555',
652 + // 'border_color_hv' => 'cccccc',
653 + 'border_color' => 'BFC3C8',
654 + 'field_border_width' => '1px',
655 + 'field_border_style' => 'solid',
658 656
659 - 'bg_color' => 'ffffff',
660 - //'bg_color_hv' => 'ffffff',
661 - 'remove_box_shadow' => '',
662 - 'bg_color_active' => 'ffffff',
663 - 'border_color_active' => '66afe9',
664 - 'remove_box_shadow_active' => '',
665 - 'text_color_error' => '444444',
666 - 'bg_color_error' => 'ffffff',
667 - 'border_color_error' => 'B94A48',
668 - 'border_width_error' => '1px',
669 - 'border_style_error' => 'solid',
670 - 'bg_color_disabled' => 'ffffff',
671 - 'border_color_disabled' => 'E5E5E5',
672 - 'text_color_disabled' => 'A1A1A1',
657 + 'bg_color' => 'ffffff',
658 + // 'bg_color_hv' => 'ffffff',
659 + 'remove_box_shadow' => '',
660 + 'bg_color_active' => 'ffffff',
661 + 'border_color_active' => '66afe9',
662 + 'remove_box_shadow_active' => '',
663 + 'text_color_error' => '444444',
664 + 'bg_color_error' => 'ffffff',
665 + 'border_color_error' => 'B94A48',
666 + 'border_width_error' => '1px',
667 + 'border_style_error' => 'solid',
668 + 'bg_color_disabled' => 'ffffff',
669 + 'border_color_disabled' => 'E5E5E5',
670 + 'text_color_disabled' => 'A1A1A1',
673 671
674 - 'radio_align' => 'block',
675 - 'check_align' => 'block',
676 - 'check_font_size' => '13px',
677 - 'check_label_color' => '444444',
678 - 'check_weight' => 'normal',
672 + 'radio_align' => 'block',
673 + 'check_align' => 'block',
674 + 'check_font_size' => '13px',
675 + 'check_label_color' => '444444',
676 + 'check_weight' => 'normal',
679 677
680 - 'section_font_size' => '18px',
681 - 'section_color' => '444444',
682 - 'section_weight' => 'bold',
683 - 'section_pad' => '15px 0 3px 0',
684 - 'section_mar_top' => '15px',
685 - 'section_mar_bottom' => '30px',
686 - 'section_bg_color' => '',
687 - 'section_border_color' => 'e8e8e8',
688 - 'section_border_width' => '2px',
689 - 'section_border_style' => 'solid',
690 - 'section_border_loc' => '-top',
691 - 'collapse_icon' => '6',
692 - 'collapse_pos' => 'after',
693 - 'repeat_icon' => '1',
694 - 'repeat_icon_color' => 'ffffff',
678 + 'section_font_size' => '18px',
679 + 'section_color' => '444444',
680 + 'section_weight' => 'bold',
681 + 'section_pad' => '15px 0 3px 0',
682 + 'section_mar_top' => '15px',
683 + 'section_mar_bottom' => '30px',
684 + 'section_bg_color' => '',
685 + 'section_border_color' => 'e8e8e8',
686 + 'section_border_width' => '2px',
687 + 'section_border_style' => 'solid',
688 + 'section_border_loc' => '-top',
689 + 'collapse_icon' => '6',
690 + 'collapse_pos' => 'after',
691 + 'repeat_icon' => '1',
692 + 'repeat_icon_color' => 'ffffff',
695 693
696 694 'submit_style' => false,
697 695 'submit_font_size' => '15px',
698 696 'submit_width' => 'auto',
@@ -713,30 +711,29 @@
713 711 'submit_active_bg_color' => 'efefef',
714 712 'submit_active_color' => '444444',
715 713 'submit_active_border_color' => 'cccccc',
716 714
717 - 'border_radius' => '4px',
718 - 'error_bg' => 'F2DEDE',
719 - 'error_border' => 'EBCCD1',
720 - 'error_text' => 'B94A48',
721 - 'error_font_size' => '14px',
715 + 'border_radius' => '4px',
716 + 'error_bg' => 'F2DEDE',
717 + 'error_border' => 'EBCCD1',
718 + 'error_text' => 'B94A48',
719 + 'error_font_size' => '14px',
722 720
723 - 'success_bg_color' => 'DFF0D8',
724 - 'success_border_color' => 'D6E9C6',
725 - 'success_text_color' => '468847',
726 - 'success_font_size' => '14px',
721 + 'success_bg_color' => 'DFF0D8',
722 + 'success_border_color' => 'D6E9C6',
723 + 'success_text_color' => '468847',
724 + 'success_font_size' => '14px',
727 725
728 - 'important_style' => false,
726 + 'important_style' => false,
729 727
730 - 'progress_bg_color' => 'eaeaea',
731 - 'progress_active_color' => 'ffffff',
732 - 'progress_active_bg_color' => '579AF6',
733 - 'progress_color' => '3f4b5b',
734 - 'progress_border_color' => 'E5E5E5',
735 - 'progress_border_size' => '2px',
736 - 'progress_size' => '24px',
737 -
738 - 'custom_css' => '',
728 + 'progress_bg_color' => 'eaeaea',
729 + 'progress_active_color' => 'ffffff',
730 + 'progress_active_bg_color' => '579AF6',
731 + 'progress_color' => '3f4b5b',
732 + 'progress_border_color' => 'E5E5E5',
733 + 'progress_border_size' => '2px',
734 + 'progress_size' => '24px',
735 + 'custom_css' => '',
739 736 );
740 737
741 738 return apply_filters( 'frm_default_style_settings', $defaults );
742 739 }