Repository navigation
Expand file tree
/
Copy pathTaxonomy.php
More file actions
81 lines (70 loc) · 1.61 KB
/
Copy pathTaxonomy.php
File metadata and controls
81 lines (70 loc) · 1.61 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
namespace Vanilla;
abstract class Taxonomy {
/**
* Taxonomy name
*
* @var string
*/
protected $name;
/**
* The plural, singular, and slug names
*
* @var array
*/
protected $names = [];
/**
* List of post types the taxonomy is associated with
*
* @var array
*/
protected $postTypes = [];
/**
* Template to be used for the taxonomy archive page
*
* @var
*/
protected $archiveTemplate;
/**
* Register taxonomy
*/
public function register()
{
register_extended_taxonomy($this->name, $this->postTypeNames(), $this->arguments(), $this->names);
return $this;
}
/**
* @return array associated Vanilla\PostType names
*/
public function postTypeNames()
{
return collect($this->postTypes)->map(function ($className) {
return (new $className)->name();
})->toArray();
}
/**
* Arguments for register_extended_taxonomy function
*
* @return array
*/
public function arguments()
{
return array_merge($this->args() ?: [], [
'archiveTemplate' => $this->archiveTemplate,
'className' => static::class
]);
}
public function name()
{
return $this->name;
}
/**
* Taxonomy settings. For available options
*
* Used as $args parameter in register_extended_taxonomy()
* @see https://github.com/johnbillion/extended-cpts/wiki/Registering-taxonomies
*
* @return void|array
*/
abstract protected function args();
}