| @@ -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', |
| @@ -71,9 +62,9 @@ | ||
| 71 | 62 | 'name' => __( 'User ID', 'formidable' ), |
| 72 | 63 | 'icon' => 'frm_icon_font frm_user_icon', |
| 73 | 64 | ), |
| 74 | 65 | 'captcha' => array( |
| 75 | - 'name' => $captcha_name, | |
| 66 | + 'name' => __( 'reCAPTCHA', 'formidable' ), | |
| 76 | 67 | 'icon' => 'frm_icon_font frm_shield_check_icon', |
| 77 | 68 | ), |
| 78 | 69 | ); |
| 79 | 70 | |
| @@ -80,10 +71,9 @@ | ||
| 80 | 71 | return apply_filters( 'frm_available_fields', $fields ); |
| 81 | 72 | } |
| 82 | 73 | |
| 83 | 74 | public static function pro_field_selection() { |
| 84 | - $images_url = FrmAppHelper::plugin_url() . '/images/'; | |
| 85 | - $fields = array( | |
| 75 | + $fields = array( | |
| 86 | 76 | 'file' => array( |
| 87 | 77 | 'name' => __( 'File Upload', 'formidable' ), |
| 88 | 78 | 'icon' => 'frm_icon_font frm_upload_icon', |
| 89 | 79 | '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 +92,9 @@ | ||
| 102 | 92 | ), |
| 103 | 93 | 'scale' => array( |
| 104 | 94 | 'name' => __( 'Scale', 'formidable' ), |
| 105 | 95 | '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" />', | |
| 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" />', | |
| 107 | 97 | ), |
| 108 | 98 | 'star' => array( |
| 109 | 99 | 'name' => __( 'Star Rating', 'formidable' ), |
| 110 | 100 | 'icon' => 'frm_icon_font frm_star_icon', |
| @@ -124,14 +114,14 @@ | ||
| 124 | 114 | ), |
| 125 | 115 | 'lookup' => array( |
| 126 | 116 | 'name' => __( 'Lookup', 'formidable' ), |
| 127 | 117 | '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" />', | |
| 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" />', | |
| 129 | 119 | ), |
| 130 | 120 | 'divider|repeat' => array( |
| 131 | 121 | 'name' => __( 'Repeater', 'formidable' ), |
| 132 | 122 | '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" />', | |
| 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" />', | |
| 134 | 124 | ), |
| 135 | 125 | 'end_divider' => array( |
| 136 | 126 | 'name' => __( 'Section Buttons', 'formidable' ), |
| 137 | 127 | 'switch_from' => 'divider', |
| @@ -148,18 +138,8 @@ | ||
| 148 | 138 | 'form' => array( |
| 149 | 139 | 'name' => __( 'Embed Form', 'formidable' ), |
| 150 | 140 | 'icon' => 'frm_icon_font frm_file_text_icon', |
| 151 | 141 | ), |
| 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 | 142 | 'password' => array( |
| 163 | 143 | 'name' => __( 'Password', 'formidable' ), |
| 164 | 144 | 'icon' => 'frm_icon_font frm_lock_open_icon', |
| 165 | 145 | ), |
| @@ -185,13 +165,12 @@ | ||
| 185 | 165 | 'name' => __( 'Signature', 'formidable' ), |
| 186 | 166 | 'icon' => 'frm_icon_font frm_signature_icon frm_show_upgrade', |
| 187 | 167 | 'addon' => 'signature', |
| 188 | 168 | ), |
| 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.', | |
| 169 | + 'quiz_score' => array( | |
| 170 | + 'name' => __( 'Quiz Score', 'formidable' ), | |
| 171 | + 'icon' => 'frm_icon_font frm_percent_icon frm_show_upgrade', | |
| 172 | + 'addon' => 'quizzes', | |
| 194 | 173 | ), |
| 195 | 174 | 'ssa-appointment' => array( |
| 196 | 175 | 'name' => __( 'Appointment', 'formidable' ), |
| 197 | 176 | 'icon' => 'frm_icon_font frm_calendar_icon frm_show_upgrade', |
| @@ -196,9 +175,9 @@ | ||
| 196 | 175 | 'name' => __( 'Appointment', 'formidable' ), |
| 197 | 176 | 'icon' => 'frm_icon_font frm_calendar_icon frm_show_upgrade', |
| 198 | 177 | 'require' => 'Simply Schedule Appointments', |
| 199 | 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. |
| 200 | - <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" />', | |
| 201 | 180 | 'link' => 'https://simplyscheduleappointments.com/meet/formidable/', |
| 202 | 181 | ), |
| 203 | 182 | 'product' => array( |
| 204 | 183 | 'name' => __( 'Product', 'formidable' ), |
| @@ -216,12 +195,8 @@ | ||
| 216 | 195 | 'section' => 'pricing', |
| 217 | 196 | ), |
| 218 | 197 | ); |
| 219 | 198 | |
| 220 | - if ( ! FrmAppHelper::show_new_feature( 'ai' ) ) { | |
| 221 | - unset( $fields['ai'] ); | |
| 222 | - } | |
| 223 | - | |
| 224 | 199 | // Since the signature field may be in a different section, don't show it twice. |
| 225 | 200 | $lite_fields = self::field_selection(); |
| 226 | 201 | if ( isset( $lite_fields['signature'] ) ) { |
| 227 | 202 | unset( $fields['signature'] ); |
| @@ -244,15 +219,14 @@ | ||
| 244 | 219 | $new_values = array(); |
| 245 | 220 | $key = isset( $values['field_key'] ) ? $values['field_key'] : $values['name']; |
| 246 | 221 | $new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
| 247 | 222 | |
| 248 | - $values = FrmAppHelper::maybe_filter_array( $values, array( 'name', 'description' ) ); | |
| 249 | - | |
| 250 | 223 | foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) { |
| 251 | 224 | $new_values[ $col ] = $values[ $col ]; |
| 252 | 225 | } |
| 253 | 226 | |
| 254 | - $new_values['options'] = self::maybe_filter_options( $values['options'] ); | |
| 227 | + $new_values['options'] = $values['options']; | |
| 228 | + | |
| 255 | 229 | $new_values['field_order'] = isset( $values['field_order'] ) ? (int) $values['field_order'] : null; |
| 256 | 230 | $new_values['required'] = isset( $values['required'] ) ? (int) $values['required'] : 0; |
| 257 | 231 | $new_values['form_id'] = isset( $values['form_id'] ) ? (int) $values['form_id'] : null; |
| 258 | 232 | $new_values['field_options'] = $values['field_options']; |
| @@ -275,8 +249,11 @@ | ||
| 275 | 249 | } |
| 276 | 250 | unset( $k, $v ); |
| 277 | 251 | } |
| 278 | 252 | |
| 253 | + //if(isset($values['id']) and is_numeric($values['id'])) | |
| 254 | + // $new_values['id'] = $values['id']; | |
| 255 | + | |
| 279 | 256 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_fields', $new_values ); |
| 280 | 257 | $new_id = 0; |
| 281 | 258 | if ( $query_results ) { |
| 282 | 259 | self::delete_form_transient( $new_values['form_id'] ); |
| @@ -297,59 +274,8 @@ | ||
| 297 | 274 | return false; |
| 298 | 275 | } |
| 299 | 276 | } |
| 300 | 277 | |
| 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 | 278 | public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) { |
| 353 | 279 | global $frm_duplicate_ids; |
| 354 | 280 | |
| 355 | 281 | $where = array( |
| @@ -406,10 +332,9 @@ | ||
| 406 | 332 | |
| 407 | 333 | public static function update( $id, $values ) { |
| 408 | 334 | global $wpdb; |
| 409 | 335 | |
| 410 | - $id = absint( $id ); | |
| 411 | - $values = FrmAppHelper::maybe_filter_array( $values, array( 'name', 'description' ) ); | |
| 336 | + $id = absint( $id ); | |
| 412 | 337 | |
| 413 | 338 | if ( isset( $values['field_key'] ) ) { |
| 414 | 339 | $values['field_key'] = FrmAppHelper::get_unique_key( $values['field_key'], $wpdb->prefix . 'frm_fields', 'field_key', $id ); |
| 415 | 340 | } |
| @@ -422,9 +347,9 @@ | ||
| 422 | 347 | |
| 423 | 348 | if ( isset( $values['type'] ) ) { |
| 424 | 349 | $values = apply_filters( 'frm_clean_' . $values['type'] . '_field_options_before_update', $values ); |
| 425 | 350 | |
| 426 | - 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'] ) ) { | |
| 427 | 352 | // don't keep the old placeholder setting for hidden fields |
| 428 | 353 | $values['field_options']['clear_on_focus'] = 0; |
| 429 | 354 | } |
| 430 | 355 | } |
| @@ -431,11 +356,8 @@ | ||
| 431 | 356 | |
| 432 | 357 | // serialize array values |
| 433 | 358 | foreach ( array( 'field_options', 'options' ) as $opt ) { |
| 434 | 359 | if ( isset( $values[ $opt ] ) && is_array( $values[ $opt ] ) ) { |
| 435 | - if ( 'field_options' === $opt ) { | |
| 436 | - $values[ $opt ] = self::maybe_filter_options( $values[ $opt ] ); | |
| 437 | - } | |
| 438 | 360 | $values[ $opt ] = serialize( $values[ $opt ] ); |
| 439 | 361 | } |
| 440 | 362 | } |
| 441 | 363 | if ( isset( $values['default_value'] ) && is_array( $values['default_value'] ) ) { |
| @@ -535,9 +457,9 @@ | ||
| 535 | 457 | |
| 536 | 458 | global $wpdb; |
| 537 | 459 | |
| 538 | 460 | $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 | |
| 461 | + $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id ); // WPCS: unprepared SQL ok. | |
| 540 | 462 | |
| 541 | 463 | $results = FrmDb::check_cache( $id, 'frm_field', $query, 'get_row', 0 ); |
| 542 | 464 | |
| 543 | 465 | if ( empty( $results ) ) { |
| @@ -1083,9 +1005,9 @@ | ||
| 1083 | 1005 | |
| 1084 | 1006 | /** |
| 1085 | 1007 | * @param string $id |
| 1086 | 1008 | * |
| 1087 | - * @return null|string | |
| 1009 | + * @return string | |
| 1088 | 1010 | */ |
| 1089 | 1011 | public static function get_key_by_id( $id ) { |
| 1090 | 1012 | return FrmDb::get_var( 'frm_fields', array( 'id' => $id ), 'field_key' ); |
| 1091 | 1013 | } |