class-od-bridge.php

Optimization Detective (OD) bridge.

Source includes/Insight/class-od-bridge.php5 min readPart of Performance Optimisation

includes/Insight/class-od-bridge.php

Optimization Detective (OD) bridge.

Namespace: PerformanceOptimise\\Inc · Lines: 1508

Class OD_Bridge

Optimization Detective bridge.

Source: includes/Insight/class-od-bridge.php, line 30

class OD_Bridge

Tags: @since 2.0.0

Constants

ConstantVisibilityValueLine
SETTINGS_KEYpublic\'od_integration\'39
FILTER_SHOULD_OPTIMIZEpublic\'wppo_od_should_optimize\'48

Properties

PropertyVisibilityTypeDefaultLine
$request_memoprivate staticarrayarray()67

publicstatic clear_request_memo()

public static function clear_request_memo(): void

Reset the per-request OD memo.

Return: void.

Tags: @since 2.2.0

Source: includes/Insight/class-od-bridge.php, line 78

privatestatic request_memo_key()

private static function request_memo_key(string $prefix): string

Memo key for the current URL with the given prefix.

ParameterTypeDefaultDescription
$prefixstring—Memo namespace prefix.

Return: string — Memo key.

Tags: @since 2.2.0

Source: includes/Insight/class-od-bridge.php, line 91

privatestatic request_memo_set()

private static function request_memo_set(string $key, $value): void

Store a memo value, bounding the map.

ParameterTypeDefaultDescription
$keystring—Memo key.
$valuemixed—Memo value.

Return: void.

Tags: @since 2.2.0

Source: includes/Insight/class-od-bridge.php, line 112

privatestatic debug_log()

private static function debug_log(string $message): void

Log a Throwable diagnostic to the server error log when WP_DEBUG is on.

ParameterTypeDefaultDescription
$messagestring—Message to log.

Return: void.

Tags: @since 2.0.0

Source: includes/Insight/class-od-bridge.php, line 130

publicstatic is_od_available()

public static function is_od_available(): bool

Whether the Optimization Detective plugin is available.

Return: bool — True when OD is active.

Tags: @since 2.0.0

Source: includes/Insight/class-od-bridge.php, line 149

publicstatic is_enabled()

public static function is_enabled(): bool

Whether OD optimization is enabled for the current request.

Return: bool — True when OD data should be consumed.

Tags: @since 2.0.0

Source: includes/Insight/class-od-bridge.php, line 163

publicstatic get_lcp_url()

public static function get_lcp_url(): string

Get the LCP image URL from OD viewport groups.

Return: string — LCP image URL or empty string.

Tags: @since 2.0.0

Source: includes/Insight/class-od-bridge.php, line 233

publicstatic get_stable_lcp_url()

public static function get_stable_lcp_url(): string

Get the stable LCP image URL from OD viewport groups.

Return: string — Stable LCP image URL or empty string.

Tags: @since 2.2.0

Source: includes/Insight/class-od-bridge.php, line 295

publicstatic get_exclude_first_images_count()

public static function get_exclude_first_images_count(): int

Get the lazy-load threshold (excludeFirstImages) from OD data.

Return: int — Number of first images to exclude, 1-3.

Tags: @since 2.0.0

Source: includes/Insight/class-od-bridge.php, line 378

privatestatic collect_lcp_urls()

private static function collect_lcp_urls(): array

Collect distinct LCP URLs from OD metrics.

Return: string[] — Distinct LCP image URLs.

Tags: @since 2.0.0

Source: includes/Insight/class-od-bridge.php, line 437

privatestatic collect_raw_lcp_urls()

private static function collect_raw_lcp_urls(): array

Collect raw (non-deduplicated) LCP URLs from OD metrics.

Return: string[] — Raw LCP image URLs (may contain duplicates).

Tags: @since 2.0.0

Source: includes/Insight/class-od-bridge.php, line 454

privatestatic count_viewport_groups()

private static function count_viewport_groups(): int

Count viewport groups from OD data.

Return: int — Number of viewport groups (0 when unavailable).

Tags: @since 2.0.0

Source: includes/Insight/class-od-bridge.php, line 577

publicstatic get_occluded_image_urls()

public static function get_occluded_image_urls(): array

Get normalized occluded image URLs for the current URL.

Return: string[] — Normalized occluded image URLs (may be empty).

Tags: @since 2.3.0

Source: includes/Insight/class-od-bridge.php, line 671

privatestatic element_is_occluded()

private static function element_is_occluded($element): bool

Whether an OD element is occluded (hidden but in-viewport).

ParameterTypeDefaultDescription
$elementmixed—Element object or array.

Return: bool — True when occluded.

Tags: @since 2.3.0

Source: includes/Insight/class-od-bridge.php, line 790

privatestatic element_geometry_is_occluded()

private static function element_geometry_is_occluded(array $data): bool

Geometry fallback for occlusion detection.

ParameterTypeDefaultDescription
$dataarray—Element data as an array.

Return: bool — True when geometry implies occlusion.

Tags: @since 2.3.0

Source: includes/Insight/class-od-bridge.php, line 887

publicstatic get_breakpoint_lcp_elements()

public static function get_breakpoint_lcp_elements(): array

Get per-breakpoint LCP element detail for responsive preloads.

Return: array<int, — array{url: string, srcset: string, sizes: string, media: string, type: string}> Breakpoint LCP entries.

Tags: @since 2.3.0

Source: includes/Insight/class-od-bridge.php, line 947

privatestatic collect_lcp_elements_from_metric()

private static function collect_lcp_elements_from_metric($metric): array

Collect LCP elements (not just URLs) from a single OD metric.

ParameterTypeDefaultDescription
$metricmixed—Single OD metric object or array.

Return: array — List of LCP elements.

Tags: @since 2.3.0

Source: includes/Insight/class-od-bridge.php, line 1014

privatestatic extract_element_attr()

private static function extract_element_attr($element, string $name): string

Extract a string attribute from an OD element (method → property → array).

ParameterTypeDefaultDescription
$elementmixed—Element object or array.
$namestring—Attribute name (e.g. \’srcset\’).

Return: string — Attribute value or empty string.

Tags: @since 2.3.0

Source: includes/Insight/class-od-bridge.php, line 1086

privatestatic extract_srcset_from_element()

private static function extract_srcset_from_element($element): string

Extract the srcset value from an OD element.

ParameterTypeDefaultDescription
$elementmixed—Element object or array.

Return: string — Srcset value or empty string.

Tags: @since 2.3.0

Source: includes/Insight/class-od-bridge.php, line 1165

privatestatic extract_sizes_from_element()

private static function extract_sizes_from_element($element): string

Extract the sizes value from an OD element.

ParameterTypeDefaultDescription
$elementmixed—Element object or array.

Return: string — Sizes value or empty string.

Tags: @since 2.3.0

Source: includes/Insight/class-od-bridge.php, line 1176

privatestatic extract_media_from_element()

private static function extract_media_from_element($element): string

Extract the media value from an OD element.

ParameterTypeDefaultDescription
$elementmixed—Element object or array.

Return: string — Media value or empty string.

Tags: @since 2.3.0

Source: includes/Insight/class-od-bridge.php, line 1190

privatestatic extract_type_from_element()

private static function extract_type_from_element($element): string

Extract the LCP element type for per-type preload coverage.

ParameterTypeDefaultDescription
$elementmixed—Element object or array.

Return: string — Element type.

Tags: @since 2.3.0

Source: includes/Insight/class-od-bridge.php, line 1207

privatestatic get_url_metrics()

private static function get_url_metrics(): array

Retrieve URL metrics via the OD API.

Return: array — List of metric objects/arrays.

Tags: @since 2.0.0

Source: includes/Insight/class-od-bridge.php, line 1262

privatestatic element_is_lcp()

private static function element_is_lcp($element): bool

Whether an OD element is the LCP element.

ParameterTypeDefaultDescription
$elementmixed—Element object or array.

Return: bool — True when LCP.

Tags: @since 2.0.0

Source: includes/Insight/class-od-bridge.php, line 1335

privatestatic extract_url_from_element()

private static function extract_url_from_element($element): string

Extract an image URL from an OD element.

ParameterTypeDefaultDescription
$elementmixed—Element object or array.

Return: string — URL or empty string.

Tags: @since 2.0.0

Source: includes/Insight/class-od-bridge.php, line 1402