ClassesBigCommerceAmpAmp Template Override

Amp_Template_Override

Class Amp_Template_Override

Responsible for overriding template paths to provide AMP-specific versions when AMP mode is enabled.

  • Full name: \BigCommerce\Amp\Amp_Template_Override

Methods

__construct

Constructor for the Amp_Template_Override class.

public __construct(string $amp_directory = 'amp'): mixed

Parameters:

ParameterTypeDescription
$amp_directorystringName of the directory containing AMP template overrides. Default is ‘amp’.

override_template_path

Filters the path to a requested template, providing AMP-specific versions if available.

public override_template_path(string $path, string $relative_path): string

Parameters:

ParameterTypeDescription
$pathstringThe absolute path to the requested template.
$relative_pathstringThe relative path of the template within the theme/plugin.

Return Value:

The filtered template path, modified for AMP if applicable.


override_classic_amp_template_path

Overrides template paths for classic AMP templates.

public override_classic_amp_template_path(string $file, string $template_type, \WP_Post $post): string

Parameters:

ParameterTypeDescription
$filestringThe absolute path to the AMP template.
$template_typestringThe type of template being served (e.g., single, archive).
$post\WP_PostThe current post object.

Return Value:

The overridden template path.


override_classic_header_bar_template

Overrides the header bar template for AMP classic mode.

public override_classic_header_bar_template(string $file, string $type, array $container): string

Parameters:

ParameterTypeDescription
$filestringTemplate file path.
$typestringTemplate type (e.g., ‘header-bar’).
$containerarray\BigCommerce\Container\Amp

Return Value:

The overridden template file path.


is_classic

Determines whether AMP is in classic mode.

public is_classic(): bool

Classic mode renders AMP templates for all pages, while paired/native mode only renders AMP templates for specific components.

Return Value:

True if classic mode is enabled; false otherwise.


provide_header_nav_menu

Provides the header navigation menu data in AMP classic mode.

public provide_header_nav_menu(array $data): array

Parameters:

ParameterTypeDescription
$dataarrayAMP template data.

Return Value:

Filtered data with header_nav_menu included.



Automatically generated on 2025-01-21