diff --git a/includes/amp-post-template-functions.php b/includes/amp-post-template-functions.php index 1373bc9bba8..bf19274a69c 100644 --- a/includes/amp-post-template-functions.php +++ b/includes/amp-post-template-functions.php @@ -15,7 +15,6 @@ function amp_post_template_init_hooks() { add_action( 'amp_post_template_head', 'amp_post_template_add_title' ); add_action( 'amp_post_template_head', 'amp_post_template_add_canonical' ); add_action( 'amp_post_template_head', 'amp_post_template_add_fonts' ); - add_action( 'amp_post_template_head', 'amp_print_schemaorg_metadata' ); add_action( 'amp_post_template_head', 'amp_add_generator_metadata' ); add_action( 'amp_post_template_head', 'wp_generator' ); add_action( 'amp_post_template_head', 'amp_post_template_add_block_styles' ); diff --git a/tests/php/test-amp-helper-functions.php b/tests/php/test-amp-helper-functions.php index 0c610a7dbbd..dd2e32c3b66 100644 --- a/tests/php/test-amp-helper-functions.php +++ b/tests/php/test-amp-helper-functions.php @@ -1728,6 +1728,27 @@ static function( $meta ) use ( $self ) { $this->assertEquals( $metadata['publisher']['logo']['url'], amp_get_publisher_logo() ); } + /** + * Test amp_print_schemaorg_metadata(). + * + * @covers ::amp_print_schemaorg_metadata() + */ + public function test_amp_print_schemaorg_metadata() { + add_filter( 'amp_schemaorg_metadata', '__return_empty_array' ); + $output = get_echo( 'amp_print_schemaorg_metadata' ); + $this->assertEmpty( $output ); + + remove_filter( 'amp_schemaorg_metadata', '__return_empty_array' ); + add_filter( + 'amp_schemaorg_metadata', + static function () { + return [ 'foo' => 'bar' ]; + } + ); + $output = trim( get_echo( 'amp_print_schemaorg_metadata' ) ); + $this->assertSame( '<script type="application/ld+json">{"foo":"bar"}</script>', $output ); + } + /** * Test amp_add_admin_bar_view_link() *