Skip to content

Commit 99915e9

Browse files
committed
Omit AMP status from classic post editor when post type not supported
1 parent 97f37d0 commit 99915e9

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

includes/admin/class-amp-post-meta-box.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ public function enqueue_admin_assets() {
146146
$validate = (
147147
isset( $screen->base ) &&
148148
'post' === $screen->base &&
149-
( ! isset( $screen->is_block_editor ) || ! $screen->is_block_editor ) &&
150-
in_array( $post->post_type, AMP_Post_Type_Support::get_eligible_post_types(), true )
149+
empty( $screen->is_block_editor ) &&
150+
in_array( $post->post_type, AMP_Post_Type_Support::get_supported_post_types(), true )
151151
);
152152

153153
if ( ! $validate ) {
@@ -344,7 +344,7 @@ public function render_status( $post ) {
344344
$verify = (
345345
isset( $post->ID )
346346
&&
347-
in_array( $post->post_type, AMP_Post_Type_Support::get_eligible_post_types(), true )
347+
in_array( $post->post_type, AMP_Post_Type_Support::get_supported_post_types(), true )
348348
&&
349349
current_user_can( 'edit_post', $post->ID )
350350
);

tests/php/test-class-amp-meta-box.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,16 +284,11 @@ public function test_render_status() {
284284
$this->assertStringContainsString( $no_support_notice, $output );
285285
}
286286

287-
// Post type no longer supports AMP, so no status input.
287+
// Post type no longer supports AMP, so no status input (and no mention of AMP at all).
288288
$supported_post_types = array_diff( AMP_Options_Manager::get_option( Option::SUPPORTED_POST_TYPES ), [ 'post' ] );
289289
AMP_Options_Manager::update_option( Option::SUPPORTED_POST_TYPES, $supported_post_types );
290290
$output = get_echo( [ $this->instance, 'render_status' ], [ $post ] );
291-
if ( Services::get( 'dependency_support' )->has_support_from_core() ) {
292-
$this->assertStringContainsString( 'This post type is not', $output );
293-
$this->assertStringNotContainsString( $checkbox_enabled, $output );
294-
} else {
295-
$this->assertStringContainsString( $no_support_notice, $output );
296-
}
291+
$this->assertEmpty( $output );
297292
$supported_post_types[] = 'post';
298293
AMP_Options_Manager::update_option( Option::SUPPORTED_POST_TYPES, $supported_post_types );
299294

0 commit comments

Comments
 (0)