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 themes to provide alternate templates in “paired mode” #849

Closed
5 tasks done
ThierryA opened this issue Jan 9, 2018 · 0 comments
Closed
5 tasks done

Allow themes to provide alternate templates in “paired mode” #849

ThierryA opened this issue Jan 9, 2018 · 0 comments
Milestone

Comments

@ThierryA
Copy link
Collaborator

ThierryA commented Jan 9, 2018

Acceptance Criteria

AC1: Using “paired mode,” themes can specify an alternative path to use for AMP templates (see @westonruter’s comment proposed).
AC2: When themes do this, the templates in that directory will replace the entire “paired mode” template system in the plugin. The AMP toggle developed in 0.6 will continue to be available in this mode.

Tasks

  • Add theme support property to indicate path to paired-mode templates, for the theme root, where the template hierarchy will be evaluated. This may be called theme_root or template_directory or template_path or something else that makes the most sense.
  • And add callback function which is used to determine whether a given request should be routed to the paired mode. Have default logic that tries to identify the template for a given request and if it is is present, then make AMP available. Otherwise, don’t make it available. For example, if requesting a single page, but there is no page.php or index.php in the AMP template root, then AMP would not be available by default.
  • Update amp_prepare_render() to prevent calling add_action( 'template_redirect', 'amp_render' ); when current_theme_supports( 'amp' ), as we need to not use amp_render() since it uses the old paired-mode theme system; instead, this function should do whatever is required (e.g. add template_include filter), per the next task (implement template hierarchy).
  • Implement the same template hierarchy resolution logic, ideally re-use what is in core. Figure out how to make use of the custom theme root for AMP templates.
  • Continue outputting the AMP rel link in head for non-AMP templates and other things that happen in current paired mode. And also include relevant links in head for AMP templates. Toggle what is output in wp_head based on whether it is an AMP response or not.
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

3 participants