|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* User breadcrumb item locator |
|
4
|
|
|
* |
|
5
|
|
|
* @package carbon-breadcrumbs |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Author archive breadcrumb item locator class. |
|
10
|
|
|
* |
|
11
|
|
|
* Used to locate the breadcrumb items for author archives. |
|
12
|
|
|
*/ |
|
13
|
|
|
class Carbon_Breadcrumb_Locator_User extends Carbon_Breadcrumb_Locator { |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Whether this the items of this locator should be included in the trail. |
|
17
|
|
|
* |
|
18
|
|
|
* @access public |
|
19
|
|
|
* |
|
20
|
|
|
* @return bool $is_included Whether the found items should be included. |
|
21
|
|
|
*/ |
|
22
|
|
|
public function is_included() { |
|
23
|
|
|
return is_author(); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Retrieve the items, found by this locator. |
|
28
|
|
|
* |
|
29
|
|
|
* @access public |
|
30
|
|
|
* |
|
31
|
|
|
* @param int $priority The priority of the located items. |
|
32
|
|
|
* @param int $user_id The author user ID. |
|
33
|
|
|
* @return array $items The items, found by this locator. |
|
34
|
|
|
*/ |
|
35
|
|
|
public function get_items( $priority = 1000, $user_id = 0 ) { |
|
36
|
|
|
// Get the current author ID, if not specified. |
|
37
|
|
|
if ( ! $user_id ) { |
|
38
|
|
|
$user_id = get_queried_object_id(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
// Create the author breadcrumb item. |
|
42
|
|
|
$item = Carbon_Breadcrumb_Item::factory( $this->get_type(), $priority ); |
|
43
|
|
|
$item->set_id( $user_id ); |
|
44
|
|
|
$item->setup(); |
|
45
|
|
|
|
|
46
|
|
|
return array( $item ); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Generate a set of breadcrumb items that found by this locator type and any subtype. |
|
51
|
|
|
* The author archive locator has no subtypes, so this method wraps around get_items(). |
|
52
|
|
|
* |
|
53
|
|
|
* @access public |
|
54
|
|
|
* |
|
55
|
|
|
* @return array $items The items, generated by this locator. |
|
56
|
|
|
*/ |
|
57
|
|
|
public function generate_items() { |
|
58
|
|
|
if ( ! $this->is_included() ) { |
|
59
|
|
|
return array(); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
return $this->get_items(); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
} |
|
66
|
|
|
|