PluginProbe
Assistant – Every Day Productivity Apps / 0.7.0.4
Assistant – Every Day Productivity Apps v0.7.0.4
1.5.5 trunk 0.1.0 0.2.0 0.2.1 0.2.2 0.3.0 0.3.1 0.4 0.4.1 0.4.2 0.5.0 0.5.1 0.6.0 0.7.0 0.7.0.2 0.7.0.3 0.7.0.4 0.7.0.5 0.7.0.6 0.7.0.7 0.7.0.8 0.7.0.9 0.7.1 1.0 All 71 releases
assistant / backend / src / Data / Transformers / CommentTransformer.php

CommentTransformer.php in Assistant – Every Day Productivity Apps 0.7.0.4, at backend/src/Data/Transformers/CommentTransformer.php

59 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 }
59