Amp_Template_Override::override_template_path( string $path, string $relative_path )
Summary
No summary available.Parameters
- $path
-
(string) (Required) The absolute path to the template
- $relative_path
-
(string) (Required) The relative path of the requested template
Return
(string) The filtered path to the template
Source
File: src/BigCommerce/Amp/Amp_Template_Override.php
public function override_template_path( $path, $relative_path ) { /* * If we're not using AMP classic and are using paired/native instead, * then we should only override `components/*` templates. All the other * templates (i.e. single product, archive etc) will be rendered from * the main WP theme template and thus we should not override that. */ if ( ! $this->is_classic() && ! strpos( $path, 'components' ) ) { return $path; } $amp_path = ''; $amp_relative_path = trailingslashit( $this->amp_directory ) . $relative_path; /** * This filter is documented in src/BigCommerce/Templates/Controller.php */ $theme_dir = apply_filters( 'bigcommerce/template/directory/theme', '', $amp_relative_path ); /** * This filter is documented in src/BigCommerce/Templates/Controller.php */ $plugin_dir = apply_filters( 'bigcommerce/template/directory/plugin', '', $amp_relative_path ); if ( ! empty( $theme_dir ) ) { $amp_path = locate_template( trailingslashit( $theme_dir ) . $amp_relative_path ); } // no template in the theme, so fall back to the plugin default if ( empty( $amp_path ) && ! empty( $plugin_dir ) ) { $amp_path = trailingslashit( $plugin_dir ) . $amp_relative_path; } // check that we actually have an AMP override for this template if ( ! empty( $amp_path ) && file_exists( $amp_path ) ) { $path = $amp_path; } return $path; }