From f5c31c23fb6e9f97cba0d9c8725a8c2a5706b535 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 7 Dec 2020 11:58:09 -0800 Subject: [PATCH 1/2] Eliminate redundant legacy method of adding Schema.org metadata --- includes/amp-post-template-functions.php | 1 - 1 file changed, 1 deletion(-) 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' ); From 769546fdcd65dfd252926fd71407683c883d3a64 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 7 Dec 2020 15:20:54 -0800 Subject: [PATCH 2/2] Add test for amp_print_schemaorg_metadata() --- tests/php/test-amp-helper-functions.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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( '', $output ); + } + /** * Test amp_add_admin_bar_view_link() *