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 -94 6.255.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,23 +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 - * @return stdClass
91 - */
92 - public function get_entry() {
93 - return $this->entry;
94 - }
95 -
96 - /**
97 85 * Set the form_id property
98 86 *
99 87 * @since 2.04
100 - *
101 - * @return void
102 88 */
103 89 protected function init_form_id() {
104 90 $this->form_id = (int) $this->entry->form_id;
105 91 }
@@ -109,39 +95,31 @@
109 95 *
110 96 * @since 2.04
111 97 *
112 98 * @param array $atts
113 - *
114 - * @return void
115 99 */
116 100 protected function init_include_fields( $atts ) {
117 101
118 - // For reverse compatibility with the fields parameter.
119 - if ( empty( $atts['include_fields'] ) && ! empty( $atts['fields'] ) ) {
120 - if ( ! is_array( $atts['fields'] ) ) {
121 - $atts['include_fields'] = $atts['fields'];
122 - } else {
123 - $atts['include_fields'] = '';
102 + // For reverse compatibility with the fields parameter
103 + if ( ! isset( $atts['include_fields'] ) || empty( $atts['include_fields'] ) ) {
124 104
125 - foreach ( $atts['fields'] as $included_field ) {
126 - $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'], ',' );
127 117 }
128 -
129 - $atts['include_fields'] = rtrim( $atts['include_fields'], ',' );
130 118 }
131 119 }
132 120
133 121 $this->include_fields = $this->prepare_array_property( 'include_fields', $atts );
134 -
135 - /**
136 - * Allows modifying the IDs of include_fields used in the entry values.
137 - *
138 - * @since 5.0.04
139 - *
140 - * @param array $field_ids The list of field IDs.
141 - * @param array $atts The arguments. See {@see FrmEntriesController::show_entry_shortcode()}.
142 - */
143 - $this->include_fields = apply_filters( 'frm_entry_values_include_fields', $this->include_fields, $atts );
144 122 }
145 123
146 124 /**
147 125 * Set the exclude_fields property
@@ -148,23 +126,11 @@
148 126 *
149 127 * @since 2.04
150 128 *
151 129 * @param array $atts
152 - *
153 - * @return void
154 130 */
155 131 protected function init_exclude_fields( $atts ) {
156 132 $this->exclude_fields = $this->prepare_array_property( 'exclude_fields', $atts );
157 -
158 - /**
159 - * Allows modifying the IDs of exclude_fields used in the entry values.
160 - *
161 - * @since 5.0.04
162 - *
163 - * @param array $field_ids The list of field IDs.
164 - * @param array $atts The arguments. See {@see FrmEntriesController::show_entry_shortcode()}.
165 - */
166 - $this->exclude_fields = apply_filters( 'frm_entry_values_exclude_fields', $this->exclude_fields, $atts );
167 133 }
168 134
169 135 /**
170 136 * Prepare an array property value, such as include_fields and exclude_fields
@@ -171,14 +137,14 @@
171 137 *
172 138 * @since 2.04
173 139 *
174 140 * @param string $index
175 - * @param array $atts
141 + * @param array $atts
176 142 *
177 143 * @return array
178 144 */
179 145 private function prepare_array_property( $index, $atts ) {
180 - if ( ! empty( $atts[ $index ] ) ) {
146 + if ( isset( $atts[ $index ] ) && ! empty( $atts[ $index ] ) ) {
181 147
182 148 if ( is_array( $atts[ $index ] ) ) {
183 149 $property = $atts[ $index ];
184 150 } else {
@@ -194,30 +160,11 @@
194 160 /**
195 161 * Set the fields property
196 162 *
197 163 * @since 2.04
198 - *
199 - * @return void
200 164 */
201 165 protected function init_fields() {
202 166 $this->fields = FrmField::get_all_for_form( $this->form_id, '', 'exclude', 'exclude' );
203 -
204 - /**
205 - * Allows modifying the list of all field in the form that is used in the entry values.
206 - *
207 - * @since 5.0.04
208 - *
209 - * @param array $fields The list of fields.
210 - * @param array $args The arguments. Contains `form_id`, `entry`.
211 - */
212 - $this->fields = apply_filters(
213 - 'frm_entry_values_fields',
214 - $this->fields,
215 - array(
216 - 'form_id' => $this->form_id,
217 - 'entry' => $this->entry,
218 - )
219 - );
220 167 }
221 168
222 169 /**
223 170 * Set the field_values property
@@ -222,10 +169,8 @@
222 169 /**
223 170 * Set the field_values property
224 171 *
225 172 * @since 2.04
226 - *
227 - * @return void
228 173 */
229 174 protected function init_field_values() {
230 175 foreach ( $this->fields as $field ) {
231 176 if ( $this->is_field_included( $field ) ) {
@@ -248,10 +193,8 @@
248 193 /**
249 194 * Set the user_info property
250 195 *
251 196 * @since 2.04
252 - *
253 - * @return void
254 197 */
255 198 protected function init_user_info() {
256 199 if ( isset( $this->entry->description ) ) {
257 200 $entry_description = (array) $this->entry->description;
@@ -261,32 +204,23 @@
261 204 'referrer' => '',
262 205 );
263 206 }
264 207
265 - $ip = array(
208 + $ip = array(
266 209 'label' => __( 'IP Address', 'formidable' ),
267 210 'value' => $this->entry->ip,
268 211 );
269 - $browser = array(
212 +
213 + $browser = array(
270 214 'label' => __( 'User-Agent (Browser/OS)', 'formidable' ),
271 - 'value' => isset( $entry_description['browser'] ) ? FrmEntriesHelper::get_browser( $entry_description['browser'] ) : '',
215 + 'value' => FrmEntriesHelper::get_browser( $entry_description['browser'] ),
272 216 );
217 +
273 218 $referrer = array(
274 219 'label' => __( 'Referrer', 'formidable' ),
275 - 'value' => $entry_description['referrer'] ?? '',
220 + 'value' => $entry_description['referrer'],
276 221 );
277 222
278 - /**
279 - * Allow the referrer to be modified.
280 - *
281 - * @since 5.5.1
282 - *
283 - * @param array $referrer
284 - * @param array $entry_description
285 - * @param object $entry
286 - */
287 - $referrer = apply_filters( 'frm_user_info_referrer', $referrer, $entry_description, $this->entry );
288 -
289 223 $this->user_info = array(
290 224 'ip' => $ip,
291 225 'browser' => $browser,
292 226 'referrer' => $referrer,
@@ -334,9 +268,9 @@
334 268 *
335 269 * @since 2.04
336 270 *
337 271 * @param stdClass $field
338 - * @param array $array
272 + * @param array $array
339 273 *
340 274 * @return bool
341 275 */
342 276 protected function is_field_in_array( $field, $array ) {
@@ -348,10 +282,8 @@
348 282 *
349 283 * @since 2.04
350 284 *
351 285 * @param stdClass $field
352 - *
353 - * @return void
354 286 */
355 287 protected function add_field_values( $field ) {
356 288 $this->field_values[ $field->id ] = new FrmFieldValue( $field, $this->entry );
357 289 }