PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0
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 -132 6.55.0 View file →
@@ -62,44 +62,18 @@
62 62 'name' => __( 'User ID', 'formidable' ),
63 63 'icon' => 'frm_icon_font frm_user_icon',
64 64 ),
65 65 'captcha' => array(
66 - 'name' => self::get_captcha_field_name(),
66 + 'name' => __( 'reCAPTCHA', 'formidable' ),
67 67 'icon' => 'frm_icon_font frm_shield_check_icon',
68 68 ),
69 - 'credit_card' => array(
70 - 'name' => __( 'Payment', 'formidable' ),
71 - 'icon' => 'frm_icon_font frm_credit_card_icon',
72 - ),
73 69 );
74 70
75 - /**
76 - * @param array $fields
77 - */
78 71 return apply_filters( 'frm_available_fields', $fields );
79 72 }
80 73
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 74 public static function pro_field_selection() {
100 - $images_url = FrmAppHelper::plugin_url() . '/images/';
101 - $fields = array(
75 + $fields = array(
102 76 'file' => array(
103 77 'name' => __( 'File Upload', 'formidable' ),
104 78 'icon' => 'frm_icon_font frm_upload_icon',
105 79 '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 +92,9 @@
118 92 ),
119 93 'scale' => array(
120 94 'name' => __( 'Scale', 'formidable' ),
121 95 '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" />',
96 + '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 97 ),
124 98 'star' => array(
125 99 'name' => __( 'Star Rating', 'formidable' ),
126 100 'icon' => 'frm_icon_font frm_star_icon',
@@ -140,14 +114,14 @@
140 114 ),
141 115 'lookup' => array(
142 116 'name' => __( 'Lookup', 'formidable' ),
143 117 '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" />',
118 + '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 119 ),
146 120 'divider|repeat' => array(
147 121 'name' => __( 'Repeater', 'formidable' ),
148 122 '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" />',
123 + '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 124 ),
151 125 'end_divider' => array(
152 126 'name' => __( 'Section Buttons', 'formidable' ),
153 127 'switch_from' => 'divider',
@@ -164,18 +138,8 @@
164 138 'form' => array(
165 139 'name' => __( 'Embed Form', 'formidable' ),
166 140 'icon' => 'frm_icon_font frm_file_text_icon',
167 141 ),
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 142 'password' => array(
179 143 'name' => __( 'Password', 'formidable' ),
180 144 'icon' => 'frm_icon_font frm_lock_open_icon',
181 145 ),
@@ -182,13 +146,12 @@
182 146 'tag' => array(
183 147 'name' => __( 'Tags', 'formidable' ),
184 148 'icon' => 'frm_icon_font frm_price_tags_icon',
185 149 ),
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 150 'credit_card' => array(
189 - 'name' => '',
190 - 'icon' => '',
151 + 'name' => __( 'Credit Card', 'formidable' ),
152 + 'icon' => 'frm_icon_font frm_credit_card_icon frm_show_upgrade',
153 + 'addon' => 'stripe',
191 154 ),
192 155 'address' => array(
193 156 'name' => __( 'Address', 'formidable' ),
194 157 'icon' => 'frm_icon_font frm_location_icon',
@@ -202,13 +165,12 @@
202 165 'name' => __( 'Signature', 'formidable' ),
203 166 'icon' => 'frm_icon_font frm_signature_icon frm_show_upgrade',
204 167 'addon' => 'signature',
205 168 ),
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.',
169 + 'quiz_score' => array(
170 + 'name' => __( 'Quiz Score', 'formidable' ),
171 + 'icon' => 'frm_icon_font frm_percent_icon frm_show_upgrade',
172 + 'addon' => 'quizzes',
211 173 ),
212 174 'ssa-appointment' => array(
213 175 'name' => __( 'Appointment', 'formidable' ),
214 176 'icon' => 'frm_icon_font frm_calendar_icon frm_show_upgrade',
@@ -213,9 +175,9 @@
213 175 'name' => __( 'Appointment', 'formidable' ),
214 176 'icon' => 'frm_icon_font frm_calendar_icon frm_show_upgrade',
215 177 'require' => 'Simply Schedule Appointments',
216 178 '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" />',
179 + <img src="https://s3.amazonaws.com/fp.strategy11.com/images/appointments/appointments.png" alt="Scheduling" />',
218 180 'link' => 'https://simplyscheduleappointments.com/meet/formidable/',
219 181 ),
220 182 'product' => array(
221 183 'name' => __( 'Product', 'formidable' ),
@@ -233,12 +195,8 @@
233 195 'section' => 'pricing',
234 196 ),
235 197 );
236 198
237 - if ( ! FrmAppHelper::show_new_feature( 'ai' ) ) {
238 - unset( $fields['ai'] );
239 - }
240 -
241 199 // Since the signature field may be in a different section, don't show it twice.
242 200 $lite_fields = self::field_selection();
243 201 if ( isset( $lite_fields['signature'] ) ) {
244 202 unset( $fields['signature'] );
@@ -254,15 +212,8 @@
254 212 $pro_field_selection = self::pro_field_selection();
255 213 return array_merge( $pro_field_selection, self::field_selection() );
256 214 }
257 215
258 - /**
259 - * Create a field.
260 - *
261 - * @param array $values
262 - * @param bool $return
263 - * @return int|false
264 - */
265 216 public static function create( $values, $return = true ) {
266 217 global $wpdb, $frm_duplicate_ids;
267 218
268 219 $new_values = array();
@@ -268,15 +219,14 @@
268 219 $new_values = array();
269 220 $key = isset( $values['field_key'] ) ? $values['field_key'] : $values['name'];
270 221 $new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' );
271 222
272 - $values = FrmAppHelper::maybe_filter_array( $values, array( 'name', 'description' ) );
273 -
274 223 foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) {
275 224 $new_values[ $col ] = $values[ $col ];
276 225 }
277 226
278 - $new_values['options'] = self::maybe_filter_options( $values['options'] );
227 + $new_values['options'] = $values['options'];
228 +
279 229 $new_values['field_order'] = isset( $values['field_order'] ) ? (int) $values['field_order'] : null;
280 230 $new_values['required'] = isset( $values['required'] ) ? (int) $values['required'] : 0;
281 231 $new_values['form_id'] = isset( $values['form_id'] ) ? (int) $values['form_id'] : null;
282 232 $new_values['field_options'] = $values['field_options'];
@@ -299,77 +249,31 @@
299 249 }
300 250 unset( $k, $v );
301 251 }
302 252
253 + //if(isset($values['id']) and is_numeric($values['id']))
254 + // $new_values['id'] = $values['id'];
255 +
303 256 $query_results = $wpdb->insert( $wpdb->prefix . 'frm_fields', $new_values );
304 -
305 - if ( ! $query_results ) {
306 - return false;
257 + $new_id = 0;
258 + if ( $query_results ) {
259 + self::delete_form_transient( $new_values['form_id'] );
260 + $new_id = $wpdb->insert_id;
307 261 }
308 262
309 - self::delete_form_transient( $new_values['form_id'] );
310 - $new_id = $wpdb->insert_id;
311 -
312 263 if ( ! $return ) {
313 264 return false;
314 265 }
315 266
316 - if ( isset( $values['id'] ) ) {
317 - $frm_duplicate_ids[ $values['id'] ] = $new_id;
318 - }
267 + if ( $query_results ) {
268 + if ( isset( $values['id'] ) ) {
269 + $frm_duplicate_ids[ $values['id'] ] = $new_id;
270 + }
319 271
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 ) {
272 + return $new_id;
273 + } else {
341 274 return false;
342 275 }
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 276 }
373 277
374 278 public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) {
375 279 global $frm_duplicate_ids;
@@ -428,10 +332,9 @@
428 332
429 333 public static function update( $id, $values ) {
430 334 global $wpdb;
431 335
432 - $id = absint( $id );
433 - $values = FrmAppHelper::maybe_filter_array( $values, array( 'name', 'description' ) );
336 + $id = absint( $id );
434 337
435 338 if ( isset( $values['field_key'] ) ) {
436 339 $values['field_key'] = FrmAppHelper::get_unique_key( $values['field_key'], $wpdb->prefix . 'frm_fields', 'field_key', $id );
437 340 }
@@ -444,9 +347,9 @@
444 347
445 348 if ( isset( $values['type'] ) ) {
446 349 $values = apply_filters( 'frm_clean_' . $values['type'] . '_field_options_before_update', $values );
447 350
448 - if ( $values['type'] === 'hidden' && isset( $values['field_options'] ) && isset( $values['field_options']['clear_on_focus'] ) ) {
351 + if ( $values['type'] == 'hidden' && isset( $values['field_options'] ) && isset( $values['field_options']['clear_on_focus'] ) ) {
449 352 // don't keep the old placeholder setting for hidden fields
450 353 $values['field_options']['clear_on_focus'] = 0;
451 354 }
452 355 }
@@ -453,11 +356,8 @@
453 356
454 357 // serialize array values
455 358 foreach ( array( 'field_options', 'options' ) as $opt ) {
456 359 if ( isset( $values[ $opt ] ) && is_array( $values[ $opt ] ) ) {
457 - if ( 'field_options' === $opt ) {
458 - $values[ $opt ] = self::maybe_filter_options( $values[ $opt ] );
459 - }
460 360 $values[ $opt ] = serialize( $values[ $opt ] );
461 361 }
462 362 }
463 363 if ( isset( $values['default_value'] ) && is_array( $values['default_value'] ) ) {
@@ -557,9 +457,9 @@
557 457
558 458 global $wpdb;
559 459
560 460 $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
461 + $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id ); // WPCS: unprepared SQL ok.
562 462
563 463 $results = FrmDb::check_cache( $id, 'frm_field', $query, 'get_row', 0 );
564 464
565 465 if ( empty( $results ) ) {
@@ -1105,9 +1005,9 @@
1105 1005
1106 1006 /**
1107 1007 * @param string $id
1108 1008 *
1109 - * @return null|string
1009 + * @return string
1110 1010 */
1111 1011 public static function get_key_by_id( $id ) {
1112 1012 return FrmDb::get_var( 'frm_fields', array( 'id' => $id ), 'field_key' );
1113 1013 }