-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGenericTaxonomy.php
50 lines (37 loc) · 1.28 KB
/
GenericTaxonomy.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
global $wpc_taxonomies;
$wpc_taxonomies = array();
abstract class GenericTaxonomy {
public $id = NULL;
public $label = "";
public $slug = "";
public $singular_label = "";
public $hierarchical = false;
public $for_post_types = array();
function __construct () {
global $wpc_taxonomies;
// SET DEFAULTS
if ( empty($this->id) ) $this->id = strtolower ( get_class_name($this) );
if ( empty($this->label) ) $this->label = $this->id . "s";
if ( empty($this->singular_label) ) $this->singular_label = $this->id;
if ( empty($this->slug) ) $this->slug = $this->id;
if ( empty($this->for_post_types) ) $this->for_post_types = array();
if ( in_array($this->id, get_taxonomies()) ) {
die ("wpc taxonomy \"$this->id\" is not unique");
return ;
} else {
$wpc_taxonomies[$this->id] = $this;
}
// REGISTER TAXONOMY
register_taxonomy (
$this->id,
$this->for_post_types,
array(
'label' => $this->label,
'hierarchical' => $this->hierarchical,
'rewrite' => array( 'slug' => $this->slug )
)
);
}
}
?>