PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 4.07.01
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v4.07.01
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 +32 -150 6.54.07.01 View file →
@@ -41,12 +41,8 @@
41 41 'number' => array(
42 42 'name' => __( 'Number', 'formidable' ),
43 43 'icon' => 'frm_icon_font frm_hashtag_icon',
44 44 ),
45 - 'name' => array(
46 - 'name' => __( 'Name', 'formidable' ),
47 - 'icon' => 'frm_icon_font frm_user_name_icon',
48 - ),
49 45 'phone' => array(
50 46 'name' => __( 'Phone', 'formidable' ),
51 47 'icon' => 'frm_icon_font frm_phone_icon',
52 48 ),
@@ -62,44 +58,18 @@
62 58 'name' => __( 'User ID', 'formidable' ),
63 59 'icon' => 'frm_icon_font frm_user_icon',
64 60 ),
65 61 'captcha' => array(
66 - 'name' => self::get_captcha_field_name(),
62 + 'name' => __( 'reCAPTCHA', 'formidable' ),
67 63 'icon' => 'frm_icon_font frm_shield_check_icon',
68 64 ),
69 - 'credit_card' => array(
70 - 'name' => __( 'Payment', 'formidable' ),
71 - 'icon' => 'frm_icon_font frm_credit_card_icon',
72 - ),
73 65 );
74 66
75 - /**
76 - * @param array $fields
77 - */
78 67 return apply_filters( 'frm_available_fields', $fields );
79 68 }
80 69
81 - /**
82 - * Get the name of the Captcha field based on the global Captcha setting.
83 - *
84 - * @return string
85 - */
86 - private static function get_captcha_field_name() {
87 - $frm_settings = FrmAppHelper::get_settings();
88 - $active_captcha = $frm_settings->active_captcha;
89 - if ( ! FrmFieldCaptcha::should_show_captcha() ) {
90 - $captcha_name = 'Captcha';
91 - } elseif ( $active_captcha === 'recaptcha' ) {
92 - $captcha_name = 'reCAPTCHA';
93 - } else {
94 - $captcha_name = 'hCaptcha';
95 - }
96 - return $captcha_name;
97 - }
98 -
99 70 public static function pro_field_selection() {
100 - $images_url = FrmAppHelper::plugin_url() . '/images/';
101 - $fields = array(
71 + $fields = array(
102 72 'file' => array(
103 73 'name' => __( 'File Upload', 'formidable' ),
104 74 'icon' => 'frm_icon_font frm_upload_icon',
105 75 'message' => 'Add file uploads to save time and cut down on back-and-forth. Upgrade to Pro to get Upload fields and more.',
@@ -118,9 +88,9 @@
118 88 ),
119 89 'scale' => array(
120 90 'name' => __( 'Scale', 'formidable' ),
121 91 'icon' => 'frm_icon_font frm_linear_scale_icon',
122 - 'message' => 'Add a set of radio buttons with whatever range you choose. <img src="' . esc_attr( $images_url ) . 'scale_field.png" alt="Scale Field" />',
92 + 'message' => 'Add a set of radio buttons with whatever range you choose. <img src="https://s3.amazonaws.com/fp.strategy11.com/images/knowledgebase/scale_field.png" alt="Scale Field" />',
123 93 ),
124 94 'star' => array(
125 95 'name' => __( 'Star Rating', 'formidable' ),
126 96 'icon' => 'frm_icon_font frm_star_icon',
@@ -140,14 +110,14 @@
140 110 ),
141 111 'lookup' => array(
142 112 'name' => __( 'Lookup', 'formidable' ),
143 113 'icon' => 'frm_icon_font frm_search_icon',
144 - 'message' => 'Filter the options in the next field and automatically add values to other fields. Upgrade to Pro to get Lookup fields and more. <img src="' . esc_attr( $images_url ) . 'look-up_year-make-model.gif" alt="cascading lookup fields" />',
114 + 'message' => 'Filter the options in the next field and automatically add values to other fields. Upgrade to Pro to get Lookup fields and more. <img src="https://s3.amazonaws.com/fp.strategy11.com/images/knowledgebase/look-up_year-make-model.gif" alt="cascading lookup fields" />',
145 115 ),
146 116 'divider|repeat' => array(
147 117 'name' => __( 'Repeater', 'formidable' ),
148 118 'icon' => 'frm_icon_font frm_repeater_icon',
149 - 'message' => 'Allow your visitors to add new sets of fields while filling out forms. Increase conversions while saving building time and server resources. <img src="' . esc_attr( $images_url ) . 'repeatable-section_frontend.gif" alt="Dynamically Add Form Fields with repeatable sections" />',
119 + 'message' => 'Allow your visitors to add new sets of fields while filling out forms. Increase conversions while saving building time and server resources. <img src="https://s3.amazonaws.com/fp.strategy11.com/images/knowledgebase/repeatable-section_frontend.gif" alt="Dynamically Add Form Fields with repeatable sections" />',
150 120 ),
151 121 'end_divider' => array(
152 122 'name' => __( 'Section Buttons', 'formidable' ),
153 123 'switch_from' => 'divider',
@@ -164,18 +134,8 @@
164 134 'form' => array(
165 135 'name' => __( 'Embed Form', 'formidable' ),
166 136 'icon' => 'frm_icon_font frm_file_text_icon',
167 137 ),
168 - 'likert' => array(
169 - 'name' => __( 'Likert Scale', 'formidable' ),
170 - 'icon' => 'frm_icon_font frm_likert_scale frm_show_upgrade',
171 - 'addon' => 'surveys',
172 - ),
173 - 'nps' => array(
174 - 'name' => __( 'NPS', 'formidable' ),
175 - 'icon' => 'frm_icon_font frm_nps frm_show_upgrade',
176 - 'addon' => 'surveys',
177 - ),
178 138 'password' => array(
179 139 'name' => __( 'Password', 'formidable' ),
180 140 'icon' => 'frm_icon_font frm_lock_open_icon',
181 141 ),
@@ -182,13 +142,12 @@
182 142 'tag' => array(
183 143 'name' => __( 'Tags', 'formidable' ),
184 144 'icon' => 'frm_icon_font frm_price_tags_icon',
185 145 ),
186 - // This is no longer a Pro field, but without this here, Pro triggers "undefined index" notices.
187 - // Right now it leaves a gap. Maybe we can skip anything without a name or something.
188 146 'credit_card' => array(
189 - 'name' => '',
190 - 'icon' => '',
147 + 'name' => __( 'Credit Card', 'formidable' ),
148 + 'icon' => 'frm_icon_font frm_credit_card_icon frm_show_upgrade',
149 + 'addon' => 'stripe',
191 150 ),
192 151 'address' => array(
193 152 'name' => __( 'Address', 'formidable' ),
194 153 'icon' => 'frm_icon_font frm_location_icon',
@@ -202,13 +161,12 @@
202 161 'name' => __( 'Signature', 'formidable' ),
203 162 'icon' => 'frm_icon_font frm_signature_icon frm_show_upgrade',
204 163 'addon' => 'signature',
205 164 ),
206 - 'ai' => array(
207 - 'name' => __( 'AI', 'formidable' ),
208 - 'icon' => 'frm_icon_font frm_eye_icon frm_show_upgrade',
209 - 'addon' => 'ai',
210 - '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.',
165 + 'quiz_score' => array(
166 + 'name' => __( 'Quiz Score', 'formidable' ),
167 + 'icon' => 'frm_icon_font frm_percent_icon frm_show_upgrade',
168 + 'addon' => 'quizzes',
211 169 ),
212 170 'ssa-appointment' => array(
213 171 'name' => __( 'Appointment', 'formidable' ),
214 172 'icon' => 'frm_icon_font frm_calendar_icon frm_show_upgrade',
@@ -213,9 +171,9 @@
213 171 'name' => __( 'Appointment', 'formidable' ),
214 172 'icon' => 'frm_icon_font frm_calendar_icon frm_show_upgrade',
215 173 'require' => 'Simply Schedule Appointments',
216 174 'message' => 'Appointment fields are an integration with <a href="https://simplyscheduleappointments.com/meet/formidable/">Simply Schedule Appointments</a>. Get started now to schedule appointments directly from your forms.
217 - <img src="' . esc_attr( $images_url ) . 'appointments.png" alt="Scheduling" />',
175 + <img src="https://s3.amazonaws.com/fp.strategy11.com/images/appointments/appointments.png" alt="Scheduling" />',
218 176 'link' => 'https://simplyscheduleappointments.com/meet/formidable/',
219 177 ),
220 178 'product' => array(
221 179 'name' => __( 'Product', 'formidable' ),
@@ -233,12 +191,8 @@
233 191 'section' => 'pricing',
234 192 ),
235 193 );
236 194
237 - if ( ! FrmAppHelper::show_new_feature( 'ai' ) ) {
238 - unset( $fields['ai'] );
239 - }
240 -
241 195 // Since the signature field may be in a different section, don't show it twice.
242 196 $lite_fields = self::field_selection();
243 197 if ( isset( $lite_fields['signature'] ) ) {
244 198 unset( $fields['signature'] );
@@ -254,15 +208,8 @@
254 208 $pro_field_selection = self::pro_field_selection();
255 209 return array_merge( $pro_field_selection, self::field_selection() );
256 210 }
257 211
258 - /**
259 - * Create a field.
260 - *
261 - * @param array $values
262 - * @param bool $return
263 - * @return int|false
264 - */
265 212 public static function create( $values, $return = true ) {
266 213 global $wpdb, $frm_duplicate_ids;
267 214
268 215 $new_values = array();
@@ -268,15 +215,14 @@
268 215 $new_values = array();
269 216 $key = isset( $values['field_key'] ) ? $values['field_key'] : $values['name'];
270 217 $new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' );
271 218
272 - $values = FrmAppHelper::maybe_filter_array( $values, array( 'name', 'description' ) );
273 -
274 219 foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) {
275 220 $new_values[ $col ] = $values[ $col ];
276 221 }
277 222
278 - $new_values['options'] = self::maybe_filter_options( $values['options'] );
223 + $new_values['options'] = $values['options'];
224 +
279 225 $new_values['field_order'] = isset( $values['field_order'] ) ? (int) $values['field_order'] : null;
280 226 $new_values['required'] = isset( $values['required'] ) ? (int) $values['required'] : 0;
281 227 $new_values['form_id'] = isset( $values['form_id'] ) ? (int) $values['form_id'] : null;
282 228 $new_values['field_options'] = $values['field_options'];
@@ -299,77 +245,31 @@
299 245 }
300 246 unset( $k, $v );
301 247 }
302 248
249 + //if(isset($values['id']) and is_numeric($values['id']))
250 + // $new_values['id'] = $values['id'];
251 +
303 252 $query_results = $wpdb->insert( $wpdb->prefix . 'frm_fields', $new_values );
304 -
305 - if ( ! $query_results ) {
306 - return false;
253 + $new_id = 0;
254 + if ( $query_results ) {
255 + self::delete_form_transient( $new_values['form_id'] );
256 + $new_id = $wpdb->insert_id;
307 257 }
308 258
309 - self::delete_form_transient( $new_values['form_id'] );
310 - $new_id = $wpdb->insert_id;
311 -
312 259 if ( ! $return ) {
313 260 return false;
314 261 }
315 262
316 - if ( isset( $values['id'] ) ) {
317 - $frm_duplicate_ids[ $values['id'] ] = $new_id;
318 - }
263 + if ( $query_results ) {
264 + if ( isset( $values['id'] ) ) {
265 + $frm_duplicate_ids[ $values['id'] ] = $new_id;
266 + }
319 267
320 - return $new_id;
321 - }
322 -
323 - /**
324 - * @since 5.0.08
325 - *
326 - * @param array $options
327 - * @return array
328 - */
329 - private static function maybe_filter_options( $options ) {
330 - return FrmAppHelper::maybe_filter_array( $options, array( 'custom_html' ) );
331 - }
332 -
333 - /**
334 - * Process the field duplication.
335 - *
336 - * @since 5.0.05
337 - */
338 - public static function duplicate_single_field( $field_id, $form_id ) {
339 - $copy_field = self::getOne( $field_id );
340 - if ( ! $copy_field ) {
268 + return $new_id;
269 + } else {
341 270 return false;
342 271 }
343 -
344 - do_action( 'frm_duplicate_field', $copy_field, $form_id );
345 - do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id );
346 -
347 - $values = array(
348 - 'id' => $copy_field->id,
349 - );
350 - FrmFieldsHelper::fill_field( $values, $copy_field, $copy_field->form_id );
351 - $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values );
352 -
353 - $field_id = self::create( $values );
354 -
355 - /**
356 - * Fires after duplicating a field.
357 - *
358 - * @since 5.0.04
359 - *
360 - * @param array $args {
361 - * The arguments.
362 - *
363 - * @type int $field_id New field ID.
364 - * @type array $values Values before inserting.
365 - * @type object $copy_field Copy field data.
366 - * @type int $form_id Form ID.
367 - * }
368 - */
369 - do_action( 'frm_after_duplicate_field', compact( 'field_id', 'values', 'copy_field', 'form_id' ) );
370 -
371 - return compact( 'field_id', 'values' );
372 272 }
373 273
374 274 public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) {
375 275 global $frm_duplicate_ids;
@@ -428,10 +328,9 @@
428 328
429 329 public static function update( $id, $values ) {
430 330 global $wpdb;
431 331
432 - $id = absint( $id );
433 - $values = FrmAppHelper::maybe_filter_array( $values, array( 'name', 'description' ) );
332 + $id = absint( $id );
434 333
435 334 if ( isset( $values['field_key'] ) ) {
436 335 $values['field_key'] = FrmAppHelper::get_unique_key( $values['field_key'], $wpdb->prefix . 'frm_fields', 'field_key', $id );
437 336 }
@@ -444,9 +343,9 @@
444 343
445 344 if ( isset( $values['type'] ) ) {
446 345 $values = apply_filters( 'frm_clean_' . $values['type'] . '_field_options_before_update', $values );
447 346
448 - if ( $values['type'] === 'hidden' && isset( $values['field_options'] ) && isset( $values['field_options']['clear_on_focus'] ) ) {
347 + if ( $values['type'] == 'hidden' && isset( $values['field_options'] ) && isset( $values['field_options']['clear_on_focus'] ) ) {
449 348 // don't keep the old placeholder setting for hidden fields
450 349 $values['field_options']['clear_on_focus'] = 0;
451 350 }
452 351 }
@@ -453,11 +352,8 @@
453 352
454 353 // serialize array values
455 354 foreach ( array( 'field_options', 'options' ) as $opt ) {
456 355 if ( isset( $values[ $opt ] ) && is_array( $values[ $opt ] ) ) {
457 - if ( 'field_options' === $opt ) {
458 - $values[ $opt ] = self::maybe_filter_options( $values[ $opt ] );
459 - }
460 356 $values[ $opt ] = serialize( $values[ $opt ] );
461 357 }
462 358 }
463 359 if ( isset( $values['default_value'] ) && is_array( $values['default_value'] ) ) {
@@ -557,9 +453,9 @@
557 453
558 454 global $wpdb;
559 455
560 456 $where = is_numeric( $id ) ? 'id=%d' : 'field_key=%s';
561 - $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
457 + $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id ); // WPCS: unprepared SQL ok.
562 458
563 459 $results = FrmDb::check_cache( $id, 'frm_field', $query, 'get_row', 0 );
564 460
565 461 if ( empty( $results ) ) {
@@ -1105,9 +1001,9 @@
1105 1001
1106 1002 /**
1107 1003 * @param string $id
1108 1004 *
1109 - * @return null|string
1005 + * @return string
1110 1006 */
1111 1007 public static function get_key_by_id( $id ) {
1112 1008 return FrmDb::get_var( 'frm_fields', array( 'id' => $id ), 'field_key' );
1113 1009 }
@@ -1171,20 +1067,6 @@
1171 1067 *
1172 1068 * @since 4.04
1173 1069 */
1174 1070 return apply_filters( 'frm_is_field_type', $is_field_type, compact( 'field', 'is_type' ) );
1175 - }
1176 -
1177 - /**
1178 - * Checks if the given field array is a combo field.
1179 - *
1180 - * @since 4.10.02
1181 - *
1182 - * @param array $field Field array.
1183 - * @return bool
1184 - */
1185 - public static function is_combo_field( $field ) {
1186 - $field_type_obj = FrmFieldFactory::get_field_factory( $field );
1187 -
1188 - return ! empty( $field_type_obj->is_combo_field );
1189 1071 }
1190 1072 }