PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.6.1
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.6.1
1.6.7 1.6.8 1.6.9 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.18 1.6.19 1.6.2 1.6.20 1.6.21 1.6.22 1.6.23 1.6.24 1.6.25 1.6.26 1.6.27 1.6.28 1.6.3 1.6.4 1.6.5 1.6.6 All 74 releases
← All changes | includes/class-form.php +4 -108 1.6.271.6.1 View file →
@@ -28,36 +28,8 @@
28 28 */
29 29 public $data = null;
30 30
31 31 /**
32 - * Derived/formatted stats & metadata used by admin/AJAX/API responses.
33 - * Declared explicitly to avoid PHP 8.2 "dynamic property" deprecations.
34 - *
35 - * @var int
36 - */
37 - public $entries = 0;
38 -
39 - /**
40 - * @var array
41 - */
42 - public $settings = [];
43 -
44 - /**
45 - * @var int
46 - */
47 - public $views = 0;
48 -
49 - /**
50 - * @var int
51 - */
52 - public $payments = 0;
53 -
54 - /**
55 - * @var array
56 - */
57 - public $author = [];
58 -
59 - /**
60 32 * Form fields
61 33 *
62 34 * @var array
63 35 */
@@ -125,12 +97,9 @@
125 97
126 98 $form_fields = [];
127 99
128 100 foreach ( $fields as $key => $content ) {
129 - // Security fix: Prevent PHP Object Injection by restricting allowed classes
130 - $field = is_serialized( $content->post_content )
131 - ? @unserialize( $content->post_content, [ 'allowed_classes' => false ] )
132 - : $content->post_content;
101 + $field = maybe_unserialize( $content->post_content );
133 102
134 103 if ( empty( $field['template'] ) ) {
135 104 continue;
136 105 }
@@ -169,16 +138,12 @@
169 138 $field['enable_no_captcha'] = isset( $field['enable_no_captcha'] ) ? $field['enable_no_captcha'] : '';
170 139 $field['recaptcha_theme'] = isset( $field['recaptcha_theme'] ) ? $field['recaptcha_theme'] : 'light';
171 140 }
172 141
173 - // Check if meta_key has changed when saving form compared current entries
174 - if ( isset( $field['name'] ) ) {
175 - $field['original_name'] = $field['name'];
176 - }
177 - $form_fields[] = apply_filters( 'weforms-get-form-field', $field, $this->id );
142 + $form_fields[] = apply_filters( 'weforms-get-form-field', $field );
178 143 }
179 144
180 - $this->form_fields = apply_filters( 'weforms-get-form-fields', $form_fields, $this->id );
145 + $this->form_fields = apply_filters( 'weforms-get-form-fields', $form_fields );
181 146
182 147 return $this->form_fields;
183 148 }
184 149
@@ -305,9 +270,9 @@
305 270 public function get_settings() {
306 271 $settings = get_post_meta( $this->id, 'wpuf_form_settings', true );
307 272 $default = weforms_get_default_form_settings();
308 273
309 - return apply_filters( 'weforms-get-form-settings', array_merge( $default, $settings ), $this->id );
274 + return array_merge( $default, $settings );
310 275 }
311 276
312 277 /**
313 278 * Check if the form submission is open
@@ -399,77 +364,8 @@
399 364 * @return \WeForms_Form_Entry_Manager
400 365 */
401 366 public function entries() {
402 367 return new WeForms_Form_Entry_Manager( $this->id, $this );
403 - }
404 -
405 - /**
406 - * When a user is editing their form they may change a fields name.
407 - * This method will loop through existing entries to match the new field names.
408 - *
409 - * @since 1.6.9
410 - *
411 - * @param int $form_id
412 - * @param array $form_fields
413 - */
414 - public function maybe_update_entries( $form_fields ) {
415 - $changed_fields = $this->get_changed_fields( $form_fields );
416 - // Loop through changed fields and update entries
417 - foreach ( $changed_fields as $old => $new) {
418 - $updated_fields = $this->rename_field( $old, $new );
419 - }
420 - }
421 -
422 - /**
423 - * When a user is editing their form they may change a fields name.
424 - * This method will loop through all fields that have changed.
425 - *
426 - * @since 1.6.9
427 - *
428 - * @param int $form_id
429 - * @param array $form_fields
430 - *
431 - * @return array
432 - */
433 - public function get_changed_fields( $form_fields ) {
434 - $changed_fields = array();
435 - foreach ( $form_fields as $field ) {
436 - $org_field = $field['original_name'];
437 - // All form fields should have an original name.
438 - if ( empty( $field['original_name'] ) ) {
439 - continue;
440 - }
441 - if ( $field['name'] !== $field['original_name'] ) {
442 - $changed_fields[$field['original_name']] = $field['name'];
443 - } else {
444 - continue;
445 - }
446 - }
447 - return $changed_fields;
448 -
449 - }
450 -
451 - /**
452 - * When a user changes the field names of a form, the existing entries will need updated.
453 - * This method will loop through the existing entries and update them will the new names.
454 - *
455 - * @since 1.6.9
456 - *
457 - * @param int $form_id
458 - * @param array $form_fields
459 - *
460 - * @return array
461 - */
462 - public function rename_field ( $old, $new ) {
463 - global $wpdb;
464 -
465 - $entries = weforms_get_form_entries( $this->id );
466 -
467 - foreach ( $entries as $entry ) {
468 - $entry_id = $entry->id;
469 - $values = weforms_get_entry_meta( $entry_id );
470 - $update_keys = $wpdb->update( $wpdb->weforms_entrymeta, array( 'meta_key' => $new ), array( 'meta_key' => $old, 'weforms_entry_id' => $entry_id ) );
471 - }
472 368 }
473 369
474 370 /**
475 371 * Get number of form entries