PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.2
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.2
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/models/FrmField.php +25 -47 6.56.2 View file →
@@ -8,8 +8,17 @@
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 + }
12 21 $fields = array(
13 22 'text' => array(
14 23 'name' => __( 'Text', 'formidable' ),
15 24 'icon' => 'frm_icon_font frm_text2_icon',
@@ -62,41 +71,16 @@
62 71 'name' => __( 'User ID', 'formidable' ),
63 72 'icon' => 'frm_icon_font frm_user_icon',
64 73 ),
65 74 'captcha' => array(
66 - 'name' => self::get_captcha_field_name(),
75 + 'name' => $captcha_name,
67 76 'icon' => 'frm_icon_font frm_shield_check_icon',
68 77 ),
69 - 'credit_card' => array(
70 - 'name' => __( 'Payment', 'formidable' ),
71 - 'icon' => 'frm_icon_font frm_credit_card_icon',
72 - ),
73 78 );
74 79
75 - /**
76 - * @param array $fields
77 - */
78 80 return apply_filters( 'frm_available_fields', $fields );
79 81 }
80 82
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 83 public static function pro_field_selection() {
100 84 $images_url = FrmAppHelper::plugin_url() . '/images/';
101 85 $fields = array(
102 86 'file' => array(
@@ -182,13 +166,12 @@
182 166 'tag' => array(
183 167 'name' => __( 'Tags', 'formidable' ),
184 168 'icon' => 'frm_icon_font frm_price_tags_icon',
185 169 ),
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 170 'credit_card' => array(
189 - 'name' => '',
190 - 'icon' => '',
171 + 'name' => __( 'Credit Card', 'formidable' ),
172 + 'icon' => 'frm_icon_font frm_credit_card_icon frm_show_upgrade',
173 + 'addon' => 'stripe',
191 174 ),
192 175 'address' => array(
193 176 'name' => __( 'Address', 'formidable' ),
194 177 'icon' => 'frm_icon_font frm_location_icon',
@@ -254,15 +237,8 @@
254 237 $pro_field_selection = self::pro_field_selection();
255 238 return array_merge( $pro_field_selection, self::field_selection() );
256 239 }
257 240
258 - /**
259 - * Create a field.
260 - *
261 - * @param array $values
262 - * @param bool $return
263 - * @return int|false
264 - */
265 241 public static function create( $values, $return = true ) {
266 242 global $wpdb, $frm_duplicate_ids;
267 243
268 244 $new_values = array();
@@ -300,25 +276,27 @@
300 276 unset( $k, $v );
301 277 }
302 278
303 279 $query_results = $wpdb->insert( $wpdb->prefix . 'frm_fields', $new_values );
280 + $new_id = 0;
281 + if ( $query_results ) {
282 + self::delete_form_transient( $new_values['form_id'] );
283 + $new_id = $wpdb->insert_id;
284 + }
304 285
305 - if ( ! $query_results ) {
286 + if ( ! $return ) {
306 287 return false;
307 288 }
308 289
309 - self::delete_form_transient( $new_values['form_id'] );
310 - $new_id = $wpdb->insert_id;
290 + if ( $query_results ) {
291 + if ( isset( $values['id'] ) ) {
292 + $frm_duplicate_ids[ $values['id'] ] = $new_id;
293 + }
311 294
312 - if ( ! $return ) {
295 + return $new_id;
296 + } else {
313 297 return false;
314 298 }
315 -
316 - if ( isset( $values['id'] ) ) {
317 - $frm_duplicate_ids[ $values['id'] ] = $new_id;
318 - }
319 -
320 - return $new_id;
321 299 }
322 300
323 301 /**
324 302 * @since 5.0.08