-
Notifications
You must be signed in to change notification settings - Fork 385
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
Incompatibility with Polylang's language taxonomy #1786
Comments
Did this result in |
Possibly-related forum topic: https://wordpress.org/support/topic/referenced-amp-url-is-not-an-amp-8/#post-11816408 |
It's been a while; I would have to test it again. But if I recall correctly, I was still able to access the AMP pages. There simply was a notice. |
AMP pages work fine but only when slug ID or name is visible (this box is unticked). Another user with the same issue: |
@jamesozzie I've added this to the current project board to prioritize fixing this for the next release. |
It seems that the check for |
But doesn't diff --git a/includes/class-amp-theme-support.php b/includes/class-amp-theme-support.php
index e02cf242..d620f355 100644
--- a/includes/class-amp-theme-support.php
+++ b/includes/class-amp-theme-support.php
@@ -892,8 +892,8 @@ class AMP_Theme_Support {
}
$taxonomy_args = [
- '_builtin' => false,
- 'publicly_queryable' => true,
+ '_builtin' => false,
+ 'public' => true,
];
foreach ( get_taxonomies( $taxonomy_args, 'objects' ) as $taxonomy ) {
$templates[ sprintf( 'is_tax[%s]', $taxonomy->name ) ] = [ However, perhaps it is only fixing the symptom and not the root cause? I'm getting this specific notice:
Here: amp-wp/includes/class-amp-theme-support.php Line 689 in 75674df
I get this when I go to a URL like For my environment, {
"is_singular": {
"label": "Singular",
"description": "Required for the above content types.",
"user_supported": true,
"immutable": false,
"supported": true
},
"is_front_page": {
"label": "Homepage",
"parent": "is_singular",
"user_supported": false,
"immutable": false,
"supported": true
},
"is_home": {
"label": "Blog",
"user_supported": false,
"immutable": false,
"supported": true
},
"is_archive": {
"label": "Archives",
"user_supported": false,
"immutable": false,
"supported": true
},
"is_author": {
"label": "Author",
"parent": "is_archive",
"user_supported": false,
"immutable": false,
"supported": true
},
"is_date": {
"label": "Date",
"parent": "is_archive",
"user_supported": false,
"immutable": false,
"supported": true
},
"is_search": {
"label": "Search",
"user_supported": false,
"immutable": false,
"supported": true
},
"is_404": {
"label": "Not Found (404)",
"user_supported": false,
"immutable": false,
"supported": true
},
"is_category": {
"label": "Categor\u00edas",
"parent": "is_archive",
"user_supported": false,
"immutable": false,
"supported": true
},
"is_tag": {
"label": "Etiquetas",
"parent": "is_archive",
"user_supported": false,
"immutable": false,
"supported": true
},
"is_tax[language]": {
"label": "Languages",
"parent": "is_archive",
"callback": {},
"user_supported": false,
"immutable": false,
"supported": true
}
} The issue seems to be that amp-wp/includes/class-amp-theme-support.php Lines 667 to 671 in 75674df
Apparently the logic in #1235 is not properly accounting for the template hierarchy, perhaps here due to the fact that A related issue that may serve as inspiration here is #1938. |
I currently fail to replicate this. I tried to verify the box mentioned in #1786 (comment) , but I don't have that one in my version. What version of the Polylang plugin are you running? I'm trying to replicate with version 2.6.4... |
@schlessera If you set your homepage to a static page that option should appear. |
@jamesozzie Yes, that does indeed display the missing check box. However, no matter what settings I use, I'm still unable to trigger a notice. I'm monitoring the PHP error log, and I tried trigger an Maybe I'm misunderstanding the ticket and looking in the wrong place, so I'll recount what I tried to get a notice:
|
@swissspidy Are you able to replicate this? Do you have any pointers for me in that regard? |
Could finally replicate the notice. This is the one I'm geeting:
|
Excellent. Same as I was getting in #1786 (comment). |
I think the root cause of the notice is that for The reason why the As the Following is an overview of the three different ways I think this might be solved, and what that entails. 1.) Harden the logic that removes the parent templates to gracefully the case where a parent template is not found in the 2.) Change the query arguments from 3.) Do both the changes in 1.) & 2.) but adapt 1.) to throw a 4.) Engage with the Polylang developers to discuss the rewrite rules that the plugin uses, as the URL that causes this issue is not actually a taxonomy archive page. I would suggest going with option 3.) as the conceptually most correct change. We can still do 4.) in parallel, but we can immediately solve the problem on our end at least with 3.). @westonruter, @swissspidy Thoughts? |
@schlessera Excellent research and suggestions. Going with 3 seems good to me. What is the impact going to be in the admin screen with that change? Is it the case that the Polylang taxonomy currently is being listed among the checkboxes, but with the change it will now be removed? Thinking about it, it doesn't seem to make sense for a user to ever land on archive template with the queried object being the Polylang language taxonomy. Is that even the behavior of Polylang presently? If I have English and Spanish on my site, then it doesn't make sense for me to access Spanish, as rather Polylang should be routing the queried object to the translated entity rather than the language term itself. If not, then it indeed doesn't make sense for the taxonomy to be listed among the supportable templates. |
Yes, it would be removed. And I agree, it doesn't make sense to land on that template, I think it is an issue with the rewrite rules from Polylang not catching this properly. I'll go ahead with implementing 3.) then. |
Testing Instructions:
|
Hi @schlessera - FE is fine - ok for me to move to Ready To Merge? Any logs you need to check first? |
I installed Polylang on a site where I try to add AMP support in the theme. This mostly means a bunch of
is_amp_endpoint()
checks.I've set up two languages, but haven't really done anything with them yet.
Now when I navigate to
/page/2/?amp
,is_amp_endpoint()
ultimately calls\AMP_Theme_Support::get_template_availability
which in turn calls\AMP_Theme_Support::get_supportable_templates()
.Also in the list of supportable templates is the
language
taxonomy added by Polylang. This is because the AMP plugin only checks forpublicly_queryable
, notpublic
. The taxonomy is queryable though, just not public.This leads to a PHP notice in this part of the code:
amp-wp/includes/class-amp-theme-support.php
Lines 533 to 544 in 19f1f24
The text was updated successfully, but these errors were encountered: