Skip to content

Commit

Permalink
Fix article wrapper issue with JSON-LD properties. (#1734)
Browse files Browse the repository at this point in the history
* Check in post-to-jsonld conversion if post is an entity and expand custom_fields as article type.

* Formatting
  • Loading branch information
mauanga authored Mar 20, 2024
1 parent 2938acb commit 6089e8f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/includes/class-wordlift-entity-type-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public function set( $post_id, $type_uri, $replace = true ) {
* or `$term` was not found.
* @since 3.20.0
*/
private function get_term_by_slug( $slug ) {
public function get_term_by_slug( $slug ) {

return get_term_by( 'slug', $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
}
Expand Down
7 changes: 6 additions & 1 deletion src/includes/class-wordlift-post-to-jsonld-converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ public function convert( $post_id, &$references = array(), &$references_infos =
// Get the entity name.
$jsonld['headline'] = $post->post_title;

$custom_fields = $this->entity_type_service->get_custom_fields_for_post( $post_id );
// Convert entities as `Article`.
//
// @see https://github.com/insideout10/wordlift-plugin/issues/1731
$custom_fields = Wordlift_Entity_Service::get_instance()->is_entity( $post_id )
? $this->entity_type_service->get_custom_fields_for_term( $this->entity_type_service->get_term_by_slug( 'article' ) )
: $this->entity_type_service->get_custom_fields_for_post( $post_id );

if ( isset( $custom_fields ) ) {
$this->process_type_custom_fields( $jsonld, $custom_fields, $post, $references, $references_infos );
Expand Down

0 comments on commit 6089e8f

Please sign in to comment.