| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
namespace FL\Assistant\Data\Transformers; |
| 5 |
|
| 6 |
|
| 7 |
class CommentTransformer { |
| 8 |
public function __invoke( \WP_Comment $comment ) { |
| 9 |
$post = get_post( $comment->comment_post_ID ); |
| 10 |
$date = mysql2date( get_option( 'date_format' ), $comment->comment_date ); |
| 11 |
$time = mysql2date( get_option( 'time_format' ), $comment->comment_date ); |
| 12 |
|
| 13 |
return [ |
| 14 |
'approved' => $comment->comment_approved ? true : false, |
| 15 |
'author' => $comment->comment_author, |
| 16 |
'authorEmail' => $comment->comment_author_email, |
| 17 |
'authorIP' => $comment->comment_author_IP, |
| 18 |
'content' => $comment->comment_content, |
| 19 |
'date' => $date, |
| 20 |
'editUrl' => admin_url( 'comment.php?action=editcomment&c=' ) . $comment->comment_ID, |
| 21 |
'id' => $comment->comment_ID, |
| 22 |
'meta' => $comment->comment_author . ' - ' . $date, |
| 23 |
'postId' => $post->ID, |
| 24 |
'postTitle' => $post->post_title, |
| 25 |
'spam' => 'spam' === $comment->comment_approved, |
| 26 |
'time' => $time, |
| 27 |
'thumbnail' => get_avatar_url( $comment->comment_author_email ), |
| 28 |
'title' => strip_tags( $comment->comment_content ), |
| 29 |
'trash' => 'trash' === $comment->comment_approved, |
| 30 |
'url' => get_comment_link( $comment ), |
| 31 |
]; |
| 32 |
} |
| 33 |
} |
| 34 |
|