Skip to content

Commit

Permalink
Update name template_path to template_dir when it comes to custom pai…
Browse files Browse the repository at this point in the history
…red mode templates to match AMP_Post_Template naming.
  • Loading branch information
kaitnyl committed Jan 15, 2018
1 parent e5b5490 commit 6285f9f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions amp.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ function amp_maybe_add_actions() {
* Themes can register support for this with `add_theme_support( 'amp' )`.
* Then, this will change the plugin from 'paired mode,' and it won't use its own templates.
* Nor output frontend markup like the 'rel' link. If the theme registers support for AMP with:
* `add_theme_support( 'amp', array( 'template_path' => get_template_directory() . 'my-amp-templates/' ) )`
* `add_theme_support( 'amp', array( 'template_dir' => 'my-amp-templates' ) )`
* it will retain 'paired mode.
*
* @return boolean Whether this is in AMP 'canonical mode'.
Expand All @@ -184,7 +184,7 @@ function amp_is_canonical() {
}
if ( is_array( $support ) ) {
$args = array_shift( $support );
if ( empty( $args['template_path'] ) ) {
if ( empty( $args['template_dir'] ) ) {
return true;
}
}
Expand Down
10 changes: 5 additions & 5 deletions includes/class-amp-theme-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static function init() {
* Determines whether paired mode is available.
*
* When 'amp' theme support has not been added or canonical mode is enabled, then this returns false.
* Returns true when there is a template_path defined in theme support, and if a defined active_callback
* Returns true when there is a template_dir defined in theme support, and if a defined active_callback
* returns true.
*
* @return bool Whether available.
Expand Down Expand Up @@ -133,7 +133,7 @@ public static function register_hooks() {
}

/**
* Prepends template hierarchy with template_path for AMP paired mode templates.
* Prepends template hierarchy with template_dir for AMP paired mode templates.
*
* @see get_query_template()
*
Expand All @@ -143,10 +143,10 @@ public static function register_hooks() {
public static function filter_paired_template_hierarchy( $templates ) {
$support = get_theme_support( 'amp' );
$args = array_shift( $support );
if ( isset( $args['template_path'] ) ) {
if ( isset( $args['template_dir'] ) ) {
$amp_templates = array();
foreach ( $templates as $template ) {
$amp_templates[] = $args['template_path'] . '/' . $template;
$amp_templates[] = $args['template_dir'] . '/' . $template;
}
$templates = $amp_templates;
}
Expand All @@ -156,7 +156,7 @@ public static function filter_paired_template_hierarchy( $templates ) {
/**
* Redirect to the non-canonical URL when the template to include is empty.
*
* This is a failsafe in case an index.php is not located in the AMP template_path,
* This is a failsafe in case an index.php is not located in the AMP template_dir,
* and the active_callback fails to omit a given request from being available in AMP.
*
* @param string $template Template to include.
Expand Down

0 comments on commit 6285f9f

Please sign in to comment.