Completed
Push — milestone/2.0 ( 5944fd...9cc217 )
by
unknown
02:37
created

WP_Toolset::get_user_title()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Carbon_Fields\Toolset;
4
5
/**
6
 * Provides common tools when dealing with WordPress data such as posts, terms etc.
7
 */
8
class WP_Toolset {
9
10
	/**
11
	 * Get post title
12
	 *
13
	 * @param int $id
14
	 * @return string $title The title of the item.
15
	 */
16
	public function get_post_title( $id ) {
17
		return get_the_title( $id );
18
	}
19
20
	/**
21
	 * Get term title
22
	 *
23
	 * @param int $id
24
	 * @param string $subtype
25
	 * @return string $title The title of the item.
26
	 */
27
	public function get_term_title( $id, $subtype = '' ) {
28
		$term = get_term_by( 'id', $id, $subtype );
29
		return $term->name;
30
	}
31
32
	/**
33
	 * Get user title
34
	 *
35
	 * @param int $id
36
	 * @return string $title The title of the item.
37
	 */
38
	public function get_user_title( $id ) {
39
		return get_the_author_meta( 'user_login', $id );
40
	}
41
42
	/**
43
	 * Get comment title
44
	 *
45
	 * @param int $id
46
	 * @return string $title The title of the item.
47
	 */
48
	public function get_comment_title( $id ) {
49
		return get_comment_text( $id );
50
	}
51
}
52