Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow absolute paths for template_dir when adding amp theme support #1204

Closed
westonruter opened this issue Jun 7, 2018 · 1 comment
Closed

Comments

@westonruter
Copy link
Member

If you currently add amp theme support for paired mode via:

add_theme_support( 'amp', array(
	'template_dir' => get_template_directory(),
) );

Then it will fail to find the template dir since it is expecting relative paths, it will redirect to the non-AMP version with this code:

https://github.com/Automattic/amp-wp/blob/5f635d27d64f50eeba4c0710c84d929342f967b5/includes/class-amp-theme-support.php#L675-L690

Instead, you currently have to do:

add_theme_support( 'amp', array(
	'template_dir' => './',
) );

This isn't totally intuitive. (Aside: indicating paired mode with template_dir is also not intuitive. For that, see #934.)

@westonruter westonruter added this to the v1.0 milestone Jun 7, 2018
@westonruter westonruter removed the beta label Jun 21, 2018
@westonruter westonruter removed this from the v1.0 milestone Jun 21, 2018
@westonruter
Copy link
Member Author

On second thought, let's not do this. The template_dir is prepended to the currently-queried template file (e.g. single.php) and it is then passed into locate_template() which does not allow absolute paths. With #934 a theme will be able to opt-in to paired mode without having to do a pointless 'template_dir' => './' via a proposed extension to what the available_callback returns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants