PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0
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/FrmEntryValues.php +26 -97 6.265.0 View file →
@@ -8,11 +8,11 @@
8 8 */
9 9 class FrmEntryValues {
10 10
11 11 /**
12 - * @var stdClass|null
12 + * @var stdClass
13 13 */
14 - protected $entry;
14 + protected $entry = null;
15 15
16 16 /**
17 17 * @var int
18 18 */
@@ -48,9 +48,9 @@
48 48 *
49 49 * @since 2.04
50 50 *
51 51 * @param int|string $entry_id
52 - * @param array $atts
52 + * @param array $atts
53 53 */
54 54 public function __construct( $entry_id, $atts = array() ) {
55 55 if ( isset( $atts['entry'] ) && is_object( $atts['entry'] ) && ! empty( $atts['entry']->metas ) ) {
56 56 $this->entry = $atts['entry'];
@@ -75,10 +75,8 @@
75 75 *
76 76 * @since 2.04
77 77 *
78 78 * @param int|string $entry_id
79 - *
80 - * @return void
81 79 */
82 80 protected function init_entry( $entry_id ) {
83 81 $this->entry = FrmEntry::getOne( $entry_id, true );
84 82 }
@@ -83,24 +81,11 @@
83 81 $this->entry = FrmEntry::getOne( $entry_id, true );
84 82 }
85 83
86 84 /**
87 - * Gets entry property.
88 - *
89 - * @since 5.0.16
90 - *
91 - * @return stdClass
92 - */
93 - public function get_entry() {
94 - return $this->entry;
95 - }
96 -
97 - /**
98 85 * Set the form_id property
99 86 *
100 87 * @since 2.04
101 - *
102 - * @return void
103 88 */
104 89 protected function init_form_id() {
105 90 $this->form_id = (int) $this->entry->form_id;
106 91 }
@@ -110,39 +95,31 @@
110 95 *
111 96 * @since 2.04
112 97 *
113 98 * @param array $atts
114 - *
115 - * @return void
116 99 */
117 100 protected function init_include_fields( $atts ) {
118 101
119 - // For reverse compatibility with the fields parameter.
120 - if ( empty( $atts['include_fields'] ) && ! empty( $atts['fields'] ) ) {
121 - if ( ! is_array( $atts['fields'] ) ) {
122 - $atts['include_fields'] = $atts['fields'];
123 - } else {
124 - $atts['include_fields'] = '';
102 + // For reverse compatibility with the fields parameter
103 + if ( ! isset( $atts['include_fields'] ) || empty( $atts['include_fields'] ) ) {
125 104
126 - foreach ( $atts['fields'] as $included_field ) {
127 - $atts['include_fields'] .= $included_field->id . ',';
105 + if ( isset( $atts['fields'] ) && ! empty( $atts['fields'] ) ) {
106 +
107 + if ( ! is_array( $atts['fields'] ) ) {
108 + $atts['include_fields'] = $atts['fields'];
109 + } else {
110 + $atts['include_fields'] = '';
111 +
112 + foreach ( $atts['fields'] as $included_field ) {
113 + $atts['include_fields'] .= $included_field->id . ',';
114 + }
115 +
116 + $atts['include_fields'] = rtrim( $atts['include_fields'], ',' );
128 117 }
129 -
130 - $atts['include_fields'] = rtrim( $atts['include_fields'], ',' );
131 118 }
132 119 }
133 120
134 121 $this->include_fields = $this->prepare_array_property( 'include_fields', $atts );
135 -
136 - /**
137 - * Allows modifying the IDs of include_fields used in the entry values.
138 - *
139 - * @since 5.0.04
140 - *
141 - * @param array $field_ids The list of field IDs.
142 - * @param array $atts The arguments. See {@see FrmEntriesController::show_entry_shortcode()}.
143 - */
144 - $this->include_fields = apply_filters( 'frm_entry_values_include_fields', $this->include_fields, $atts );
145 122 }
146 123
147 124 /**
148 125 * Set the exclude_fields property
@@ -149,23 +126,11 @@
149 126 *
150 127 * @since 2.04
151 128 *
152 129 * @param array $atts
153 - *
154 - * @return void
155 130 */
156 131 protected function init_exclude_fields( $atts ) {
157 132 $this->exclude_fields = $this->prepare_array_property( 'exclude_fields', $atts );
158 -
159 - /**
160 - * Allows modifying the IDs of exclude_fields used in the entry values.
161 - *
162 - * @since 5.0.04
163 - *
164 - * @param array $field_ids The list of field IDs.
165 - * @param array $atts The arguments. See {@see FrmEntriesController::show_entry_shortcode()}.
166 - */
167 - $this->exclude_fields = apply_filters( 'frm_entry_values_exclude_fields', $this->exclude_fields, $atts );
168 133 }
169 134
170 135 /**
171 136 * Prepare an array property value, such as include_fields and exclude_fields
@@ -172,14 +137,14 @@
172 137 *
173 138 * @since 2.04
174 139 *
175 140 * @param string $index
176 - * @param array $atts
141 + * @param array $atts
177 142 *
178 143 * @return array
179 144 */
180 145 private function prepare_array_property( $index, $atts ) {
181 - if ( ! empty( $atts[ $index ] ) ) {
146 + if ( isset( $atts[ $index ] ) && ! empty( $atts[ $index ] ) ) {
182 147
183 148 if ( is_array( $atts[ $index ] ) ) {
184 149 $property = $atts[ $index ];
185 150 } else {
@@ -195,30 +160,11 @@
195 160 /**
196 161 * Set the fields property
197 162 *
198 163 * @since 2.04
199 - *
200 - * @return void
201 164 */
202 165 protected function init_fields() {
203 166 $this->fields = FrmField::get_all_for_form( $this->form_id, '', 'exclude', 'exclude' );
204 -
205 - /**
206 - * Allows modifying the list of all field in the form that is used in the entry values.
207 - *
208 - * @since 5.0.04
209 - *
210 - * @param array $fields The list of fields.
211 - * @param array $args The arguments. Contains `form_id`, `entry`.
212 - */
213 - $this->fields = apply_filters(
214 - 'frm_entry_values_fields',
215 - $this->fields,
216 - array(
217 - 'form_id' => $this->form_id,
218 - 'entry' => $this->entry,
219 - )
220 - );
221 167 }
222 168
223 169 /**
224 170 * Set the field_values property
@@ -223,10 +169,8 @@
223 169 /**
224 170 * Set the field_values property
225 171 *
226 172 * @since 2.04
227 - *
228 - * @return void
229 173 */
230 174 protected function init_field_values() {
231 175 foreach ( $this->fields as $field ) {
232 176 if ( $this->is_field_included( $field ) ) {
@@ -249,10 +193,8 @@
249 193 /**
250 194 * Set the user_info property
251 195 *
252 196 * @since 2.04
253 - *
254 - * @return void
255 197 */
256 198 protected function init_user_info() {
257 199 if ( isset( $this->entry->description ) ) {
258 200 $entry_description = (array) $this->entry->description;
@@ -262,32 +204,23 @@
262 204 'referrer' => '',
263 205 );
264 206 }
265 207
266 - $ip = array(
208 + $ip = array(
267 209 'label' => __( 'IP Address', 'formidable' ),
268 210 'value' => $this->entry->ip,
269 211 );
270 - $browser = array(
212 +
213 + $browser = array(
271 214 'label' => __( 'User-Agent (Browser/OS)', 'formidable' ),
272 - 'value' => isset( $entry_description['browser'] ) ? FrmEntriesHelper::get_browser( $entry_description['browser'] ) : '',
215 + 'value' => FrmEntriesHelper::get_browser( $entry_description['browser'] ),
273 216 );
217 +
274 218 $referrer = array(
275 219 'label' => __( 'Referrer', 'formidable' ),
276 - 'value' => $entry_description['referrer'] ?? '',
220 + 'value' => $entry_description['referrer'],
277 221 );
278 222
279 - /**
280 - * Allow the referrer to be modified.
281 - *
282 - * @since 5.5.1
283 - *
284 - * @param array $referrer
285 - * @param array $entry_description
286 - * @param object $entry
287 - */
288 - $referrer = apply_filters( 'frm_user_info_referrer', $referrer, $entry_description, $this->entry );
289 -
290 223 $this->user_info = array(
291 224 'ip' => $ip,
292 225 'browser' => $browser,
293 226 'referrer' => $referrer,
@@ -315,9 +248,8 @@
315 248 * @return bool
316 249 */
317 250 protected function is_field_included( $field ) {
318 251 $is_included = true;
319 -
320 252 if ( ! empty( $this->include_fields ) ) {
321 253 $is_included = $this->is_field_in_array( $field, $this->include_fields );
322 254 }
323 255
@@ -322,9 +254,8 @@
322 254 }
323 255
324 256 if ( ! empty( $this->exclude_fields ) ) {
325 257 $is_excluded = $this->is_field_in_array( $field, $this->exclude_fields );
326 -
327 258 if ( $is_excluded ) {
328 259 $is_included = false;
329 260 }
330 261 }
@@ -337,9 +268,9 @@
337 268 *
338 269 * @since 2.04
339 270 *
340 271 * @param stdClass $field
341 - * @param array $array
272 + * @param array $array
342 273 *
343 274 * @return bool
344 275 */
345 276 protected function is_field_in_array( $field, $array ) {
@@ -351,10 +282,8 @@
351 282 *
352 283 * @since 2.04
353 284 *
354 285 * @param stdClass $field
355 - *
356 - * @return void
357 286 */
358 287 protected function add_field_values( $field ) {
359 288 $this->field_values[ $field->id ] = new FrmFieldValue( $field, $this->entry );
360 289 }