diff --git a/includes/admin/class-amp-post-meta-box.php b/includes/admin/class-amp-post-meta-box.php index 8747467878f..3981c44529d 100644 --- a/includes/admin/class-amp-post-meta-box.php +++ b/includes/admin/class-amp-post-meta-box.php @@ -184,20 +184,17 @@ public function render_status( $post ) { return; } - $errors = AMP_Post_Type_Support::get_support_errors( $post ); - $status = empty( $errors ) ? self::ENABLED_STATUS : self::DISABLED_STATUS; - $errors = array_diff( $errors, array( 'post-status-disabled' ) ); // Subtract the status which the metabox will allow to be toggled. - - // Handle special case of the static front page or page for posts. if ( current_theme_supports( 'amp' ) ) { $availability = AMP_Theme_Support::get_template_availability( $post ); + $status = $availability['supported'] ? self::ENABLED_STATUS : self::DISABLED_STATUS; + $errors = array_diff( $availability['errors'], array( 'post-status-disabled' ) ); // Subtract the status which the metabox will allow to be toggled. if ( true === $availability['immutable'] ) { $errors[] = 'status_immutable'; - $status = $availability['supported'] ? self::ENABLED_STATUS : self::DISABLED_STATUS; - } elseif ( ! $availability['supported'] && in_array( 'template_unsupported', $availability['errors'], true ) ) { - $errors[] = 'template_unsupported'; - $status = self::DISABLED_STATUS; } + } else { + $errors = AMP_Post_Type_Support::get_support_errors( $post ); + $status = empty( $errors ) ? self::ENABLED_STATUS : self::DISABLED_STATUS; + $errors = array_diff( $errors, array( 'post-status-disabled' ) ); // Subtract the status which the metabox will allow to be toggled. } $labels = array( diff --git a/tests/test-amp-helper-functions.php b/tests/test-amp-helper-functions.php index d7391910cfd..290660ba1ce 100644 --- a/tests/test-amp-helper-functions.php +++ b/tests/test-amp-helper-functions.php @@ -316,6 +316,7 @@ public function test_amp_add_amphtml_link( $canonical_url, $amphtml_url ) { * @covers \is_amp_endpoint() */ public function test_is_amp_endpoint() { + $this->go_to( get_permalink( $this->factory()->post->create() ) ); $this->assertFalse( is_amp_endpoint() ); // Legacy query var.