PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.8
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.8
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 +148 -160 6.256.8 View file →
@@ -3,18 +3,9 @@
3 3 die( 'You are not allowed to call this page directly.' );
4 4 }
5 5
6 6 class FrmStyle {
7 -
8 7 /**
9 - * The meta name of default template style.
10 - *
11 - * @since 6.14
12 - * @var string
13 - */
14 - private $default_template_style_meta_name = 'frm_style_default';
15 -
16 - /**
17 8 * Unique ID number of the current instance.
18 9 *
19 10 * @var int
20 11 */
@@ -27,9 +18,9 @@
27 18 */
28 19 public $id = 0;
29 20
30 21 /**
31 - * @param int|string $id The id of the stylesheet or 'default'.
22 + * @param int|string $id The id of the stylsheet or 'default'.
32 23 */
33 24 public function __construct( $id = 0 ) {
34 25 $this->id = $id;
35 26 }
@@ -42,9 +33,9 @@
42 33
43 34 $max_slug_value = 2147483647;
44 35 // We want to have at least 2 characters in the slug.
45 36 $min_slug_value = 37;
46 - $key = base_convert( random_int( $min_slug_value, $max_slug_value ), 10, 36 );
37 + $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
47 38
48 39 $style = array(
49 40 'post_type' => FrmStylesController::$post_type,
50 41 'ID' => '',
@@ -88,9 +79,9 @@
88 79 }
89 80
90 81 $action_ids = array();
91 82
92 - foreach ( $all_instances as $new_instance ) {
83 + foreach ( $all_instances as $number => $new_instance ) {
93 84 $new_instance = (array) $new_instance;
94 85 $this->id = $new_instance['ID'];
95 86
96 87 if ( $id != $this->id || ! $_POST || ! isset( $_POST['frm_style_setting'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
@@ -99,9 +90,9 @@
99 90 }
100 91
101 92 // Custom CSS is no longer used from the default style, but it is still checked if the Global Setting is missing.
102 93 // 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'] ?? '';
94 + $custom_css = isset( $new_instance['post_content']['custom_css'] ) ? $new_instance['post_content']['custom_css'] : '';
104 95
105 96 // phpcs:ignore WordPress.Security.NonceVerification.Missing
106 97 if ( ! empty( $_POST['frm_style_setting']['post_title'] ) ) {
107 98 // The nonce check happens in FrmStylesController::save_style before this is called.
@@ -112,10 +103,10 @@
112 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
113 104 $new_instance['post_content']['custom_css'] = $custom_css;
114 105 unset( $custom_css );
115 106
116 - $new_instance['post_type'] = FrmStylesController::$post_type;
117 - $new_instance['post_status'] = 'publish';
107 + $new_instance['post_type'] = FrmStylesController::$post_type;
108 + $new_instance['post_status'] = 'publish';
118 109
119 110 if ( ! $id ) {
120 111 $new_instance['post_name'] = $new_instance['post_title'];
121 112 }
@@ -140,10 +131,8 @@
140 131 $new_instance['post_content'][ $setting ] = $this->force_balanced_quotation( $new_instance['post_content'][ $setting ] );
141 132 }
142 133 }
143 134
144 - $new_instance['post_content'] = FrmStylesHelper::update_base_font_size( $new_instance['post_content'], $this->get_defaults() );
145 -
146 135 $action_ids[] = $this->save( $new_instance );
147 136 }//end foreach
148 137
149 138 $this->save_settings();
@@ -210,9 +199,9 @@
210 199 $new_value = floatval( $value );
211 200 }
212 201 }//end if
213 202
214 - $new_color_values[] = $new_value;
203 + $new_color_values[] = null === $new_value ? $value : $new_value;
215 204 }//end foreach
216 205
217 206 // add more 0s and 1 (if alpha position) if needed.
218 207 $missing_values = $length_of_color_codes - count( $new_color_values );
@@ -236,13 +225,28 @@
236 225 $color_val = $new_color;
237 226 }
238 227
239 228 /**
229 + * Unslash everything in post_content but custom_css
230 + *
240 231 * @since 5.0.13
241 232 *
242 233 * @param array $settings
243 234 * @return array
244 235 */
236 + private function unslash_post_content( $settings ) {
237 + $custom_css = isset( $settings['custom_css'] ) ? $settings['custom_css'] : '';
238 + $settings = wp_unslash( $settings );
239 + $settings['custom_css'] = $custom_css;
240 + return $settings;
241 + }
242 +
243 + /**
244 + * @since 5.0.13
245 + *
246 + * @param array $settings
247 + * @return array
248 + */
245 249 public function sanitize_post_content( $settings ) {
246 250 $defaults = $this->get_defaults();
247 251 $valid_keys = array_keys( $defaults );
248 252 $sanitized_settings = array();
@@ -311,10 +315,12 @@
311 315 */
312 316 private function trim_braces( $input ) {
313 317 $output = $input;
314 318 // 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, '()' );
319 + if ( $output ) {
320 + if ( in_array( $output[0], array( '(', ')' ), true ) ) {
321 + $output = ltrim( $output, '()' );
322 + }
317 323 }
318 324 // Remove extra braces from the end.
319 325 if ( in_array( substr( $output, -1 ), array( '(', ')' ), true ) ) {
320 326 $output = rtrim( $output, '()' );
@@ -442,9 +448,9 @@
442 448 /**
443 449 * Delete a style by its post ID.
444 450 *
445 451 * @param int $id
446 - * @return false|WP_Post|null
452 + * @return WP_Post|false|null
447 453 */
448 454 public function destroy( $id ) {
449 455 if ( $id === $this->get_default_style()->ID ) {
450 456 return false;
@@ -452,9 +458,9 @@
452 458 return wp_delete_post( $id );
453 459 }
454 460
455 461 /**
456 - * @return stdClass|WP_Post
462 + * @return WP_Post|stdClass
457 463 */
458 464 public function get_one() {
459 465 if ( 'default' === $this->id ) {
460 466 $style = $this->get_default_style();
@@ -579,9 +585,9 @@
579 585 if ( ! is_array( $settings ) ) {
580 586 return $settings;
581 587 }
582 588
583 - $settings['line_height'] = ! isset( $settings['field_height'] ) || $settings['field_height'] == '' || $settings['field_height'] === 'auto' ? 'normal' : $settings['field_height'];
589 + $settings['line_height'] = ( ! isset( $settings['field_height'] ) || $settings['field_height'] == '' || $settings['field_height'] == 'auto' ) ? 'normal' : $settings['field_height'];
584 590
585 591 if ( ! isset( $settings['form_desc_size'] ) && isset( $settings['description_font_size'] ) ) {
586 592 $settings['form_desc_size'] = $settings['description_font_size'];
587 593 $settings['form_desc_color'] = $settings['description_color'];
@@ -610,144 +616,142 @@
610 616 * @return array
611 617 */
612 618 public function get_defaults() {
613 619 $defaults = array(
614 - 'theme_css' => 'ui-lightness',
615 - 'theme_name' => 'UI Lightness',
620 + 'theme_css' => 'ui-lightness',
621 + 'theme_name' => 'UI Lightness',
616 622
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' => '',
623 + 'center_form' => '',
624 + 'form_width' => '100%',
625 + 'form_align' => 'left',
626 + 'direction' => is_rtl() ? 'rtl' : 'ltr',
627 + 'fieldset' => '0px',
628 + 'fieldset_color' => '000000',
629 + 'fieldset_padding' => '0 0 15px 0',
630 + 'fieldset_bg_color' => '',
625 631
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',
632 + 'title_size' => '40px',
633 + 'title_color' => '444444',
634 + 'title_margin_top' => '10px',
635 + 'title_margin_bottom' => '60px',
636 + 'form_desc_size' => '14px',
637 + 'form_desc_color' => '666666',
638 + 'form_desc_margin_top' => '10px',
639 + 'form_desc_margin_bottom' => '25px',
640 + 'form_desc_padding' => '0',
635 641
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',
642 + 'font' => '',
643 + 'font_size' => '15px',
644 + 'label_color' => '3f4b5b',
645 + 'weight' => 'normal',
646 + 'position' => 'none',
647 + 'align' => 'left',
648 + 'width' => '150px',
649 + 'required_color' => 'B94A48',
650 + 'required_weight' => 'bold',
651 + 'label_padding' => '0 0 3px 0',
646 652
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',
653 + 'description_font_size' => '12px',
654 + 'description_color' => '666666',
655 + 'description_weight' => 'normal',
656 + 'description_style' => 'normal',
657 + 'description_align' => 'left',
658 + 'description_margin' => '0',
653 659
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',
660 + 'field_font_size' => '14px',
661 + 'field_height' => '32px',
662 + 'line_height' => 'normal',
663 + 'field_width' => '100%',
664 + 'auto_width' => false,
665 + 'field_pad' => '6px 10px',
666 + 'field_margin' => '20px',
667 + 'field_weight' => 'normal',
668 + 'text_color' => '555555',
663 669 // 'border_color_hv' => 'cccccc',
664 - 'border_color' => 'D0D5DD',
665 - 'field_border_width' => '1px',
666 - 'field_border_style' => 'solid',
670 + 'border_color' => 'BFC3C8',
671 + 'field_border_width' => '1px',
672 + 'field_border_style' => 'solid',
667 673
668 - 'bg_color' => 'ffffff',
674 + 'bg_color' => 'ffffff',
669 675 // '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',
676 + 'remove_box_shadow' => '',
677 + 'bg_color_active' => 'ffffff',
678 + 'border_color_active' => '66afe9',
679 + 'remove_box_shadow_active' => '',
680 + 'text_color_error' => '444444',
681 + 'bg_color_error' => 'ffffff',
682 + 'border_color_error' => 'B94A48',
683 + 'border_width_error' => '1px',
684 + 'border_style_error' => 'solid',
685 + 'bg_color_disabled' => 'ffffff',
686 + 'border_color_disabled' => 'E5E5E5',
687 + 'text_color_disabled' => 'A1A1A1',
682 688
683 - 'radio_align' => 'block',
684 - 'check_align' => 'block',
685 - 'check_font_size' => '14px',
686 - 'check_label_color' => '1D2939',
687 - 'check_weight' => 'normal',
689 + 'radio_align' => 'block',
690 + 'check_align' => 'block',
691 + 'check_font_size' => '13px',
692 + 'check_label_color' => '444444',
693 + 'check_weight' => 'normal',
688 694
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',
695 + 'section_font_size' => '18px',
696 + 'section_color' => '444444',
697 + 'section_weight' => 'bold',
698 + 'section_pad' => '15px 0 3px 0',
699 + 'section_mar_top' => '15px',
700 + 'section_mar_bottom' => '30px',
701 + 'section_bg_color' => '',
702 + 'section_border_color' => 'e8e8e8',
703 + 'section_border_width' => '2px',
704 + 'section_border_style' => 'solid',
705 + 'section_border_loc' => '-top',
706 + 'collapse_icon' => '6',
707 + 'collapse_pos' => 'after',
708 + 'repeat_icon' => '1',
709 + 'repeat_icon_color' => 'ffffff',
704 710
705 711 'submit_style' => false,
706 - 'submit_font_size' => '14px',
712 + 'submit_font_size' => '15px',
707 713 'submit_width' => 'auto',
708 714 'submit_height' => 'auto',
709 - 'submit_bg_color' => '4199FD',
710 - 'submit_border_color' => '4199FD',
715 + 'submit_bg_color' => '579AF6',
716 + 'submit_border_color' => '579AF6',
711 717 'submit_border_width' => '1px',
712 718 'submit_text_color' => 'ffffff',
713 719 'submit_weight' => 'normal',
714 - 'submit_border_radius' => '8px',
720 + 'submit_border_radius' => '4px',
715 721 'submit_bg_img' => '',
716 722 'submit_margin' => '10px',
717 - 'submit_padding' => '8px 16px',
723 + 'submit_padding' => '10px 20px',
718 724 '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',
725 + 'submit_hover_bg_color' => 'efefef',
726 + 'submit_hover_color' => '444444',
727 + 'submit_hover_border_color' => 'cccccc',
728 + 'submit_active_bg_color' => 'efefef',
729 + 'submit_active_color' => '444444',
730 + 'submit_active_border_color' => 'cccccc',
725 731
726 - 'border_radius' => '8px',
727 - 'error_bg' => 'FEE4E2',
728 - 'error_border' => 'F5B8AA',
729 - 'error_text' => 'F04438',
730 - 'error_font_size' => '14px',
732 + 'border_radius' => '4px',
733 + 'error_bg' => 'F2DEDE',
734 + 'error_border' => 'EBCCD1',
735 + 'error_text' => 'B94A48',
736 + 'error_font_size' => '14px',
731 737
732 - 'success_bg_color' => 'DFF0D8',
733 - 'success_border_color' => 'D6E9C6',
734 - 'success_text_color' => '468847',
735 - 'success_font_size' => '14px',
738 + 'success_bg_color' => 'DFF0D8',
739 + 'success_border_color' => 'D6E9C6',
740 + 'success_text_color' => '468847',
741 + 'success_font_size' => '14px',
736 742
737 - 'important_style' => false,
743 + 'important_style' => false,
738 744
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',
745 + 'progress_bg_color' => 'eaeaea',
746 + 'progress_active_color' => 'ffffff',
747 + 'progress_active_bg_color' => '579AF6',
748 + 'progress_color' => '3f4b5b',
749 + 'progress_border_color' => 'E5E5E5',
750 + 'progress_border_size' => '2px',
751 + 'progress_size' => '24px',
752 +
753 + 'custom_css' => '',
750 754 );
751 755
752 756 return apply_filters( 'frm_default_style_settings', $defaults );
753 757 }
@@ -767,17 +771,17 @@
767 771 * @return array
768 772 */
769 773 public static function get_bold_options() {
770 774 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' ),
775 + 100 => 100,
776 + 200 => 200,
777 + 300 => 300,
778 + 'normal' => __( 'normal', 'formidable' ),
779 + 500 => 500,
780 + 600 => 600,
781 + 'bold' => __( 'bold', 'formidable' ),
782 + 800 => 800,
783 + 900 => 900,
780 784 );
781 785 }
782 786
783 787 /**
@@ -802,22 +806,6 @@
802 806 $value .= $char;
803 807 }
804 808 }
805 809 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 810 }
823 811 }