'DiscussionForumPosting', 'id' => aioseo()->schema->context['url'] . '#discussion-forum-posting', 'headline' => $graphData->properties->headline ?? '', 'text' => $graphData->properties->text ?? '', 'url' => aioseo()->schema->context['url'], 'datePublished' => ! empty( $graphData->properties->datePublished ) ? mysql2date( DATE_W3C, $graphData->properties->datePublished, false ) : '', 'comment' => $this->parseComment( $graphData->properties->comment ?? [] ), 'author' => [ '@type' => 'Person', 'name' => $graphData->properties->author ?? '', ], ]; } /** * Retrieves comments. * * @since 4.8.1 * * @param array $comment The comment data. * @return array The formatted `comment` data. */ private function parseComment( $comment ) { if ( empty( $comment ) ) { return []; } $parsed = []; foreach ( $comment as $item ) { $itemData = [ '@type' => 'Comment', 'text' => $item->content, 'datePublished' => mysql2date( DATE_W3C, $item->date_recorded, false ), 'author' => [ '@type' => 'Person', 'name' => $item->user_fullname, ], ]; if ( ! empty( $item->children ) ) { $itemData['comment'] = $this->parseComment( $item->children ); } $parsed[] = $itemData; } return $parsed; } }