| @@ -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,14 +176,8 @@ | ||
| 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.', | |
| 211 | - ), | |
| 212 | 180 | 'ssa-appointment' => array( |
| 213 | 181 | 'name' => __( 'Appointment', 'formidable' ), |
| 214 | 182 | 'icon' => 'frm_icon_font frm_calendar_icon frm_show_upgrade', |
| 215 | 183 | 'require' => 'Simply Schedule Appointments', |
| @@ -233,12 +201,8 @@ | ||
| 233 | 201 | 'section' => 'pricing', |
| 234 | 202 | ), |
| 235 | 203 | ); |
| 236 | 204 | |
| 237 | - if ( ! FrmAppHelper::show_new_feature( 'ai' ) ) { | |
| 238 | - unset( $fields['ai'] ); | |
| 239 | - } | |
| 240 | - | |
| 241 | 205 | // Since the signature field may be in a different section, don't show it twice. |
| 242 | 206 | $lite_fields = self::field_selection(); |
| 243 | 207 | if ( isset( $lite_fields['signature'] ) ) { |
| 244 | 208 | unset( $fields['signature'] ); |
| @@ -254,15 +218,8 @@ | ||
| 254 | 218 | $pro_field_selection = self::pro_field_selection(); |
| 255 | 219 | return array_merge( $pro_field_selection, self::field_selection() ); |
| 256 | 220 | } |
| 257 | 221 | |
| 258 | - /** | |
| 259 | - * Create a field. | |
| 260 | - * | |
| 261 | - * @param array $values | |
| 262 | - * @param bool $return | |
| 263 | - * @return int|false | |
| 264 | - */ | |
| 265 | 222 | public static function create( $values, $return = true ) { |
| 266 | 223 | global $wpdb, $frm_duplicate_ids; |
| 267 | 224 | |
| 268 | 225 | $new_values = array(); |
| @@ -300,25 +257,27 @@ | ||
| 300 | 257 | unset( $k, $v ); |
| 301 | 258 | } |
| 302 | 259 | |
| 303 | 260 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_fields', $new_values ); |
| 261 | + $new_id = 0; | |
| 262 | + if ( $query_results ) { | |
| 263 | + self::delete_form_transient( $new_values['form_id'] ); | |
| 264 | + $new_id = $wpdb->insert_id; | |
| 265 | + } | |
| 304 | 266 | |
| 305 | - if ( ! $query_results ) { | |
| 267 | + if ( ! $return ) { | |
| 306 | 268 | return false; |
| 307 | 269 | } |
| 308 | 270 | |
| 309 | - self::delete_form_transient( $new_values['form_id'] ); | |
| 310 | - $new_id = $wpdb->insert_id; | |
| 271 | + if ( $query_results ) { | |
| 272 | + if ( isset( $values['id'] ) ) { | |
| 273 | + $frm_duplicate_ids[ $values['id'] ] = $new_id; | |
| 274 | + } | |
| 311 | 275 | |
| 312 | - if ( ! $return ) { | |
| 276 | + return $new_id; | |
| 277 | + } else { | |
| 313 | 278 | return false; |
| 314 | 279 | } |
| 315 | - | |
| 316 | - if ( isset( $values['id'] ) ) { | |
| 317 | - $frm_duplicate_ids[ $values['id'] ] = $new_id; | |
| 318 | - } | |
| 319 | - | |
| 320 | - return $new_id; | |
| 321 | 280 | } |
| 322 | 281 | |
| 323 | 282 | /** |
| 324 | 283 | * @since 5.0.08 |
| @@ -1105,9 +1064,9 @@ | ||
| 1105 | 1064 | |
| 1106 | 1065 | /** |
| 1107 | 1066 | * @param string $id |
| 1108 | 1067 | * |
| 1109 | - * @return null|string | |
| 1068 | + * @return string | |
| 1110 | 1069 | */ |
| 1111 | 1070 | public static function get_key_by_id( $id ) { |
| 1112 | 1071 | return FrmDb::get_var( 'frm_fields', array( 'id' => $id ), 'field_key' ); |
| 1113 | 1072 | } |