| @@ -155,9 +155,9 @@ | ||
| 155 | 155 | * Stores above-fold image data for a specific profile ID and device type. |
| 156 | 156 | * |
| 157 | 157 | * @param string $id The profile ID. |
| 158 | 158 | * @param int $device_type The device type constant. |
| 159 | - * @param array<string> $above_fold_images Array of above-fold images. | |
| 159 | + * @param array<int|string> $above_fold_images Array of above-fold image ids. | |
| 160 | 160 | * @param array<string, array<string, array<int, string>>> $af_bg_selectors Array of above-fold background selectors. |
| 161 | 161 | * Array structure: |
| 162 | 162 | * [ |
| 163 | 163 | * 'css_selector' => [ |
| @@ -383,9 +383,9 @@ | ||
| 383 | 383 | * @return bool True if the LCP image is in the viewport of all device types, false otherwise. |
| 384 | 384 | */ |
| 385 | 385 | public function is_lcp_image_in_all_viewports( int $image_id ): bool { |
| 386 | 386 | foreach ( self::get_active_devices() as $device ) { |
| 387 | - if ( ( ( self::$current_profile_data[ $device ]['lcp']['type'] ?? '' ) === 'img' ) && ( self::$current_profile_data[ $device ]['lcp']['imageId'] === $image_id ) ) { | |
| 387 | + if ( ( ( self::$current_profile_data[ $device ]['lcp']['type'] ?? '' ) === 'img' ) && ( ( self::$current_profile_data[ $device ]['lcp']['imageId'] ?? null ) === $image_id ) ) { | |
| 388 | 388 | return true; |
| 389 | 389 | } |
| 390 | 390 | } |
| 391 | 391 | |
| @@ -481,9 +481,9 @@ | ||
| 481 | 481 | |
| 482 | 482 | // Add device-specific metrics |
| 483 | 483 | foreach ( $profile_data as $device_type => $device_data ) { |
| 484 | 484 | $device_name = $this->get_device_name( $device_type ); |
| 485 | - $comment_parts[] = 'measurement#device-' . $device_name . '#' . json_encode( $device_data ); | |
| 485 | + $comment_parts[] = 'measurement#device-' . $device_name . '#' . json_encode( $device_data, JSON_HEX_TAG | JSON_HEX_AMP ); | |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | return '<!-- ' . implode( ' ', $comment_parts ) . ' -->'; |
| 489 | 489 | } |