Completed
Push — master ( 2b661c...5d79c3 )
by Marin
02:11
created

Carbon_Breadcrumb_Item_Post::setup_link()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1
Metric Value
dl 0
loc 4
ccs 4
cts 4
cp 1
rs 10
cc 1
eloc 3
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * Breadcrumb item class for posts.
4
 *
5
 * Used for breadcrumb items that represent a post of any post type.
6
 */
7
class Carbon_Breadcrumb_Item_Post extends Carbon_Breadcrumb_Item_DB_Object {
8
9
	/**
10
	 * Configure the title and link URL by using the specified post ID.
11
	 *
12
	 * @access public
13
	 */
14 2
	public function setup() {
15
		// in order to continue, post ID must be specified
16 2
		if ( ! $this->get_id() ) {
17 1
			throw new Carbon_Breadcrumb_Exception( 'The post breadcrumb items must have post ID specified.' );
18
		}
19
20 1
		parent::setup();
21 1
	}
22
23
	/**
24
	 * Setup the title of this item.
25
	 *
26
	 * @access public
27
	 */
28 1
	public function setup_title() {
29 1
		$title = get_post_field( 'post_title', $this->get_id() );
30 1
		$title = apply_filters( 'the_title', $title );
31 1
		$this->set_title( $title );
32 1
	}
33
34
	/**
35
	 * Setup the link of this item.
36
	 *
37
	 * @access public
38
	 */
39 1
	public function setup_link() {
40 1
		$link = get_permalink( $this->get_id() );
41 1
		$this->set_link( $link );
42 1
	}
43
44
}