| @@ -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', |
| @@ -182,13 +156,12 @@ | ||
| 182 | 156 | 'tag' => array( |
| 183 | 157 | 'name' => __( 'Tags', 'formidable' ), |
| 184 | 158 | 'icon' => 'frm_icon_font frm_price_tags_icon', |
| 185 | 159 | ), |
| 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 | 160 | 'credit_card' => array( |
| 189 | - 'name' => '', | |
| 190 | - 'icon' => '', | |
| 161 | + 'name' => __( 'Credit Card', 'formidable' ), | |
| 162 | + 'icon' => 'frm_icon_font frm_credit_card_icon frm_show_upgrade', | |
| 163 | + 'addon' => 'stripe', | |
| 191 | 164 | ), |
| 192 | 165 | 'address' => array( |
| 193 | 166 | 'name' => __( 'Address', 'formidable' ), |
| 194 | 167 | 'icon' => 'frm_icon_font frm_location_icon', |
| @@ -202,13 +175,12 @@ | ||
| 202 | 175 | 'name' => __( 'Signature', 'formidable' ), |
| 203 | 176 | 'icon' => 'frm_icon_font frm_signature_icon frm_show_upgrade', |
| 204 | 177 | 'addon' => 'signature', |
| 205 | 178 | ), |
| 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.', | |
| 179 | + 'quiz_score' => array( | |
| 180 | + 'name' => __( 'Quiz Score', 'formidable' ), | |
| 181 | + 'icon' => 'frm_icon_font frm_percent_icon frm_show_upgrade', | |
| 182 | + 'addon' => 'quizzes', | |
| 211 | 183 | ), |
| 212 | 184 | 'ssa-appointment' => array( |
| 213 | 185 | 'name' => __( 'Appointment', 'formidable' ), |
| 214 | 186 | 'icon' => 'frm_icon_font frm_calendar_icon frm_show_upgrade', |
| @@ -213,9 +185,9 @@ | ||
| 213 | 185 | 'name' => __( 'Appointment', 'formidable' ), |
| 214 | 186 | 'icon' => 'frm_icon_font frm_calendar_icon frm_show_upgrade', |
| 215 | 187 | 'require' => 'Simply Schedule Appointments', |
| 216 | 188 | '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" />', | |
| 189 | + <img src="https://s3.amazonaws.com/fp.strategy11.com/images/appointments/appointments.png" alt="Scheduling" />', | |
| 218 | 190 | 'link' => 'https://simplyscheduleappointments.com/meet/formidable/', |
| 219 | 191 | ), |
| 220 | 192 | 'product' => array( |
| 221 | 193 | 'name' => __( 'Product', 'formidable' ), |
| @@ -233,12 +205,8 @@ | ||
| 233 | 205 | 'section' => 'pricing', |
| 234 | 206 | ), |
| 235 | 207 | ); |
| 236 | 208 | |
| 237 | - if ( ! FrmAppHelper::show_new_feature( 'ai' ) ) { | |
| 238 | - unset( $fields['ai'] ); | |
| 239 | - } | |
| 240 | - | |
| 241 | 209 | // Since the signature field may be in a different section, don't show it twice. |
| 242 | 210 | $lite_fields = self::field_selection(); |
| 243 | 211 | if ( isset( $lite_fields['signature'] ) ) { |
| 244 | 212 | unset( $fields['signature'] ); |
| @@ -254,15 +222,8 @@ | ||
| 254 | 222 | $pro_field_selection = self::pro_field_selection(); |
| 255 | 223 | return array_merge( $pro_field_selection, self::field_selection() ); |
| 256 | 224 | } |
| 257 | 225 | |
| 258 | - /** | |
| 259 | - * Create a field. | |
| 260 | - * | |
| 261 | - * @param array $values | |
| 262 | - * @param bool $return | |
| 263 | - * @return int|false | |
| 264 | - */ | |
| 265 | 226 | public static function create( $values, $return = true ) { |
| 266 | 227 | global $wpdb, $frm_duplicate_ids; |
| 267 | 228 | |
| 268 | 229 | $new_values = array(); |
| @@ -268,15 +229,14 @@ | ||
| 268 | 229 | $new_values = array(); |
| 269 | 230 | $key = isset( $values['field_key'] ) ? $values['field_key'] : $values['name']; |
| 270 | 231 | $new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
| 271 | 232 | |
| 272 | - $values = FrmAppHelper::maybe_filter_array( $values, array( 'name', 'description' ) ); | |
| 273 | - | |
| 274 | 233 | foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) { |
| 275 | 234 | $new_values[ $col ] = $values[ $col ]; |
| 276 | 235 | } |
| 277 | 236 | |
| 278 | - $new_values['options'] = self::maybe_filter_options( $values['options'] ); | |
| 237 | + $new_values['options'] = $values['options']; | |
| 238 | + | |
| 279 | 239 | $new_values['field_order'] = isset( $values['field_order'] ) ? (int) $values['field_order'] : null; |
| 280 | 240 | $new_values['required'] = isset( $values['required'] ) ? (int) $values['required'] : 0; |
| 281 | 241 | $new_values['form_id'] = isset( $values['form_id'] ) ? (int) $values['form_id'] : null; |
| 282 | 242 | $new_values['field_options'] = $values['field_options']; |
| @@ -299,39 +259,34 @@ | ||
| 299 | 259 | } |
| 300 | 260 | unset( $k, $v ); |
| 301 | 261 | } |
| 302 | 262 | |
| 263 | + //if(isset($values['id']) and is_numeric($values['id'])) | |
| 264 | + // $new_values['id'] = $values['id']; | |
| 265 | + | |
| 303 | 266 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_fields', $new_values ); |
| 267 | + $new_id = 0; | |
| 268 | + if ( $query_results ) { | |
| 269 | + self::delete_form_transient( $new_values['form_id'] ); | |
| 270 | + $new_id = $wpdb->insert_id; | |
| 271 | + } | |
| 304 | 272 | |
| 305 | - if ( ! $query_results ) { | |
| 273 | + if ( ! $return ) { | |
| 306 | 274 | return false; |
| 307 | 275 | } |
| 308 | 276 | |
| 309 | - self::delete_form_transient( $new_values['form_id'] ); | |
| 310 | - $new_id = $wpdb->insert_id; | |
| 277 | + if ( $query_results ) { | |
| 278 | + if ( isset( $values['id'] ) ) { | |
| 279 | + $frm_duplicate_ids[ $values['id'] ] = $new_id; | |
| 280 | + } | |
| 311 | 281 | |
| 312 | - if ( ! $return ) { | |
| 282 | + return $new_id; | |
| 283 | + } else { | |
| 313 | 284 | return false; |
| 314 | 285 | } |
| 315 | - | |
| 316 | - if ( isset( $values['id'] ) ) { | |
| 317 | - $frm_duplicate_ids[ $values['id'] ] = $new_id; | |
| 318 | - } | |
| 319 | - | |
| 320 | - return $new_id; | |
| 321 | 286 | } |
| 322 | 287 | |
| 323 | 288 | /** |
| 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 | 289 | * Process the field duplication. |
| 335 | 290 | * |
| 336 | 291 | * @since 5.0.05 |
| 337 | 292 | */ |
| @@ -453,11 +408,9 @@ | ||
| 453 | 408 | |
| 454 | 409 | // serialize array values |
| 455 | 410 | foreach ( array( 'field_options', 'options' ) as $opt ) { |
| 456 | 411 | if ( isset( $values[ $opt ] ) && is_array( $values[ $opt ] ) ) { |
| 457 | - if ( 'field_options' === $opt ) { | |
| 458 | - $values[ $opt ] = self::maybe_filter_options( $values[ $opt ] ); | |
| 459 | - } | |
| 412 | + $values[ $opt ] = FrmAppHelper::maybe_filter_array( $values[ $opt ], array( 'custom_html' ) ); | |
| 460 | 413 | $values[ $opt ] = serialize( $values[ $opt ] ); |
| 461 | 414 | } |
| 462 | 415 | } |
| 463 | 416 | if ( isset( $values['default_value'] ) && is_array( $values['default_value'] ) ) { |
| @@ -557,9 +510,9 @@ | ||
| 557 | 510 | |
| 558 | 511 | global $wpdb; |
| 559 | 512 | |
| 560 | 513 | $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 | |
| 514 | + $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id ); // WPCS: unprepared SQL ok. | |
| 562 | 515 | |
| 563 | 516 | $results = FrmDb::check_cache( $id, 'frm_field', $query, 'get_row', 0 ); |
| 564 | 517 | |
| 565 | 518 | if ( empty( $results ) ) { |
| @@ -1105,9 +1058,9 @@ | ||
| 1105 | 1058 | |
| 1106 | 1059 | /** |
| 1107 | 1060 | * @param string $id |
| 1108 | 1061 | * |
| 1109 | - * @return null|string | |
| 1062 | + * @return string | |
| 1110 | 1063 | */ |
| 1111 | 1064 | public static function get_key_by_id( $id ) { |
| 1112 | 1065 | return FrmDb::get_var( 'frm_fields', array( 'id' => $id ), 'field_key' ); |
| 1113 | 1066 | } |