ClassesBigCommerceAmpOverrides

Overrides

Class Overrides

Provides custom AMP-specific overrides and modifications, including handling image sources, enabling AMP buttons, and defining allowed HTML tags for AMP templates.

  • Full name: \BigCommerce\Amp\Overrides

Methods

add_amp_img_src

Add AMP image source.

public add_amp_img_src(array $data, string $template): array

Adds image_src and image_srcset to the data passed to the product featured image template for AMP compatibility.

Parameters:

ParameterTypeDescription
$dataarrayData to be sent to the template.
$templatestringCurrent template being rendered.

Return Value:

Modified data array.


amp_enable_button

Enable AMP button.

public amp_enable_button(string $button, int $post_id): string

Dynamically enables the AMP submit button when a proper product variant is selected.

Parameters:

ParameterTypeDescription
$buttonstringOriginal button HTML.
$post_idintID of the current post or product.

Return Value:

Modified button HTML.


add_amp_redirect_headers

Add AMP redirect headers.

public add_amp_redirect_headers(string $url): void

Adds necessary headers for AMP redirects and ensures proper URL formatting.

Parameters:

ParameterTypeDescription
$urlstringThe URL to redirect to.

filter_fallback_image

Filter fallback image for AMP.

public filter_fallback_image(): string

Returns a formatted AMP-compliant image placeholder.

Return Value:

AMP-compliant <amp-img> HTML for the fallback image.


amp_kses_allowed_html

Customize allowed HTML tags for AMP context.

public amp_kses_allowed_html(array $allowed_tags, string $context): array

Parameters:

ParameterTypeDescription
$allowed_tagsarrayArray of allowed HTML tags.
$contextstringContext for filtering.

Return Value:

Modified array of allowed tags.



Automatically generated on 2025-01-21