PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
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/fields/FrmFieldUserID.php +25 -14 6.25 → trunk View file →
@@ -9,8 +9,9 @@
9 9 class FrmFieldUserID extends FrmFieldType {
10 10
11 11 /**
12 12 * @var string
13 + *
13 14 * @since 3.0
14 15 */
15 16 protected $type = 'user_id';
16 17
@@ -15,8 +16,9 @@
15 16 protected $type = 'user_id';
16 17
17 18 /**
18 19 * @var bool
20 + *
19 21 * @since 3.0
20 22 */
21 23 protected $has_input = false;
22 24
@@ -21,8 +23,9 @@
21 23 protected $has_input = false;
22 24
23 25 /**
24 26 * @var bool
27 + *
25 28 * @since 3.0
26 29 */
27 30 protected $has_html = false;
28 31
@@ -27,8 +30,9 @@
27 30 protected $has_html = false;
28 31
29 32 /**
30 33 * @var bool
34 + *
31 35 * @since 3.0
32 36 */
33 37 protected $holds_email_values = true;
34 38
@@ -36,9 +40,8 @@
36 40 * @var bool
37 41 */
38 42 protected $array_allowed = false;
39 43
40 -
41 44 /**
42 45 * @return string
43 46 */
44 47 protected function include_form_builder_file() {
@@ -44,28 +47,41 @@
44 47 protected function include_form_builder_file() {
45 48 return FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/field-user-id.php';
46 49 }
47 50
51 + /**
52 + * @param array $args
53 + */
48 54 public function prepare_field_html( $args ) {
49 55 $args = $this->fill_display_field_values( $args );
50 56 $value = $this->get_field_value( $args );
51 57
52 - echo '<input type="hidden" name="' . esc_attr( $args['field_name'] ) . '" id="' . esc_attr( $args['html_id'] ) . '" value="' . esc_attr( $value ) . '" data-frmval="' . esc_attr( $value ) . '"/>' . "\n";
58 + echo '<input type="hidden" name="' . esc_attr( $args['field_name'] ) . '" id="' . esc_attr( $args['html_id'] ) . '" value="' . esc_attr( $value ) . '" data-frmval="' . esc_attr( $value ) . '"/>' . "\n"; // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
53 59 }
54 60
55 61 /**
56 62 * @since 4.03.06
63 + *
64 + * @param array $args Field display arguments.
65 + *
66 + * @return int|string
57 67 */
58 68 protected function get_field_value( $args ) {
59 69 $user_ID = get_current_user_id();
60 - $user_ID = ( $user_ID ? $user_ID : '' );
61 - $posted_value = ( FrmAppHelper::is_admin() && $_POST && isset( $_POST['item_meta'][ $this->field['id'] ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
62 - $action = ( $args['action'] ?? $args['form_action'] ?? '' );
70 + $user_ID = $user_ID ? $user_ID : '';
71 + $posted_value = FrmAppHelper::is_admin() && $_POST && isset( $_POST['item_meta'][ $this->field['id'] ] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
72 + $action = $args['action'] ?? $args['form_action'] ?? '';
63 73 $updating = $action === 'update';
64 74 return is_numeric( $this->field['value'] ) || $posted_value || $updating ? $this->field['value'] : $user_ID;
65 75 }
66 76
77 + /**
78 + * @param array $args
79 + *
80 + * @return array
81 + */
67 82 public function validate( $args ) {
83 + // phpcs:ignore Universal.Operators.StrictComparisons
68 84 if ( '' == $args['value'] ) {
69 85 return array();
70 86 }
71 87
@@ -88,9 +104,8 @@
88 104 * @return array|string A string is returned, but the return signature should match FrmFieldType.
89 105 */
90 106 protected function prepare_display_value( $value, $atts ) {
91 107 $user_info = $this->prepare_user_info_attribute( $atts );
92 -
93 108 return FrmFieldsHelper::get_user_display_name( $value, $user_info, $atts );
94 109 }
95 110
96 111 /**
@@ -105,18 +120,12 @@
105 120 * @return string
106 121 */
107 122 private function prepare_user_info_attribute( $atts ) {
108 123 if ( isset( $atts['show'] ) ) {
109 - if ( $atts['show'] === 'id' ) {
110 - $user_info = 'ID';
111 - } else {
112 - $user_info = $atts['show'];
113 - }
114 - } else {
115 - $user_info = apply_filters( 'frm_user_id_display', 'display_name' );
124 + return $atts['show'] === 'id' ? 'ID' : $atts['show'];
116 125 }
117 126
118 - return $user_info;
127 + return apply_filters( 'frm_user_id_display', 'display_name' );
119 128 }
120 129
121 130 /**
122 131 * @param string $value
@@ -129,8 +138,10 @@
129 138 }
130 139
131 140 /**
132 141 * @since 4.0.04
142 + *
143 + * @param mixed $value Field value passed by reference.
133 144 *
134 145 * @return void
135 146 */
136 147 public function sanitize_value( &$value ) {