← All changes
|
backend/src/Data/Transformers/CommentTransformer.php
+58
-58
1.5.5
→
1.4.7
View file →
| @@ -1,58 +1,58 @@ | ||
| 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 | - '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 | |
| 25 | - 'approved' => $comment->comment_approved ? true : false, | |
| 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, | |
| 35 | - 'authorEmail' => $comment->comment_author_email, | |
| 36 | - 'authorIP' => $comment->comment_author_IP, | |
| 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 | |
| 49 | - 'postId' => $post->ID, | |
| 50 | - 'postTitle' => $post->post_title, | |
| 51 | - 'post' => [ | |
| 52 | - 'id' => $post->ID, | |
| 53 | - 'title' => $post->post_title, | |
| 54 | - 'thumbnail' => '', | |
| 55 | - ], | |
| 56 | - ]; | |
| 57 | - } | |
| 58 | -} | |
| 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 | + '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 | |
| 25 | + 'approved' => $comment->comment_approved ? true : false, | |
| 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, | |
| 35 | + 'authorEmail' => $comment->comment_author_email, | |
| 36 | + 'authorIP' => $comment->comment_author_IP, | |
| 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 | |
| 49 | + 'postId' => $post->ID, | |
| 50 | + 'postTitle' => $post->post_title, | |
| 51 | + 'post' => [ | |
| 52 | + 'id' => $post->ID, | |
| 53 | + 'title' => $post->post_title, | |
| 54 | + 'thumbnail' => '', | |
| 55 | + ], | |
| 56 | + ]; | |
| 57 | + } | |
| 58 | +} | |