| @@ -62,41 +62,16 @@ | ||
| 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 | 75 | $images_url = FrmAppHelper::plugin_url() . '/images/'; |
| 101 | 76 | $fields = array( |
| 102 | 77 | 'file' => array( |
| @@ -182,13 +157,12 @@ | ||
| 182 | 157 | 'tag' => array( |
| 183 | 158 | 'name' => __( 'Tags', 'formidable' ), |
| 184 | 159 | 'icon' => 'frm_icon_font frm_price_tags_icon', |
| 185 | 160 | ), |
| 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 | 161 | 'credit_card' => array( |
| 189 | - 'name' => '', | |
| 190 | - 'icon' => '', | |
| 162 | + 'name' => __( 'Credit Card', 'formidable' ), | |
| 163 | + 'icon' => 'frm_icon_font frm_credit_card_icon frm_show_upgrade', | |
| 164 | + 'addon' => 'stripe', | |
| 191 | 165 | ), |
| 192 | 166 | 'address' => array( |
| 193 | 167 | 'name' => __( 'Address', 'formidable' ), |
| 194 | 168 | 'icon' => 'frm_icon_font frm_location_icon', |
| @@ -202,13 +176,12 @@ | ||
| 202 | 176 | 'name' => __( 'Signature', 'formidable' ), |
| 203 | 177 | 'icon' => 'frm_icon_font frm_signature_icon frm_show_upgrade', |
| 204 | 178 | 'addon' => 'signature', |
| 205 | 179 | ), |
| 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.', | |
| 180 | + 'quiz_score' => array( | |
| 181 | + 'name' => __( 'Quiz Score', 'formidable' ), | |
| 182 | + 'icon' => 'frm_icon_font frm_percent_icon frm_show_upgrade', | |
| 183 | + 'addon' => 'quizzes', | |
| 211 | 184 | ), |
| 212 | 185 | 'ssa-appointment' => array( |
| 213 | 186 | 'name' => __( 'Appointment', 'formidable' ), |
| 214 | 187 | 'icon' => 'frm_icon_font frm_calendar_icon frm_show_upgrade', |
| @@ -233,12 +206,8 @@ | ||
| 233 | 206 | 'section' => 'pricing', |
| 234 | 207 | ), |
| 235 | 208 | ); |
| 236 | 209 | |
| 237 | - if ( ! FrmAppHelper::show_new_feature( 'ai' ) ) { | |
| 238 | - unset( $fields['ai'] ); | |
| 239 | - } | |
| 240 | - | |
| 241 | 210 | // Since the signature field may be in a different section, don't show it twice. |
| 242 | 211 | $lite_fields = self::field_selection(); |
| 243 | 212 | if ( isset( $lite_fields['signature'] ) ) { |
| 244 | 213 | unset( $fields['signature'] ); |
| @@ -254,15 +223,8 @@ | ||
| 254 | 223 | $pro_field_selection = self::pro_field_selection(); |
| 255 | 224 | return array_merge( $pro_field_selection, self::field_selection() ); |
| 256 | 225 | } |
| 257 | 226 | |
| 258 | - /** | |
| 259 | - * Create a field. | |
| 260 | - * | |
| 261 | - * @param array $values | |
| 262 | - * @param bool $return | |
| 263 | - * @return int|false | |
| 264 | - */ | |
| 265 | 227 | public static function create( $values, $return = true ) { |
| 266 | 228 | global $wpdb, $frm_duplicate_ids; |
| 267 | 229 | |
| 268 | 230 | $new_values = array(); |
| @@ -300,25 +262,27 @@ | ||
| 300 | 262 | unset( $k, $v ); |
| 301 | 263 | } |
| 302 | 264 | |
| 303 | 265 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_fields', $new_values ); |
| 266 | + $new_id = 0; | |
| 267 | + if ( $query_results ) { | |
| 268 | + self::delete_form_transient( $new_values['form_id'] ); | |
| 269 | + $new_id = $wpdb->insert_id; | |
| 270 | + } | |
| 304 | 271 | |
| 305 | - if ( ! $query_results ) { | |
| 272 | + if ( ! $return ) { | |
| 306 | 273 | return false; |
| 307 | 274 | } |
| 308 | 275 | |
| 309 | - self::delete_form_transient( $new_values['form_id'] ); | |
| 310 | - $new_id = $wpdb->insert_id; | |
| 276 | + if ( $query_results ) { | |
| 277 | + if ( isset( $values['id'] ) ) { | |
| 278 | + $frm_duplicate_ids[ $values['id'] ] = $new_id; | |
| 279 | + } | |
| 311 | 280 | |
| 312 | - if ( ! $return ) { | |
| 281 | + return $new_id; | |
| 282 | + } else { | |
| 313 | 283 | return false; |
| 314 | 284 | } |
| 315 | - | |
| 316 | - if ( isset( $values['id'] ) ) { | |
| 317 | - $frm_duplicate_ids[ $values['id'] ] = $new_id; | |
| 318 | - } | |
| 319 | - | |
| 320 | - return $new_id; | |
| 321 | 285 | } |
| 322 | 286 | |
| 323 | 287 | /** |
| 324 | 288 | * @since 5.0.08 |
| @@ -557,9 +521,9 @@ | ||
| 557 | 521 | |
| 558 | 522 | global $wpdb; |
| 559 | 523 | |
| 560 | 524 | $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 | |
| 525 | + $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id ); // WPCS: unprepared SQL ok. | |
| 562 | 526 | |
| 563 | 527 | $results = FrmDb::check_cache( $id, 'frm_field', $query, 'get_row', 0 ); |
| 564 | 528 | |
| 565 | 529 | if ( empty( $results ) ) { |
| @@ -1105,9 +1069,9 @@ | ||
| 1105 | 1069 | |
| 1106 | 1070 | /** |
| 1107 | 1071 | * @param string $id |
| 1108 | 1072 | * |
| 1109 | - * @return null|string | |
| 1073 | + * @return string | |
| 1110 | 1074 | */ |
| 1111 | 1075 | public static function get_key_by_id( $id ) { |
| 1112 | 1076 | return FrmDb::get_var( 'frm_fields', array( 'id' => $id ), 'field_key' ); |
| 1113 | 1077 | } |