PluginProbe
Sessions / 2.3.1
Sessions v2.3.1
2.1.0 2.10.0 2.11.0 2.12.0 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.2.0 2.3.0 2.3.1 2.4.0 2.4.1 2.5.0 2.6.0 2.6.1 2.6.2 2.7.0 2.8.0 2.9.0 2.9.1 3.0.0 3.1.0 3.1.1 All 39 releases
sessions / includes / system / class-comment.php

class-comment.php in Sessions 2.3.1, at includes/system/class-comment.php

56 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Comments handling
4 *
5 * Handles all comments operations and detection.
6 *
7 * @package System
8 * @author Pierre Lannoy <https://pierre.lannoy.fr/>.
9 * @since 1.0.0
10 */
11
12 namespace POSessions\System;
13
14 /**
15 * Define the comments functionality.
16 *
17 * Handles all comments operations and detection.
18 *
19 * @package System
20 * @author Pierre Lannoy <https://pierre.lannoy.fr/>.
21 * @since 1.0.0
22 */
23 class Comment {
24
25 /**
26 * Initializes the class and set its properties.
27 *
28 * @since 1.0.0
29 */
30 public function __construct() {
31 }
32
33 /**
34 * Get a fully qualified comment name.
35 *
36 * @param mixed $id Optional. The comment id or WP_comment instance.
37 * @return string The comment pseudo name if detected.
38 * @since 1.0.0
39 */
40 public static function get_full_comment_name( $id ) {
41 $comment = null;
42 if ( is_numeric( $id ) ) {
43 $comment = get_comment( $id );
44 }
45 if ( $id instanceof \WP_Comment ) {
46 $comment = $id;
47 }
48 if ( $comment instanceof \WP_Comment ) {
49 return sprintf( '"%s" (comment ID %s)', wp_trim_words( wp_kses( $comment->comment_content, [] ), 8 ), $comment->comment_ID );
50 } else {
51 return 'unknow comment';
52 }
53 }
54
55 }
56