| @@ -8,9 +8,9 @@ | ||
| 8 | 8 | */ |
| 9 | 9 | class FrmEntryValues { |
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | - * @var stdClass|null | |
| 12 | + * @var false|stdClass|null | |
| 13 | 13 | */ |
| 14 | 14 | protected $entry; |
| 15 | 15 | |
| 16 | 16 | /** |
| @@ -114,14 +114,11 @@ | ||
| 114 | 114 | * |
| 115 | 115 | * @return void |
| 116 | 116 | */ |
| 117 | 117 | protected function init_include_fields( $atts ) { |
| 118 | - | |
| 119 | 118 | // For reverse compatibility with the fields parameter. |
| 120 | 119 | if ( empty( $atts['include_fields'] ) && ! empty( $atts['fields'] ) ) { |
| 121 | - if ( ! is_array( $atts['fields'] ) ) { | |
| 122 | - $atts['include_fields'] = $atts['fields']; | |
| 123 | - } else { | |
| 120 | + if ( is_array( $atts['fields'] ) ) { | |
| 124 | 121 | $atts['include_fields'] = ''; |
| 125 | 122 | |
| 126 | 123 | foreach ( $atts['fields'] as $included_field ) { |
| 127 | 124 | $atts['include_fields'] .= $included_field->id . ','; |
| @@ -127,8 +124,10 @@ | ||
| 127 | 124 | $atts['include_fields'] .= $included_field->id . ','; |
| 128 | 125 | } |
| 129 | 126 | |
| 130 | 127 | $atts['include_fields'] = rtrim( $atts['include_fields'], ',' ); |
| 128 | + } else { | |
| 129 | + $atts['include_fields'] = $atts['fields']; | |
| 131 | 130 | } |
| 132 | 131 | } |
| 133 | 132 | |
| 134 | 133 | $this->include_fields = $this->prepare_array_property( 'include_fields', $atts ); |
| @@ -178,19 +177,12 @@ | ||
| 178 | 177 | * @return array |
| 179 | 178 | */ |
| 180 | 179 | private function prepare_array_property( $index, $atts ) { |
| 181 | 180 | if ( ! empty( $atts[ $index ] ) ) { |
| 182 | - | |
| 183 | - if ( is_array( $atts[ $index ] ) ) { | |
| 184 | - $property = $atts[ $index ]; | |
| 185 | - } else { | |
| 186 | - $property = explode( ',', $atts[ $index ] ); | |
| 187 | - } | |
| 188 | - } else { | |
| 189 | - $property = array(); | |
| 181 | + return is_array( $atts[ $index ] ) ? $atts[ $index ] : explode( ',', $atts[ $index ] ); | |
| 190 | 182 | } |
| 191 | 183 | |
| 192 | - return $property; | |
| 184 | + return array(); | |
| 193 | 185 | } |
| 194 | 186 | |
| 195 | 187 | /** |
| 196 | 188 | * Set the fields property |
| @@ -316,13 +308,13 @@ | ||
| 316 | 308 | */ |
| 317 | 309 | protected function is_field_included( $field ) { |
| 318 | 310 | $is_included = true; |
| 319 | 311 | |
| 320 | - if ( ! empty( $this->include_fields ) ) { | |
| 312 | + if ( $this->include_fields ) { | |
| 321 | 313 | $is_included = $this->is_field_in_array( $field, $this->include_fields ); |
| 322 | 314 | } |
| 323 | 315 | |
| 324 | - if ( ! empty( $this->exclude_fields ) ) { | |
| 316 | + if ( $this->exclude_fields ) { | |
| 325 | 317 | $is_excluded = $this->is_field_in_array( $field, $this->exclude_fields ); |
| 326 | 318 | |
| 327 | 319 | if ( $is_excluded ) { |
| 328 | 320 | $is_included = false; |
| @@ -342,8 +334,9 @@ | ||
| 342 | 334 | * |
| 343 | 335 | * @return bool |
| 344 | 336 | */ |
| 345 | 337 | protected function is_field_in_array( $field, $array ) { |
| 338 | + // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict | |
| 346 | 339 | return in_array( $field->id, $array ) || in_array( (string) $field->field_key, $array, true ); |
| 347 | 340 | } |
| 348 | 341 | |
| 349 | 342 | /** |