PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.13
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.13
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/FrmField.php +53 -89 6.256.13 View file →
@@ -9,77 +9,72 @@
9 9 public static $transient_size = 200;
10 10
11 11 public static function field_selection() {
12 12 $fields = array(
13 - 'text' => array(
13 + 'text' => array(
14 14 'name' => __( 'Text', 'formidable' ),
15 15 'icon' => 'frm_icon_font frm_text2_icon',
16 16 ),
17 - 'textarea' => array(
17 + 'textarea' => array(
18 18 'name' => __( 'Paragraph', 'formidable' ),
19 19 'icon' => 'frm_icon_font frm_paragraph_icon',
20 20 ),
21 - 'checkbox' => array(
21 + 'checkbox' => array(
22 22 'name' => __( 'Checkboxes', 'formidable' ),
23 23 'icon' => 'frm_icon_font frm_check_square_icon',
24 24 ),
25 - 'radio' => array(
25 + 'radio' => array(
26 26 'name' => __( 'Radio Buttons', 'formidable' ),
27 27 'icon' => 'frm_icon_font frm_radio_checked_icon',
28 28 ),
29 - 'select' => array(
29 + 'select' => array(
30 30 'name' => __( 'Dropdown', 'formidable' ),
31 - 'icon' => 'frm_icon_font frm_dropdown_icon',
31 + 'icon' => 'frm_icon_font frm_caret_square_down_icon',
32 32 ),
33 - 'email' => array(
33 + 'email' => array(
34 34 'name' => __( 'Email', 'formidable' ),
35 - 'icon' => 'frm_icon_font frm_email2_icon',
35 + 'icon' => 'frm_icon_font frm_email_icon',
36 36 ),
37 - 'url' => array(
37 + 'url' => array(
38 38 'name' => __( 'Website/URL', 'formidable' ),
39 - 'icon' => 'frm_icon_font frm_link2_icon',
39 + 'icon' => 'frm_icon_font frm_link_icon',
40 40 ),
41 - 'number' => array(
41 + 'number' => array(
42 42 'name' => __( 'Number', 'formidable' ),
43 43 'icon' => 'frm_icon_font frm_hashtag_icon',
44 44 ),
45 - 'name' => array(
45 + 'name' => array(
46 46 'name' => __( 'Name', 'formidable' ),
47 47 'icon' => 'frm_icon_font frm_user_name_icon',
48 48 ),
49 - 'phone' => array(
49 + 'phone' => array(
50 50 'name' => __( 'Phone', 'formidable' ),
51 51 'icon' => 'frm_icon_font frm_phone_icon',
52 52 ),
53 - 'html' => array(
53 + 'html' => array(
54 54 'name' => __( 'HTML', 'formidable' ),
55 - 'icon' => 'frm_icon_font frm_code2_icon',
55 + 'icon' => 'frm_icon_font frm_code_icon',
56 56 ),
57 - 'hidden' => array(
57 + 'hidden' => array(
58 58 'name' => __( 'Hidden', 'formidable' ),
59 - 'icon' => 'frm_icon_font frm_eye_slash2_icon',
59 + 'icon' => 'frm_icon_font frm_eye_slash_icon',
60 60 ),
61 - 'user_id' => array(
61 + 'user_id' => array(
62 62 'name' => __( 'User ID', 'formidable' ),
63 - 'icon' => 'frm_icon_font frm_user2_icon',
63 + 'icon' => 'frm_icon_font frm_user_icon',
64 64 ),
65 - 'captcha' => array(
65 + 'captcha' => array(
66 66 'name' => self::get_captcha_field_name(),
67 - 'icon' => 'frm_icon_font frm_shield_check2_icon',
67 + 'icon' => 'frm_icon_font frm_shield_check_icon',
68 68 ),
69 - 'credit_card' => array(
69 + 'credit_card' => array(
70 70 'name' => __( 'Payment', 'formidable' ),
71 - 'icon' => 'frm_icon_font frm_credit_card2_icon',
71 + 'icon' => 'frm_icon_font frm_credit_card_icon',
72 72 ),
73 - FrmSubmitHelper::FIELD_TYPE => array(
73 + FrmSubmitHelper::FIELD_TYPE => array(
74 74 'name' => __( 'Submit', 'formidable' ),
75 75 'hide' => true,
76 76 ),
77 - FrmFieldGdprHelper::FIELD_TYPE => array(
78 - 'name' => __( 'GDPR', 'formidable' ),
79 - 'icon' => 'frm_icon_font frm-gdpr-icon',
80 - 'hide' => FrmFieldGdprHelper::hide_gdpr_field(),
81 - ),
82 77 );
83 78
84 79 /**
85 80 * @param array $fields
@@ -100,9 +95,9 @@
100 95 $images_url = FrmAppHelper::plugin_url() . '/images/';
101 96 $fields = array(
102 97 'file' => array(
103 98 'name' => __( 'File Upload', 'formidable' ),
104 - 'icon' => 'frm_icon_font frm_upload3_icon',
99 + 'icon' => 'frm_icon_font frm_upload_icon',
105 100 'message' => __( 'Add file uploads to save time and cut down on back-and-forth. Upgrade to Pro to get Upload fields and more.', 'formidable' ),
106 101 ),
107 102 'ranking' => array(),
108 103 'rte' => array(
@@ -110,9 +105,9 @@
110 105 'icon' => 'frm_icon_font frm_align_right_icon',
111 106 ),
112 107 'date' => array(
113 108 'name' => __( 'Date', 'formidable' ),
114 - 'icon' => 'frm_icon_font frm_calendar2_icon',
109 + 'icon' => 'frm_icon_font frm_calendar_icon',
115 110 ),
116 111 'time' => array(
117 112 'name' => __( 'Time', 'formidable' ),
118 113 'icon' => 'frm_icon_font frm_clock_icon',
@@ -123,9 +118,9 @@
123 118 'message' => esc_html__( 'Add a set of radio buttons with whatever range you choose.', 'formidable' ) . '<img src="' . esc_url( $images_url ) . 'scale_field.png" alt="' . esc_attr__( 'Scale Field', 'formidable' ) . '" />',
124 119 ),
125 120 'star' => array(
126 121 'name' => __( 'Star Rating', 'formidable' ),
127 - 'icon' => 'frm_icon_font frm_star2_icon',
122 + 'icon' => 'frm_icon_font frm_star_icon',
128 123 ),
129 124 'range' => array(
130 125 'name' => __( 'Slider', 'formidable' ),
131 126 'icon' => 'frm_icon_font frm_code_commit_icon',
@@ -135,9 +130,9 @@
135 130 'icon' => 'frm_icon_font frm_toggle_on_icon',
136 131 ),
137 132 'data' => array(
138 133 'name' => __( 'Dynamic', 'formidable' ),
139 - 'icon' => 'frm_icon_font frm_dynamic_icon',
134 + 'icon' => 'frm_icon_font frm_sitemap_icon',
140 135 'message' => __( 'Create relationships between multiple forms. You can link a member to a team, a rating to a product, a comment to a submission, and much more.', 'formidable' ),
141 136 ),
142 137 'lookup' => array(
143 138 'name' => __( 'Lookup', 'formidable' ),
@@ -145,9 +140,9 @@
145 140 'message' => esc_html__( 'Filter the options in the next field and automatically add values to other fields. Upgrade to Pro to get Lookup fields and more.', 'formidable' ) . ' <img src="' . esc_url( $images_url ) . 'look-up_year-make-model.gif" alt="' . esc_attr__( 'cascading lookup fields', 'formidable' ) . '" />',
146 141 ),
147 142 'divider|repeat' => array(
148 143 'name' => __( 'Repeater', 'formidable' ),
149 - 'icon' => 'frm_icon_font frm_refresh_icon',
144 + 'icon' => 'frm_icon_font frm_repeater_icon',
150 145 'message' => esc_html__( 'Allow your visitors to add new sets of fields while filling out forms. Increase conversions while saving building time and server resources.', 'formidable' ) . ' <img src="' . esc_url( $images_url ) . 'repeatable-section_frontend.gif" alt="' . esc_attr__( 'Dynamically Add Form Fields with repeatable sections', 'formidable' ) . '" />',
151 146 ),
152 147 'end_divider' => array(
153 148 'name' => __( 'Section Buttons', 'formidable' ),
@@ -163,9 +158,9 @@
163 158 'message' => __( 'Get multi-paged forms with progress bars. Did you know you can upgrade to PRO to unlock multi-step forms with more awesome features?', 'formidable' ),
164 159 ),
165 160 'form' => array(
166 161 'name' => __( 'Embed Form', 'formidable' ),
167 - 'icon' => 'frm_icon_font frm_file_text2_icon',
162 + 'icon' => 'frm_icon_font frm_file_text_icon',
168 163 ),
169 164 'likert' => array(
170 165 'name' => __( 'Likert Scale', 'formidable' ),
171 166 'icon' => 'frm_icon_font frm_likert_scale frm_show_upgrade',
@@ -177,13 +172,13 @@
177 172 'addon' => 'surveys',
178 173 ),
179 174 'password' => array(
180 175 'name' => __( 'Password', 'formidable' ),
181 - 'icon' => 'frm_icon_font frm_lock_closed2_icon',
176 + 'icon' => 'frm_icon_font frm_lock_open_icon',
182 177 ),
183 178 'tag' => array(
184 179 'name' => __( 'Tags', 'formidable' ),
185 - 'icon' => 'frm_icon_font frm_price_tags2_icon',
180 + 'icon' => 'frm_icon_font frm_price_tags_icon',
186 181 ),
187 182 // This is no longer a Pro field, but without this here, Pro triggers "undefined index" notices.
188 183 // Right now it leaves a gap. Maybe we can skip anything without a name or something.
189 184 'credit_card' => array(
@@ -191,13 +186,13 @@
191 186 'icon' => '',
192 187 ),
193 188 'address' => array(
194 189 'name' => __( 'Address', 'formidable' ),
195 - 'icon' => 'frm_icon_font frm_location2_icon',
190 + 'icon' => 'frm_icon_font frm_location_icon',
196 191 ),
197 192 'summary' => array(
198 193 'name' => __( 'Summary', 'formidable' ),
199 - 'icon' => 'frm_icon_font frm_file_text3_icon',
194 + 'icon' => 'frm_icon_font frm_file_text_icon',
200 195 'message' => __( 'Allow visitors to review their responses before a form is submitted. Upgrade to Pro to get Summary fields and more.', 'formidable' ),
201 196 ),
202 197 'signature' => array(
203 198 'name' => __( 'Signature', 'formidable' ),
@@ -205,15 +200,15 @@
205 200 'addon' => 'signature',
206 201 ),
207 202 'ai' => array(
208 203 'name' => __( 'AI', 'formidable' ),
209 - 'icon' => 'frm_icon_font frm-ai-icon frm_show_upgrade',
204 + 'icon' => 'frm_icon_font frm_eye_icon frm_show_upgrade',
210 205 'addon' => 'ai',
211 206 'message' => __( 'Streamline workflows and reclaim valuable time with the power of AI. You can effortlessly respond to your visitors in real-time with ChatGPT as your automated assistant. Upgrade to Pro and unlock AI-powered fields.', 'formidable' ),
212 207 ),
213 208 'ssa-appointment' => array(
214 209 'name' => __( 'Appointment', 'formidable' ),
215 - 'icon' => 'frm_icon_font frm_schedule_icon frm_show_upgrade',
210 + 'icon' => 'frm_icon_font frm_calendar_icon frm_show_upgrade',
216 211 'require' => 'Simply Schedule Appointments',
217 212 'message' => sprintf(
218 213 /* translators: %1$s: Link opening HTML, %2$s: Link tag closing */
219 214 esc_html__( 'Appointment fields are an integration with %1$sSimply Schedule Appointments%2$s. Get started now to schedule appointments directly from your forms.', 'formidable' ),
@@ -223,9 +218,9 @@
223 218 'link' => 'https://simplyscheduleappointments.com/meet/formidable/',
224 219 ),
225 220 'product' => array(
226 221 'name' => __( 'Product', 'formidable' ),
227 - 'icon' => 'frm_icon_font frm_product2_icon',
222 + 'icon' => 'frm_icon_font frm_product_icon',
228 223 'section' => 'pricing',
229 224 ),
230 225 'quantity' => array(
231 226 'name' => __( 'Quantity', 'formidable' ),
@@ -233,9 +228,9 @@
233 228 'section' => 'pricing',
234 229 ),
235 230 'total' => array(
236 231 'name' => __( 'Total', 'formidable' ),
237 - 'icon' => 'frm_icon_font frm_total2_icon',
232 + 'icon' => 'frm_icon_font frm_total_icon',
238 233 'section' => 'pricing',
239 234 ),
240 235 );
241 236
@@ -376,17 +371,15 @@
376 371 public static function create( $values, $return = true ) {
377 372 global $wpdb, $frm_duplicate_ids;
378 373
379 374 $new_values = array();
380 - $key = $values['field_key'] ?? $values['name'];
375 + $key = isset( $values['field_key'] ) ? $values['field_key'] : $values['name'];
381 376 $new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' );
382 377
383 378 $values = FrmAppHelper::maybe_filter_array( $values, array( 'name', 'description' ) );
384 379
385 380 foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) {
386 - if ( isset( $values[ $col ] ) ) {
387 - $new_values[ $col ] = $values[ $col ];
388 - }
381 + $new_values[ $col ] = $values[ $col ];
389 382 }
390 383
391 384 $new_values['options'] = self::maybe_filter_options( $values['options'] );
392 385 $new_values['field_order'] = isset( $values['field_order'] ) ? (int) $values['field_order'] : null;
@@ -449,12 +442,8 @@
449 442 if ( ! empty( $options['custom_html'] ) ) {
450 443 $options['custom_html'] = self::maybe_filter_custom_html_input_attributes( $options['custom_html'] );
451 444 }
452 445
453 - if ( ! empty( $options['classes'] ) ) {
454 - $options['classes'] = implode( ' ', array_map( 'FrmFormsHelper::sanitize_layout_class', explode( ' ', $options['classes'] ) ) );
455 - }
456 -
457 446 return $options;
458 447 }
459 448
460 449 /**
@@ -810,14 +799,14 @@
810 799 $field = FrmDb::check_cache( $id, 'frm_field' );
811 800 if ( $field ) {
812 801 $type = $field->{$col};
813 802 } else {
814 - if ( is_numeric( $id ) ) {
815 - $where = array( 'id' => $id );
816 - } else {
817 - $where = array( 'field_key' => $id );
818 - }
819 - $type = FrmDb::get_var( 'frm_fields', $where, $col );
803 + $where = array(
804 + 'or' => 1,
805 + 'id' => $id,
806 + 'field_key' => $id,
807 + );
808 + $type = FrmDb::get_var( 'frm_fields', $where, $col );
820 809 }
821 810
822 811 return $type;
823 812 }
@@ -1010,9 +999,9 @@
1010 999 }
1011 1000
1012 1001 $limit = FrmDb::esc_limit( $limit );
1013 1002
1014 - $query = "SELECT fi.*, fr.name as form_name FROM {$table_name} fi JOIN {$form_table_name} fr ON fi.form_id=fr.id";
1003 + $query = "SELECT fi.*, fr.name as form_name FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id";
1015 1004 $query_type = $limit === ' LIMIT 1' || $limit == 1 ? 'row' : 'results';
1016 1005
1017 1006 if ( is_array( $where ) ) {
1018 1007 $args = array(
@@ -1018,9 +1007,9 @@
1018 1007 $args = array(
1019 1008 'order_by' => $order_by,
1020 1009 'limit' => $limit,
1021 1010 );
1022 - $results = FrmDb::get_var( $table_name . ' fi JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', $args, '', $query_type );
1011 + $results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', $args, '', $query_type );
1023 1012 } else {
1024 1013 // if the query is not an array, then it has already been prepared
1025 1014 $query .= FrmDb::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
1026 1015
@@ -1041,10 +1030,8 @@
1041 1030 */
1042 1031 private static function format_field_results( &$results ) {
1043 1032 if ( is_array( $results ) ) {
1044 1033 foreach ( $results as $r_key => $result ) {
1045 - self::add_slashes_to_format_before_setting_field_cache( $result );
1046 -
1047 1034 FrmDb::set_cache( $result->id, $result, 'frm_field' );
1048 1035 FrmDb::set_cache( $result->field_key, $result, 'frm_field' );
1049 1036
1050 1037 self::prepare_options( $result );
@@ -1062,26 +1049,8 @@
1062 1049 }
1063 1050 }
1064 1051
1065 1052 /**
1066 - * When $result->field_options is an array and not a serialized string there is only a single backslash.
1067 - * Cached results are unslashed in FrmField::getAll, so we need to make sure that the cached object has an extra backslash.
1068 - * Otherwise the backslash is stripped away on load.
1069 - *
1070 - * @since 6.15
1071 - *
1072 - * @param stdClass $result
1073 - * @return void
1074 - */
1075 - private static function add_slashes_to_format_before_setting_field_cache( $result ) {
1076 - if ( ! isset( $result->field_options ) || ! is_array( $result->field_options ) || empty( $result->field_options['format'] ) ) {
1077 - return;
1078 - }
1079 -
1080 - $result->field_options['format'] = addslashes( $result->field_options['format'] );
1081 - }
1082 -
1083 - /**
1084 1053 * Unserialize all the serialized field data
1085 1054 *
1086 1055 * @since 2.0
1087 1056 */
@@ -1090,16 +1059,11 @@
1090 1059 FrmAppHelper::unserialize_or_decode( $results->options );
1091 1060
1092 1061 // Allow a single box to be checked for the default value.
1093 1062 $before = $results->default_value;
1094 -
1095 - $field_object = FrmFieldFactory::get_field_type( $results->type );
1096 -
1097 - if ( $field_object->should_unserialize_value() ) {
1098 - FrmAppHelper::unserialize_or_decode( $results->default_value );
1099 - if ( $before === $results->default_value && is_string( $before ) && strpos( $before, '["' ) === 0 ) {
1100 - $results->default_value = FrmAppHelper::maybe_json_decode( $results->default_value );
1101 - }
1063 + FrmAppHelper::unserialize_or_decode( $results->default_value );
1064 + if ( $before === $results->default_value && ! is_array( $before ) && strpos( $before, '["' ) === 0 ) {
1065 + $results->default_value = FrmAppHelper::maybe_json_decode( $results->default_value );
1102 1066 }
1103 1067 }
1104 1068
1105 1069 /**
@@ -1149,9 +1113,9 @@
1149 1113 $set = set_transient( $name, $field, 60 * 60 * 6 );
1150 1114 if ( ! $set ) {
1151 1115 // the transient didn't save
1152 1116 if ( $name != $base_name ) {
1153 - // if the first saved an others fail, this will show an incomplete form
1117 + // if the first saved an others fail, this will show an incmoplete form
1154 1118 self::delete_form_transient( $form_id );
1155 1119 }
1156 1120
1157 1121 return;
@@ -1383,9 +1347,9 @@
1383 1347 * @param string $option
1384 1348 * @return mixed
1385 1349 */
1386 1350 public static function get_option_in_object( $field, $option ) {
1387 - return $field->field_options[ $option ] ?? '';
1351 + return isset( $field->field_options[ $option ] ) ? $field->field_options[ $option ] : '';
1388 1352 }
1389 1353
1390 1354 /**
1391 1355 * @since 2.0.09