Skip to content

Commit

Permalink
Merge pull request #5663 from ampproject/remove/legacy-reader-schema-…
Browse files Browse the repository at this point in the history
…meta

Eliminate redundant legacy method of adding Schema.org metadata
  • Loading branch information
westonruter authored Dec 8, 2020
2 parents b6d53fc + 769546f commit 85f53e6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
1 change: 0 additions & 1 deletion includes/amp-post-template-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down
21 changes: 21 additions & 0 deletions tests/php/test-amp-helper-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
*
Expand Down

0 comments on commit 85f53e6

Please sign in to comment.