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/factories/FrmFieldFactory.php +15 -11 6.25 → trunk View file →
@@ -25,9 +25,9 @@
25 25 $selector = apply_filters( 'frm_create_field_value_selector', $selector, $field_id, $args );
26 26 }
27 27
28 28 if ( ! is_object( $selector ) ) {
29 - $selector = new FrmFieldValueSelector( $field_id, $args );
29 + return new FrmFieldValueSelector( $field_id, $args );
30 30 }
31 31
32 32 return $selector;
33 33 }
@@ -35,14 +35,15 @@
35 35 /**
36 36 * @since 3.0
37 37 *
38 38 * @param array|object $field
39 + *
39 40 * @return FrmFieldType
40 41 */
41 42 public static function get_field_factory( $field ) {
42 43 if ( is_object( $field ) ) {
43 44 $field_info = self::get_field_object( $field );
44 - } elseif ( isset( $field['id'] ) && $field['id'] ) {
45 + } elseif ( ! empty( $field['id'] ) ) {
45 46 $field_info = self::get_field_object( $field['id'] );
46 47 } else {
47 48 $field_info = self::get_field_type( $field['type'], $field );
48 49 }
@@ -72,15 +73,9 @@
72 73 * @return FrmFieldType
73 74 */
74 75 public static function get_field_type( $field_type, $field = 0 ) {
75 76 $class = self::get_field_type_class( $field_type );
76 - if ( empty( $class ) ) {
77 - $field = new FrmFieldDefault( $field, $field_type );
78 - } else {
79 - $field = new $class( $field, $field_type );
80 - }
81 -
82 - return $field;
77 + return $class ? new $class( $field, $field_type ) : new FrmFieldDefault( $field, $field_type );
83 78 }
84 79
85 80 /**
86 81 * @since 3.0
@@ -106,11 +101,15 @@
106 101 'hidden' => 'FrmFieldHidden',
107 102 'captcha' => 'FrmFieldCaptcha',
108 103 'name' => 'FrmFieldName',
109 104 'credit_card' => 'FrmFieldCreditCard',
105 + 'address' => 'FrmFieldAddress',
110 106 // Submit button field.
111 107 FrmSubmitHelper::FIELD_TYPE => 'FrmFieldSubmit',
112 108 FrmFieldGdprHelper::FIELD_TYPE => FrmFieldGdprHelper::get_gdpr_field_class( $field_type ),
109 + 'product' => 'FrmFieldProduct',
110 + 'quantity' => 'FrmFieldQuantity',
111 + 'total' => 'FrmFieldTotal',
113 112 );
114 113
115 114 $class = $type_classes[ $field_type ] ?? '';
116 115
@@ -118,13 +117,17 @@
118 117 }
119 118
120 119 /**
121 120 * @since 3.0
121 + *
122 + * @param string $type
123 + *
124 + * @return mixed
122 125 */
123 126 public static function field_has_html( $type ) {
124 127 $has_html = self::field_has_property( $type, 'has_html' );
125 128
126 - // this hook is here for reverse compatibility since 3.0
129 + // This hook is here for reverse compatibility since 3.0
127 130 return apply_filters( 'frm_show_custom_html', $has_html, $type );
128 131 }
129 132
130 133 /**
@@ -131,11 +134,12 @@
131 134 * @since 3.0
132 135 *
133 136 * @param string $type
134 137 * @param string $property
138 + *
139 + * @return mixed
135 140 */
136 141 public static function field_has_property( $type, $property ) {
137 142 $field = self::get_field_type( $type );
138 -
139 143 return $field->{$property};
140 144 }
141 145 }