| @@ -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 | } |
| @@ -96,10 +94,8 @@ | ||
| 96 | 94 | /** |
| 97 | 95 | * Set the form_id property |
| 98 | 96 | * |
| 99 | 97 | * @since 2.04 |
| 100 | - * | |
| 101 | - * @return void | |
| 102 | 98 | */ |
| 103 | 99 | protected function init_form_id() { |
| 104 | 100 | $this->form_id = (int) $this->entry->form_id; |
| 105 | 101 | } |
| @@ -109,25 +105,27 @@ | ||
| 109 | 105 | * |
| 110 | 106 | * @since 2.04 |
| 111 | 107 | * |
| 112 | 108 | * @param array $atts |
| 113 | - * | |
| 114 | - * @return void | |
| 115 | 109 | */ |
| 116 | 110 | protected function init_include_fields( $atts ) { |
| 117 | 111 | |
| 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'] = ''; | |
| 112 | + // For reverse compatibility with the fields parameter | |
| 113 | + if ( ! isset( $atts['include_fields'] ) || empty( $atts['include_fields'] ) ) { | |
| 124 | 114 | |
| 125 | - foreach ( $atts['fields'] as $included_field ) { | |
| 126 | - $atts['include_fields'] .= $included_field->id . ','; | |
| 115 | + if ( isset( $atts['fields'] ) && ! empty( $atts['fields'] ) ) { | |
| 116 | + | |
| 117 | + if ( ! is_array( $atts['fields'] ) ) { | |
| 118 | + $atts['include_fields'] = $atts['fields']; | |
| 119 | + } else { | |
| 120 | + $atts['include_fields'] = ''; | |
| 121 | + | |
| 122 | + foreach ( $atts['fields'] as $included_field ) { | |
| 123 | + $atts['include_fields'] .= $included_field->id . ','; | |
| 124 | + } | |
| 125 | + | |
| 126 | + $atts['include_fields'] = rtrim( $atts['include_fields'], ',' ); | |
| 127 | 127 | } |
| 128 | - | |
| 129 | - $atts['include_fields'] = rtrim( $atts['include_fields'], ',' ); | |
| 130 | 128 | } |
| 131 | 129 | } |
| 132 | 130 | |
| 133 | 131 | $this->include_fields = $this->prepare_array_property( 'include_fields', $atts ); |
| @@ -148,10 +146,8 @@ | ||
| 148 | 146 | * |
| 149 | 147 | * @since 2.04 |
| 150 | 148 | * |
| 151 | 149 | * @param array $atts |
| 152 | - * | |
| 153 | - * @return void | |
| 154 | 150 | */ |
| 155 | 151 | protected function init_exclude_fields( $atts ) { |
| 156 | 152 | $this->exclude_fields = $this->prepare_array_property( 'exclude_fields', $atts ); |
| 157 | 153 | |
| @@ -171,14 +167,14 @@ | ||
| 171 | 167 | * |
| 172 | 168 | * @since 2.04 |
| 173 | 169 | * |
| 174 | 170 | * @param string $index |
| 175 | - * @param array $atts | |
| 171 | + * @param array $atts | |
| 176 | 172 | * |
| 177 | 173 | * @return array |
| 178 | 174 | */ |
| 179 | 175 | private function prepare_array_property( $index, $atts ) { |
| 180 | - if ( ! empty( $atts[ $index ] ) ) { | |
| 176 | + if ( isset( $atts[ $index ] ) && ! empty( $atts[ $index ] ) ) { | |
| 181 | 177 | |
| 182 | 178 | if ( is_array( $atts[ $index ] ) ) { |
| 183 | 179 | $property = $atts[ $index ]; |
| 184 | 180 | } else { |
| @@ -194,10 +190,8 @@ | ||
| 194 | 190 | /** |
| 195 | 191 | * Set the fields property |
| 196 | 192 | * |
| 197 | 193 | * @since 2.04 |
| 198 | - * | |
| 199 | - * @return void | |
| 200 | 194 | */ |
| 201 | 195 | protected function init_fields() { |
| 202 | 196 | $this->fields = FrmField::get_all_for_form( $this->form_id, '', 'exclude', 'exclude' ); |
| 203 | 197 | |
| @@ -222,10 +216,8 @@ | ||
| 222 | 216 | /** |
| 223 | 217 | * Set the field_values property |
| 224 | 218 | * |
| 225 | 219 | * @since 2.04 |
| 226 | - * | |
| 227 | - * @return void | |
| 228 | 220 | */ |
| 229 | 221 | protected function init_field_values() { |
| 230 | 222 | foreach ( $this->fields as $field ) { |
| 231 | 223 | if ( $this->is_field_included( $field ) ) { |
| @@ -248,10 +240,8 @@ | ||
| 248 | 240 | /** |
| 249 | 241 | * Set the user_info property |
| 250 | 242 | * |
| 251 | 243 | * @since 2.04 |
| 252 | - * | |
| 253 | - * @return void | |
| 254 | 244 | */ |
| 255 | 245 | protected function init_user_info() { |
| 256 | 246 | if ( isset( $this->entry->description ) ) { |
| 257 | 247 | $entry_description = (array) $this->entry->description; |
| @@ -261,32 +251,23 @@ | ||
| 261 | 251 | 'referrer' => '', |
| 262 | 252 | ); |
| 263 | 253 | } |
| 264 | 254 | |
| 265 | - $ip = array( | |
| 255 | + $ip = array( | |
| 266 | 256 | 'label' => __( 'IP Address', 'formidable' ), |
| 267 | 257 | 'value' => $this->entry->ip, |
| 268 | 258 | ); |
| 269 | - $browser = array( | |
| 259 | + | |
| 260 | + $browser = array( | |
| 270 | 261 | 'label' => __( 'User-Agent (Browser/OS)', 'formidable' ), |
| 271 | - 'value' => isset( $entry_description['browser'] ) ? FrmEntriesHelper::get_browser( $entry_description['browser'] ) : '', | |
| 262 | + 'value' => FrmEntriesHelper::get_browser( $entry_description['browser'] ), | |
| 272 | 263 | ); |
| 264 | + | |
| 273 | 265 | $referrer = array( |
| 274 | 266 | 'label' => __( 'Referrer', 'formidable' ), |
| 275 | - 'value' => $entry_description['referrer'] ?? '', | |
| 267 | + 'value' => $entry_description['referrer'], | |
| 276 | 268 | ); |
| 277 | 269 | |
| 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 | 270 | $this->user_info = array( |
| 290 | 271 | 'ip' => $ip, |
| 291 | 272 | 'browser' => $browser, |
| 292 | 273 | 'referrer' => $referrer, |
| @@ -334,9 +315,9 @@ | ||
| 334 | 315 | * |
| 335 | 316 | * @since 2.04 |
| 336 | 317 | * |
| 337 | 318 | * @param stdClass $field |
| 338 | - * @param array $array | |
| 319 | + * @param array $array | |
| 339 | 320 | * |
| 340 | 321 | * @return bool |
| 341 | 322 | */ |
| 342 | 323 | protected function is_field_in_array( $field, $array ) { |
| @@ -348,10 +329,8 @@ | ||
| 348 | 329 | * |
| 349 | 330 | * @since 2.04 |
| 350 | 331 | * |
| 351 | 332 | * @param stdClass $field |
| 352 | - * | |
| 353 | - * @return void | |
| 354 | 333 | */ |
| 355 | 334 | protected function add_field_values( $field ) { |
| 356 | 335 | $this->field_values[ $field->id ] = new FrmFieldValue( $field, $this->entry ); |
| 357 | 336 | } |