Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove repeated-metas.php and move class-meta-renderer.php #2849

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
use Parsely\Parsely;
use WP_Post;

use const Parsely\PARSELY_FILE;

/**
* Renders metadata in the WordPress front-end header.
*
Expand Down Expand Up @@ -115,30 +113,47 @@ public function render_metadata( string $meta_type ): void {
} else {
// Assume `meta_type` is `repeated_metas`.
$parsely_post_type = $this->parsely->convert_jsonld_to_parsely_type( $metadata['@type'] ?? '' );
$tags = '';

// @phpstan-ignore-next-line
if ( isset( $metadata['keywords'] ) && is_array( $metadata['keywords'] ) ) {
$metadata['keywords'] = implode( ',', $metadata['keywords'] );
$tags = implode( ',', $metadata['keywords'] );
}

$parsely_metas = array(
'title' => $metadata['headline'],
'link' => $metadata['url'] ?? null,
'link' => $metadata['url'] ?? '',
'type' => $parsely_post_type,
'image-url' => $metadata['thumbnailUrl'] ?? null,
'pub-date' => $metadata['datePublished'] ?? null,
'section' => $metadata['articleSection'] ?? null,
'tags' => $metadata['keywords'] ?? null,
'author' => isset( $metadata['author'] ),
'image-url' => $metadata['thumbnailUrl'] ?? '',
'pub-date' => $metadata['datePublished'] ?? '',
'section' => $metadata['articleSection'] ?? '',
'tags' => $tags,
);
$parsely_metas = array_filter( $parsely_metas, array( $this, 'filter_empty_and_not_string_from_array' ) );

// Output metas.
foreach ( $parsely_metas as $parsely_meta_key => $parsely_meta_val ) {
printf(
'<meta name="%s" content="%s" />%s',
esc_attr( 'parsely-' . $parsely_meta_key ),
esc_attr( $parsely_meta_val ),
"\n"
);
}

// Output author metas (they can be multiple).
if ( isset( $metadata['author'] ) ) {
$parsely_page_authors = wp_list_pluck( $metadata['author'], 'name' );
$parsely_page_authors = array_filter( $parsely_page_authors, array( $this, 'filter_empty_and_not_string_from_array' ) );
}

include plugin_dir_path( PARSELY_FILE ) . 'views/repeated-metas.php';
foreach ( $parsely_page_authors as $parsely_author_name ) {
printf(
'<meta name="parsely-author" content="%s" />%s',
esc_attr( $parsely_author_name ),
"\n"
);
}
}
}

// Add any custom metadata.
Expand Down
31 changes: 0 additions & 31 deletions views/repeated-metas.php

This file was deleted.

Loading