| @@ -8,17 +8,8 @@ | ||
| 8 | 8 | public static $use_cache = true; |
| 9 | 9 | public static $transient_size = 200; |
| 10 | 10 | |
| 11 | 11 | public static function field_selection() { |
| 12 | - $frm_settings = FrmAppHelper::get_settings(); | |
| 13 | - $active_captcha = $frm_settings->active_captcha; | |
| 14 | - if ( ! FrmFieldCaptcha::should_show_captcha() ) { | |
| 15 | - $captcha_name = 'Captcha'; | |
| 16 | - } elseif ( $active_captcha === 'recaptcha' ) { | |
| 17 | - $captcha_name = 'reCAPTCHA'; | |
| 18 | - } else { | |
| 19 | - $captcha_name = 'hCaptcha'; | |
| 20 | - } | |
| 21 | 12 | $fields = array( |
| 22 | 13 | 'text' => array( |
| 23 | 14 | 'name' => __( 'Text', 'formidable' ), |
| 24 | 15 | 'icon' => 'frm_icon_font frm_text2_icon', |
| @@ -50,12 +41,8 @@ | ||
| 50 | 41 | 'number' => array( |
| 51 | 42 | 'name' => __( 'Number', 'formidable' ), |
| 52 | 43 | 'icon' => 'frm_icon_font frm_hashtag_icon', |
| 53 | 44 | ), |
| 54 | - 'name' => array( | |
| 55 | - 'name' => __( 'Name', 'formidable' ), | |
| 56 | - 'icon' => 'frm_icon_font frm_user_name_icon', | |
| 57 | - ), | |
| 58 | 45 | 'phone' => array( |
| 59 | 46 | 'name' => __( 'Phone', 'formidable' ), |
| 60 | 47 | 'icon' => 'frm_icon_font frm_phone_icon', |
| 61 | 48 | ), |
| @@ -71,9 +58,9 @@ | ||
| 71 | 58 | 'name' => __( 'User ID', 'formidable' ), |
| 72 | 59 | 'icon' => 'frm_icon_font frm_user_icon', |
| 73 | 60 | ), |
| 74 | 61 | 'captcha' => array( |
| 75 | - 'name' => $captcha_name, | |
| 62 | + 'name' => __( 'reCAPTCHA', 'formidable' ), | |
| 76 | 63 | 'icon' => 'frm_icon_font frm_shield_check_icon', |
| 77 | 64 | ), |
| 78 | 65 | ); |
| 79 | 66 | |
| @@ -80,10 +67,9 @@ | ||
| 80 | 67 | return apply_filters( 'frm_available_fields', $fields ); |
| 81 | 68 | } |
| 82 | 69 | |
| 83 | 70 | public static function pro_field_selection() { |
| 84 | - $images_url = FrmAppHelper::plugin_url() . '/images/'; | |
| 85 | - $fields = array( | |
| 71 | + $fields = array( | |
| 86 | 72 | 'file' => array( |
| 87 | 73 | 'name' => __( 'File Upload', 'formidable' ), |
| 88 | 74 | 'icon' => 'frm_icon_font frm_upload_icon', |
| 89 | 75 | 'message' => 'Add file uploads to save time and cut down on back-and-forth. Upgrade to Pro to get Upload fields and more.', |
| @@ -102,9 +88,9 @@ | ||
| 102 | 88 | ), |
| 103 | 89 | 'scale' => array( |
| 104 | 90 | 'name' => __( 'Scale', 'formidable' ), |
| 105 | 91 | 'icon' => 'frm_icon_font frm_linear_scale_icon', |
| 106 | - '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" />', | |
| 107 | 93 | ), |
| 108 | 94 | 'star' => array( |
| 109 | 95 | 'name' => __( 'Star Rating', 'formidable' ), |
| 110 | 96 | 'icon' => 'frm_icon_font frm_star_icon', |
| @@ -124,14 +110,14 @@ | ||
| 124 | 110 | ), |
| 125 | 111 | 'lookup' => array( |
| 126 | 112 | 'name' => __( 'Lookup', 'formidable' ), |
| 127 | 113 | 'icon' => 'frm_icon_font frm_search_icon', |
| 128 | - '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" />', | |
| 129 | 115 | ), |
| 130 | 116 | 'divider|repeat' => array( |
| 131 | 117 | 'name' => __( 'Repeater', 'formidable' ), |
| 132 | 118 | 'icon' => 'frm_icon_font frm_repeater_icon', |
| 133 | - '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" />', | |
| 134 | 120 | ), |
| 135 | 121 | 'end_divider' => array( |
| 136 | 122 | 'name' => __( 'Section Buttons', 'formidable' ), |
| 137 | 123 | 'switch_from' => 'divider', |
| @@ -148,18 +134,8 @@ | ||
| 148 | 134 | 'form' => array( |
| 149 | 135 | 'name' => __( 'Embed Form', 'formidable' ), |
| 150 | 136 | 'icon' => 'frm_icon_font frm_file_text_icon', |
| 151 | 137 | ), |
| 152 | - 'likert' => array( | |
| 153 | - 'name' => __( 'Likert Scale', 'formidable' ), | |
| 154 | - 'icon' => 'frm_icon_font frm_likert_scale frm_show_upgrade', | |
| 155 | - 'addon' => 'surveys', | |
| 156 | - ), | |
| 157 | - 'nps' => array( | |
| 158 | - 'name' => __( 'NPS', 'formidable' ), | |
| 159 | - 'icon' => 'frm_icon_font frm_nps frm_show_upgrade', | |
| 160 | - 'addon' => 'surveys', | |
| 161 | - ), | |
| 162 | 138 | 'password' => array( |
| 163 | 139 | 'name' => __( 'Password', 'formidable' ), |
| 164 | 140 | 'icon' => 'frm_icon_font frm_lock_open_icon', |
| 165 | 141 | ), |
| @@ -185,13 +161,12 @@ | ||
| 185 | 161 | 'name' => __( 'Signature', 'formidable' ), |
| 186 | 162 | 'icon' => 'frm_icon_font frm_signature_icon frm_show_upgrade', |
| 187 | 163 | 'addon' => 'signature', |
| 188 | 164 | ), |
| 189 | - 'ai' => array( | |
| 190 | - 'name' => __( 'AI', 'formidable' ), | |
| 191 | - 'icon' => 'frm_icon_font frm_eye_icon frm_show_upgrade', | |
| 192 | - 'addon' => 'ai', | |
| 193 | - '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', | |
| 194 | 169 | ), |
| 195 | 170 | 'ssa-appointment' => array( |
| 196 | 171 | 'name' => __( 'Appointment', 'formidable' ), |
| 197 | 172 | 'icon' => 'frm_icon_font frm_calendar_icon frm_show_upgrade', |
| @@ -196,9 +171,9 @@ | ||
| 196 | 171 | 'name' => __( 'Appointment', 'formidable' ), |
| 197 | 172 | 'icon' => 'frm_icon_font frm_calendar_icon frm_show_upgrade', |
| 198 | 173 | 'require' => 'Simply Schedule Appointments', |
| 199 | 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. |
| 200 | - <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" />', | |
| 201 | 176 | 'link' => 'https://simplyscheduleappointments.com/meet/formidable/', |
| 202 | 177 | ), |
| 203 | 178 | 'product' => array( |
| 204 | 179 | 'name' => __( 'Product', 'formidable' ), |
| @@ -216,12 +191,8 @@ | ||
| 216 | 191 | 'section' => 'pricing', |
| 217 | 192 | ), |
| 218 | 193 | ); |
| 219 | 194 | |
| 220 | - if ( ! FrmAppHelper::show_new_feature( 'ai' ) ) { | |
| 221 | - unset( $fields['ai'] ); | |
| 222 | - } | |
| 223 | - | |
| 224 | 195 | // Since the signature field may be in a different section, don't show it twice. |
| 225 | 196 | $lite_fields = self::field_selection(); |
| 226 | 197 | if ( isset( $lite_fields['signature'] ) ) { |
| 227 | 198 | unset( $fields['signature'] ); |
| @@ -244,15 +215,14 @@ | ||
| 244 | 215 | $new_values = array(); |
| 245 | 216 | $key = isset( $values['field_key'] ) ? $values['field_key'] : $values['name']; |
| 246 | 217 | $new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
| 247 | 218 | |
| 248 | - $values = FrmAppHelper::maybe_filter_array( $values, array( 'name', 'description' ) ); | |
| 249 | - | |
| 250 | 219 | foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) { |
| 251 | 220 | $new_values[ $col ] = $values[ $col ]; |
| 252 | 221 | } |
| 253 | 222 | |
| 254 | - $new_values['options'] = self::maybe_filter_options( $values['options'] ); | |
| 223 | + $new_values['options'] = $values['options']; | |
| 224 | + | |
| 255 | 225 | $new_values['field_order'] = isset( $values['field_order'] ) ? (int) $values['field_order'] : null; |
| 256 | 226 | $new_values['required'] = isset( $values['required'] ) ? (int) $values['required'] : 0; |
| 257 | 227 | $new_values['form_id'] = isset( $values['form_id'] ) ? (int) $values['form_id'] : null; |
| 258 | 228 | $new_values['field_options'] = $values['field_options']; |
| @@ -275,8 +245,11 @@ | ||
| 275 | 245 | } |
| 276 | 246 | unset( $k, $v ); |
| 277 | 247 | } |
| 278 | 248 | |
| 249 | + //if(isset($values['id']) and is_numeric($values['id'])) | |
| 250 | + // $new_values['id'] = $values['id']; | |
| 251 | + | |
| 279 | 252 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_fields', $new_values ); |
| 280 | 253 | $new_id = 0; |
| 281 | 254 | if ( $query_results ) { |
| 282 | 255 | self::delete_form_transient( $new_values['form_id'] ); |
| @@ -297,59 +270,8 @@ | ||
| 297 | 270 | return false; |
| 298 | 271 | } |
| 299 | 272 | } |
| 300 | 273 | |
| 301 | - /** | |
| 302 | - * @since 5.0.08 | |
| 303 | - * | |
| 304 | - * @param array $options | |
| 305 | - * @return array | |
| 306 | - */ | |
| 307 | - private static function maybe_filter_options( $options ) { | |
| 308 | - return FrmAppHelper::maybe_filter_array( $options, array( 'custom_html' ) ); | |
| 309 | - } | |
| 310 | - | |
| 311 | - /** | |
| 312 | - * Process the field duplication. | |
| 313 | - * | |
| 314 | - * @since 5.0.05 | |
| 315 | - */ | |
| 316 | - public static function duplicate_single_field( $field_id, $form_id ) { | |
| 317 | - $copy_field = self::getOne( $field_id ); | |
| 318 | - if ( ! $copy_field ) { | |
| 319 | - return false; | |
| 320 | - } | |
| 321 | - | |
| 322 | - do_action( 'frm_duplicate_field', $copy_field, $form_id ); | |
| 323 | - do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id ); | |
| 324 | - | |
| 325 | - $values = array( | |
| 326 | - 'id' => $copy_field->id, | |
| 327 | - ); | |
| 328 | - FrmFieldsHelper::fill_field( $values, $copy_field, $copy_field->form_id ); | |
| 329 | - $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values ); | |
| 330 | - | |
| 331 | - $field_id = self::create( $values ); | |
| 332 | - | |
| 333 | - /** | |
| 334 | - * Fires after duplicating a field. | |
| 335 | - * | |
| 336 | - * @since 5.0.04 | |
| 337 | - * | |
| 338 | - * @param array $args { | |
| 339 | - * The arguments. | |
| 340 | - * | |
| 341 | - * @type int $field_id New field ID. | |
| 342 | - * @type array $values Values before inserting. | |
| 343 | - * @type object $copy_field Copy field data. | |
| 344 | - * @type int $form_id Form ID. | |
| 345 | - * } | |
| 346 | - */ | |
| 347 | - do_action( 'frm_after_duplicate_field', compact( 'field_id', 'values', 'copy_field', 'form_id' ) ); | |
| 348 | - | |
| 349 | - return compact( 'field_id', 'values' ); | |
| 350 | - } | |
| 351 | - | |
| 352 | 274 | public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) { |
| 353 | 275 | global $frm_duplicate_ids; |
| 354 | 276 | |
| 355 | 277 | $where = array( |
| @@ -406,10 +328,9 @@ | ||
| 406 | 328 | |
| 407 | 329 | public static function update( $id, $values ) { |
| 408 | 330 | global $wpdb; |
| 409 | 331 | |
| 410 | - $id = absint( $id ); | |
| 411 | - $values = FrmAppHelper::maybe_filter_array( $values, array( 'name', 'description' ) ); | |
| 332 | + $id = absint( $id ); | |
| 412 | 333 | |
| 413 | 334 | if ( isset( $values['field_key'] ) ) { |
| 414 | 335 | $values['field_key'] = FrmAppHelper::get_unique_key( $values['field_key'], $wpdb->prefix . 'frm_fields', 'field_key', $id ); |
| 415 | 336 | } |
| @@ -422,9 +343,9 @@ | ||
| 422 | 343 | |
| 423 | 344 | if ( isset( $values['type'] ) ) { |
| 424 | 345 | $values = apply_filters( 'frm_clean_' . $values['type'] . '_field_options_before_update', $values ); |
| 425 | 346 | |
| 426 | - 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'] ) ) { | |
| 427 | 348 | // don't keep the old placeholder setting for hidden fields |
| 428 | 349 | $values['field_options']['clear_on_focus'] = 0; |
| 429 | 350 | } |
| 430 | 351 | } |
| @@ -431,11 +352,8 @@ | ||
| 431 | 352 | |
| 432 | 353 | // serialize array values |
| 433 | 354 | foreach ( array( 'field_options', 'options' ) as $opt ) { |
| 434 | 355 | if ( isset( $values[ $opt ] ) && is_array( $values[ $opt ] ) ) { |
| 435 | - if ( 'field_options' === $opt ) { | |
| 436 | - $values[ $opt ] = self::maybe_filter_options( $values[ $opt ] ); | |
| 437 | - } | |
| 438 | 356 | $values[ $opt ] = serialize( $values[ $opt ] ); |
| 439 | 357 | } |
| 440 | 358 | } |
| 441 | 359 | if ( isset( $values['default_value'] ) && is_array( $values['default_value'] ) ) { |
| @@ -535,9 +453,9 @@ | ||
| 535 | 453 | |
| 536 | 454 | global $wpdb; |
| 537 | 455 | |
| 538 | 456 | $where = is_numeric( $id ) ? 'id=%d' : 'field_key=%s'; |
| 539 | - $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. | |
| 540 | 458 | |
| 541 | 459 | $results = FrmDb::check_cache( $id, 'frm_field', $query, 'get_row', 0 ); |
| 542 | 460 | |
| 543 | 461 | if ( empty( $results ) ) { |
| @@ -1083,9 +1001,9 @@ | ||
| 1083 | 1001 | |
| 1084 | 1002 | /** |
| 1085 | 1003 | * @param string $id |
| 1086 | 1004 | * |
| 1087 | - * @return null|string | |
| 1005 | + * @return string | |
| 1088 | 1006 | */ |
| 1089 | 1007 | public static function get_key_by_id( $id ) { |
| 1090 | 1008 | return FrmDb::get_var( 'frm_fields', array( 'id' => $id ), 'field_key' ); |
| 1091 | 1009 | } |
| @@ -1149,20 +1067,6 @@ | ||
| 1149 | 1067 | * |
| 1150 | 1068 | * @since 4.04 |
| 1151 | 1069 | */ |
| 1152 | 1070 | return apply_filters( 'frm_is_field_type', $is_field_type, compact( 'field', 'is_type' ) ); |
| 1153 | - } | |
| 1154 | - | |
| 1155 | - /** | |
| 1156 | - * Checks if the given field array is a combo field. | |
| 1157 | - * | |
| 1158 | - * @since 4.10.02 | |
| 1159 | - * | |
| 1160 | - * @param array $field Field array. | |
| 1161 | - * @return bool | |
| 1162 | - */ | |
| 1163 | - public static function is_combo_field( $field ) { | |
| 1164 | - $field_type_obj = FrmFieldFactory::get_field_factory( $field ); | |
| 1165 | - | |
| 1166 | - return ! empty( $field_type_obj->is_combo_field ); | |
| 1167 | 1071 | } |
| 1168 | 1072 | } |