Skip to content

Commit

Permalink
Build "Merge pull request #3007 from Parsely/add/identifier-to-json-l…
Browse files Browse the repository at this point in the history
…d-metadata" (214ac56)
  • Loading branch information
github-actions[bot] committed Jan 15, 2025
1 parent 2e63cb5 commit 50a3cb4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Metadata/class-metadata-renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function render_metadata( string $meta_type ): void {

// Insert JSON-LD or repeated metas.
if ( 'json_ld' === $meta_type ) {
echo '<script type="application/ld+json">' . wp_json_encode( $metadata ) . '</script>';
echo '<script type="application/ld+json" class="wp-parsely-metadata">' . wp_json_encode( $metadata ) . '</script>';
} else {
// Assume `meta_type` is `repeated_metas`.
$parsely_post_type = $this->parsely->convert_jsonld_to_parsely_type( $metadata['@type'] ?? '' );
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Endpoints/RestMetadataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ public function test_get_rendered_meta_json_ld(): void {
$this->go_to( (string) $this->get_permalink( $post_id ) );

$meta_string = self::$rest->get_rendered_meta( 'json_ld' );
$expected = '<script type="application/ld+json">{"@context":"https:\/\/schema.org","@type":"NewsArticle","headline":"My test_get_rendered_meta_json_ld title","url":"http:\/\/example.org\/?p=' . $post_id . '","mainEntityOfPage":{"@type":"WebPage","@id":"http:\/\/example.org\/?p=' . $post_id . '"},"thumbnailUrl":"","image":{"@type":"ImageObject","url":""},"articleSection":"Uncategorized","author":[],"creator":[],"publisher":{"@type":"Organization","name":"Test Blog","logo":""},"keywords":[],"dateCreated":"' . $date . '","datePublished":"' . $date . '","dateModified":"' . $date . '"}</script>';
$expected = '<script type="application/ld+json" class="wp-parsely-metadata">{"@context":"https:\/\/schema.org","@type":"NewsArticle","headline":"My test_get_rendered_meta_json_ld title","url":"http:\/\/example.org\/?p=' . $post_id . '","mainEntityOfPage":{"@type":"WebPage","@id":"http:\/\/example.org\/?p=' . $post_id . '"},"thumbnailUrl":"","image":{"@type":"ImageObject","url":""},"articleSection":"Uncategorized","author":[],"creator":[],"publisher":{"@type":"Organization","name":"Test Blog","logo":""},"keywords":[],"dateCreated":"' . $date . '","datePublished":"' . $date . '","dateModified":"' . $date . '"}</script>';
self::assertSame( $expected, $meta_string );
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/UI/MetadataRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function test_render_metadata_json_ld(): void {
*/
$out = ob_get_clean();

self::assertStringContainsString( '<script type="application/ld+json">', $out );
self::assertStringContainsString( '<script type="application/ld+json" class="wp-parsely-metadata">', $out );
self::assertStringContainsString( '</script>', $out );
}

Expand Down
12 changes: 6 additions & 6 deletions tests/e2e/specs/front-end-metadata.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ test.describe( 'Front end metadata insertion', () => {

const content = await page.content();

expect( content ).toContain( '<script type="application/ld+json">{"@context":"https:\\/\\/schema.org","@type":"WebPage","headline":"wp-parsely","url":"http:\\/\\/localhost:8889"}</script>' );
expect( content ).toContain( '<script type="application/ld+json" class="wp-parsely-metadata">{"@context":"https:\\/\\/schema.org","@type":"WebPage","headline":"wp-parsely","url":"http:\\/\\/localhost:8889"}</script>' );
expect( content ).not.toContain( '<meta name="parsely-title" ' );
} );

Expand All @@ -67,7 +67,7 @@ test.describe( 'Front end metadata insertion', () => {

const content = await page.content();

expect( content ).toContain( '<script type="application/ld+json">' );
expect( content ).toContain( '<script type="application/ld+json" class="wp-parsely-metadata">' );
expect( content ).toContain( '{"@context":"https:\\/\\/schema.org","@type":"NewsArticle","headline":"Hello world!","url":"http:\\/\\/localhost:8889\\/?p=1","mainEntityOfPage":{"@type":"WebPage","@id":"http:\\/\\/localhost:8889\\/?p=1"},"thumbnailUrl":"","image":{"@type":"ImageObject","url":""},"articleSection":"Uncategorized","author":[{"@type":"Person","name":"admin"}],"creator":["admin"],"publisher":{"@type":"Organization","name":"wp-parsely","logo":""},"keywords":[],"' );
expect( content ).not.toContain( '<meta name="parsely-title" ' );
} );
Expand All @@ -82,7 +82,7 @@ test.describe( 'Front end metadata insertion', () => {

const content = await page.content();

expect( content ).toContain( '<script type="application/ld+json">' );
expect( content ).toContain( '<script type="application/ld+json" class="wp-parsely-metadata">' );
expect( content ).toContain( '{"@context":"https:\\/\\/schema.org","@type":"WebPage","headline":"Sample Page","url":"http:\\/\\/localhost:8889\\/?page_id=2","mainEntityOfPage":{"@type":"WebPage","@id":"http:\\/\\/localhost:8889\\/?page_id=2"},"thumbnailUrl":"","image":{"@type":"ImageObject","url":""},"articleSection":"Uncategorized","author":[{"@type":"Person","name":"admin"}],"creator":["admin"],"publisher":{"@type":"Organization","name":"wp-parsely","logo":""},"keywords":[],"' );
expect( content ).not.toContain( '<meta name="parsely-title" ' );
} );
Expand All @@ -107,7 +107,7 @@ test.describe( 'Front end metadata insertion', () => {
expect( content ).not.toMatch( /<meta name="parsely-pub-date" content=".*Z">/ );
expect( content ).not.toContain( '<meta name="parsely-section" content="Uncategorized">' );
expect( content ).not.toContain( '<meta name="parsely-author" content="admin">' );
expect( content ).not.toContain( '<script type="application/ld+json">' );
expect( content ).not.toContain( '<script type="application/ld+json" class="wp-parsely-metadata">' );
} );

/**
Expand All @@ -126,7 +126,7 @@ test.describe( 'Front end metadata insertion', () => {
expect( content ).toMatch( /<meta name="parsely-pub-date" content=".*Z">/ );
expect( content ).toContain( '<meta name="parsely-section" content="Uncategorized">' );
expect( content ).toContain( '<meta name="parsely-author" content="admin">' );
expect( content ).not.toContain( '<script type="application/ld+json">' );
expect( content ).not.toContain( '<script type="application/ld+json" class="wp-parsely-metadata">' );
} );

/**
Expand All @@ -145,7 +145,7 @@ test.describe( 'Front end metadata insertion', () => {
expect( content ).toMatch( /<meta name="parsely-pub-date" content=".*Z">/ );
expect( content ).toContain( '<meta name="parsely-section" content="Uncategorized">' );
expect( content ).toContain( '<meta name="parsely-author" content="admin">' );
expect( content ).not.toContain( '<script type="application/ld+json">' );
expect( content ).not.toContain( '<script type="application/ld+json" class="wp-parsely-metadata">' );
} );
} );

Expand Down
4 changes: 2 additions & 2 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'name' => 'parsely/wp-parsely',
'pretty_version' => 'dev-develop',
'version' => 'dev-develop',
'reference' => '9876177486f6e92cfdad7386732993df288ff494',
'reference' => '2e63cb50804b32c855b8f5557d3fdcacc5acce34',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand All @@ -22,7 +22,7 @@
'parsely/wp-parsely' => array(
'pretty_version' => 'dev-develop',
'version' => 'dev-develop',
'reference' => '9876177486f6e92cfdad7386732993df288ff494',
'reference' => '2e63cb50804b32c855b8f5557d3fdcacc5acce34',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand Down

0 comments on commit 50a3cb4

Please sign in to comment.