1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* MslsTaxonomy |
4
|
|
|
* @author Dennis Ploetner <[email protected]> |
5
|
|
|
* @since 0.9.8 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace lloc\Msls; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Content types: Taxonomies (Tags, Categories, ...) |
12
|
|
|
* |
13
|
|
|
* @package Msls |
14
|
|
|
*/ |
15
|
|
|
class MslsTaxonomy extends MslsContentTypes { |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Post type |
19
|
|
|
* @var string |
20
|
|
|
*/ |
21
|
|
|
protected $post_type = ''; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Constructor |
25
|
|
|
*/ |
26
|
|
|
public function __construct() { |
27
|
|
|
$this->types = array_merge( |
28
|
|
|
[ 'category', 'post_tag' ], // no 'post_link' here |
29
|
|
|
get_taxonomies( [ 'public' => true, '_builtin' => false ], 'names', 'and' ) |
30
|
|
|
); |
31
|
|
|
|
32
|
|
|
$_request = MslsPlugin::get_superglobals( [ 'taxonomy', 'post_type' ] ); |
33
|
|
|
if ( '' != $_request['taxonomy'] ) { |
34
|
|
|
$this->request = esc_attr( $_request['taxonomy'] ); |
35
|
|
|
$this->post_type = esc_attr( $_request['post_type'] ); |
36
|
|
|
} else { |
37
|
|
|
$this->request = get_query_var( 'taxonomy' ); |
38
|
|
|
} |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Check for taxonomy |
43
|
|
|
* @return bool |
44
|
|
|
*/ |
45
|
|
|
public function is_taxonomy() { |
46
|
|
|
return true; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Check if the current user can manage this content type |
51
|
|
|
* |
52
|
|
|
* Returns name of the content type if the user has access or an empty |
53
|
|
|
* string if the user can not access |
54
|
|
|
* |
55
|
|
|
* @return string |
56
|
|
|
*/ |
57
|
|
|
public function acl_request() { |
58
|
|
|
if ( ! MslsOptions::instance()->is_excluded() ) { |
59
|
|
|
$request = $this->get_request(); |
60
|
|
|
|
61
|
|
|
$tax = get_taxonomy( $request ); |
62
|
|
|
if ( $tax && current_user_can( $tax->cap->manage_terms ) ) { |
63
|
|
|
return $request; |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
return ''; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Get the requested post_type of the taxonomy |
72
|
|
|
* |
73
|
|
|
* @return string |
74
|
|
|
*/ |
75
|
|
|
public function get_post_type() { |
76
|
|
|
return $this->post_type; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
} |
80
|
|
|
|