← All changes
|
backend/src/Data/Transformers/CommentTransformer.php
+37
-12
0.4
→
1.0.2
View file →
| @@ -10,24 +10,49 @@ | ||
| 10 | 10 | $date = mysql2date( get_option( 'date_format' ), $comment->comment_date ); |
| 11 | 11 | $time = mysql2date( get_option( 'time_format' ), $comment->comment_date ); |
| 12 | 12 | |
| 13 | 13 | return [ |
| 14 | + 'id' => $comment->comment_ID, | |
| 15 | + 'title' => strip_tags( $comment->comment_content ), | |
| 16 | + 'content' => $comment->comment_content, | |
| 17 | + 'meta' => $comment->comment_author . ' - ' . $date, | |
| 18 | + | |
| 19 | + // Date | |
| 20 | + 'date' => $date, | |
| 21 | + 'time' => $time, | |
| 22 | + 'timeDiff' => human_time_diff( strtotime( $comment->comment_date ) ), | |
| 23 | + | |
| 24 | + // Status | |
| 14 | 25 | 'approved' => $comment->comment_approved ? true : false, |
| 15 | - 'author' => $comment->comment_author, | |
| 26 | + 'spam' => 'spam' === $comment->comment_approved, | |
| 27 | + 'trash' => 'trash' === $comment->comment_approved, | |
| 28 | + | |
| 29 | + // URLs | |
| 30 | + 'url' => get_comment_link( $comment ), | |
| 31 | + 'editUrl' => admin_url( 'comment.php?action=editcomment&c=' ) . $comment->comment_ID, | |
| 32 | + | |
| 33 | + // Author Meta | |
| 34 | + 'authorName' => $comment->comment_author, | |
| 16 | 35 | 'authorEmail' => $comment->comment_author_email, |
| 17 | 36 | '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, | |
| 37 | + 'authorURL' => get_comment_author_url( $comment->comment_ID ), | |
| 38 | + 'thumbnail' => get_avatar_url( $comment->comment_author_email ), | |
| 39 | + | |
| 40 | + 'author' => [ | |
| 41 | + 'name' => $comment->comment_author, | |
| 42 | + 'email' => $comment->comment_author_email, | |
| 43 | + 'ip' => $comment->comment_author_IP, | |
| 44 | + 'url' => get_comment_author_url( $comment->comment_ID ), | |
| 45 | + 'avatar' => get_avatar_url( $comment->comment_author_email ), | |
| 46 | + ], | |
| 47 | + | |
| 48 | + // Post Meta | |
| 23 | 49 | 'postId' => $post->ID, |
| 24 | 50 | '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 ), | |
| 51 | + 'post' => [ | |
| 52 | + 'id' => $post->ID, | |
| 53 | + 'title' => $post->post_title, | |
| 54 | + 'thumbnail' => '', | |
| 55 | + ], | |
| 31 | 56 | ]; |
| 32 | 57 | } |
| 33 | 58 | } |