| @@ -8,11 +8,11 @@ | ||
| 8 | 8 | */ |
| 9 | 9 | class FrmEntryValues { |
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | - * @var false|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']; |
| @@ -86,9 +86,8 @@ | ||
| 86 | 86 | /** |
| 87 | 87 | * Gets entry property. |
| 88 | 88 | * |
| 89 | 89 | * @since 5.0.16 |
| 90 | - * | |
| 91 | 90 | * @return stdClass |
| 92 | 91 | */ |
| 93 | 92 | public function get_entry() { |
| 94 | 93 | return $this->entry; |
| @@ -114,20 +113,25 @@ | ||
| 114 | 113 | * |
| 115 | 114 | * @return void |
| 116 | 115 | */ |
| 117 | 116 | protected function init_include_fields( $atts ) { |
| 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'] = ''; | |
| 122 | 117 | |
| 123 | - foreach ( $atts['fields'] as $included_field ) { | |
| 124 | - $atts['include_fields'] .= $included_field->id . ','; | |
| 118 | + // For reverse compatibility with the fields parameter | |
| 119 | + if ( ! isset( $atts['include_fields'] ) || empty( $atts['include_fields'] ) ) { | |
| 120 | + | |
| 121 | + if ( isset( $atts['fields'] ) && ! empty( $atts['fields'] ) ) { | |
| 122 | + | |
| 123 | + if ( ! is_array( $atts['fields'] ) ) { | |
| 124 | + $atts['include_fields'] = $atts['fields']; | |
| 125 | + } else { | |
| 126 | + $atts['include_fields'] = ''; | |
| 127 | + | |
| 128 | + foreach ( $atts['fields'] as $included_field ) { | |
| 129 | + $atts['include_fields'] .= $included_field->id . ','; | |
| 130 | + } | |
| 131 | + | |
| 132 | + $atts['include_fields'] = rtrim( $atts['include_fields'], ',' ); | |
| 125 | 133 | } |
| 126 | - | |
| 127 | - $atts['include_fields'] = rtrim( $atts['include_fields'], ',' ); | |
| 128 | - } else { | |
| 129 | - $atts['include_fields'] = $atts['fields']; | |
| 130 | 134 | } |
| 131 | 135 | } |
| 132 | 136 | |
| 133 | 137 | $this->include_fields = $this->prepare_array_property( 'include_fields', $atts ); |
| @@ -171,18 +175,25 @@ | ||
| 171 | 175 | * |
| 172 | 176 | * @since 2.04 |
| 173 | 177 | * |
| 174 | 178 | * @param string $index |
| 175 | - * @param array $atts | |
| 179 | + * @param array $atts | |
| 176 | 180 | * |
| 177 | 181 | * @return array |
| 178 | 182 | */ |
| 179 | 183 | private function prepare_array_property( $index, $atts ) { |
| 180 | - if ( ! empty( $atts[ $index ] ) ) { | |
| 181 | - return is_array( $atts[ $index ] ) ? $atts[ $index ] : explode( ',', $atts[ $index ] ); | |
| 184 | + if ( isset( $atts[ $index ] ) && ! empty( $atts[ $index ] ) ) { | |
| 185 | + | |
| 186 | + if ( is_array( $atts[ $index ] ) ) { | |
| 187 | + $property = $atts[ $index ]; | |
| 188 | + } else { | |
| 189 | + $property = explode( ',', $atts[ $index ] ); | |
| 190 | + } | |
| 191 | + } else { | |
| 192 | + $property = array(); | |
| 182 | 193 | } |
| 183 | 194 | |
| 184 | - return array(); | |
| 195 | + return $property; | |
| 185 | 196 | } |
| 186 | 197 | |
| 187 | 198 | /** |
| 188 | 199 | * Set the fields property |
| @@ -254,19 +265,19 @@ | ||
| 254 | 265 | 'referrer' => '', |
| 255 | 266 | ); |
| 256 | 267 | } |
| 257 | 268 | |
| 258 | - $ip = array( | |
| 269 | + $ip = array( | |
| 259 | 270 | 'label' => __( 'IP Address', 'formidable' ), |
| 260 | 271 | 'value' => $this->entry->ip, |
| 261 | 272 | ); |
| 262 | - $browser = array( | |
| 273 | + $browser = array( | |
| 263 | 274 | 'label' => __( 'User-Agent (Browser/OS)', 'formidable' ), |
| 264 | 275 | 'value' => isset( $entry_description['browser'] ) ? FrmEntriesHelper::get_browser( $entry_description['browser'] ) : '', |
| 265 | 276 | ); |
| 266 | 277 | $referrer = array( |
| 267 | 278 | 'label' => __( 'Referrer', 'formidable' ), |
| 268 | - 'value' => $entry_description['referrer'] ?? '', | |
| 279 | + 'value' => isset( $entry_description['referrer'] ) ? $entry_description['referrer'] : '', | |
| 269 | 280 | ); |
| 270 | 281 | |
| 271 | 282 | /** |
| 272 | 283 | * Allow the referrer to be modified. |
| @@ -272,11 +283,10 @@ | ||
| 272 | 283 | * Allow the referrer to be modified. |
| 273 | 284 | * |
| 274 | 285 | * @since 5.5.1 |
| 275 | 286 | * |
| 276 | - * @param array $referrer | |
| 277 | - * @param array $entry_description | |
| 278 | - * @param object $entry | |
| 287 | + * @param array $referrer | |
| 288 | + * @param array @entry_description | |
| 279 | 289 | */ |
| 280 | 290 | $referrer = apply_filters( 'frm_user_info_referrer', $referrer, $entry_description, $this->entry ); |
| 281 | 291 | |
| 282 | 292 | $this->user_info = array( |
| @@ -307,16 +317,14 @@ | ||
| 307 | 317 | * @return bool |
| 308 | 318 | */ |
| 309 | 319 | protected function is_field_included( $field ) { |
| 310 | 320 | $is_included = true; |
| 311 | - | |
| 312 | - if ( $this->include_fields ) { | |
| 321 | + if ( ! empty( $this->include_fields ) ) { | |
| 313 | 322 | $is_included = $this->is_field_in_array( $field, $this->include_fields ); |
| 314 | 323 | } |
| 315 | 324 | |
| 316 | - if ( $this->exclude_fields ) { | |
| 325 | + if ( ! empty( $this->exclude_fields ) ) { | |
| 317 | 326 | $is_excluded = $this->is_field_in_array( $field, $this->exclude_fields ); |
| 318 | - | |
| 319 | 327 | if ( $is_excluded ) { |
| 320 | 328 | $is_included = false; |
| 321 | 329 | } |
| 322 | 330 | } |
| @@ -329,14 +337,13 @@ | ||
| 329 | 337 | * |
| 330 | 338 | * @since 2.04 |
| 331 | 339 | * |
| 332 | 340 | * @param stdClass $field |
| 333 | - * @param array $array | |
| 341 | + * @param array $array | |
| 334 | 342 | * |
| 335 | 343 | * @return bool |
| 336 | 344 | */ |
| 337 | 345 | protected function is_field_in_array( $field, $array ) { |
| 338 | - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict | |
| 339 | 346 | return in_array( $field->id, $array ) || in_array( (string) $field->field_key, $array, true ); |
| 340 | 347 | } |
| 341 | 348 | |
| 342 | 349 | /** |