File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Pollora \Attributes \Taxonomy ;
6+
7+ use Attribute ;
8+ use Pollora \Taxonomy \Domain \Contracts \TaxonomyAttributeInterface ;
9+
10+ /**
11+ * Attribute to set the capabilities parameter for a taxonomy.
12+ *
13+ * Provides an array of capabilities for this taxonomy.
14+ * See WordPress documentation for the full list of taxonomy capabilities.
15+ *
16+ * Available capabilities:
17+ * - manage_terms: capability required to access the taxonomy management screen
18+ * - edit_terms: capability required to edit terms in the taxonomy
19+ * - delete_terms: capability required to delete terms from the taxonomy
20+ * - assign_terms: capability required to assign terms in the taxonomy to posts
21+ *
22+ * @Attribute
23+ */
24+ #[Attribute(Attribute::TARGET_CLASS )]
25+ class Capabilities extends TaxonomyAttribute
26+ {
27+ /**
28+ * Constructor.
29+ *
30+ * @param array $value The capabilities array for the taxonomy
31+ */
32+ public function __construct (
33+ public readonly array $ value
34+ ) {}
35+
36+ /**
37+ * Configure the taxonomy with the capabilities parameter.
38+ *
39+ * @param TaxonomyAttributeInterface $taxonomy The taxonomy to configure
40+ */
41+ protected function configure (TaxonomyAttributeInterface $ taxonomy ): void
42+ {
43+ $ taxonomy ->attributeArgs ['capabilities ' ] = $ this ->value ;
44+ }
45+ }
You can’t perform that action at this time.
0 commit comments