Description
Feature Description
As noted in #6881 (comment):
the only post types that are eligible for being AMP-enabled are those which have
'public' => true
:amp-wp/includes/class-amp-post-type-support.php
Lines 44 to 64 in 36edf69
It's true that a post type could have
public
set to true but havepublicly_queryable
set to false, I think, and in that case it may be possible that we could accidentally show or hide the preview button. It would be marginally better to here instead do the following since there is now ais_post_type_viewable
filter in WP 5.9:diff --git a/includes/class-amp-post-type-support.php b/includes/class-amp-post-type-support.php index 3d4560641..17eb6519b 100644 --- a/includes/class-amp-post-type-support.php +++ b/includes/class-amp-post-type-support.php @@ -42,14 +42,9 @@ public static function get_builtin_supported_post_types() { * @return string[] Post types eligible for AMP. */ public static function get_eligible_post_types() { - $post_types = array_values( - get_post_types( - [ - 'public' => true, - ], - 'names' - ) - ); + $post_types = array_values( get_post_types( [], 'names' ) ); + + $post_types = array_filter( $post_types, 'is_post_type_viewable' ); /** * Filters the list of post types which may be supported for AMP.
Acceptance Criteria
Only post types for which is_post_type_viewable()
returns true
should be listed among the post types for which AMP can be enabled. Only these post types should have an AMP preview button shown in a paired AMP mode (transitional or reader).
Implementation Brief
No response
QA Testing Instructions
No response
Demo
No response
Changelog Entry
No response