Comment.php
3 months ago
Media.php
3 months ago
NetworkSite.php
3 months ago
NetworkUser.php
3 months ago
Post.php
3 months ago
Taxonomy.php
3 months ago
TotalItemsTrait.php
3 months ago
User.php
3 months ago
Taxonomy.php
41 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AC\ListTable; |
| 4 | |
| 5 | use AC\ListTable; |
| 6 | use WP_Term; |
| 7 | use WP_Terms_List_Table; |
| 8 | |
| 9 | class Taxonomy implements ListTable |
| 10 | { |
| 11 | |
| 12 | private WP_Terms_List_Table $table; |
| 13 | |
| 14 | private string $taxonomy; |
| 15 | |
| 16 | public function __construct(WP_Terms_List_Table $table, string $taxonomy) |
| 17 | { |
| 18 | $this->table = $table; |
| 19 | $this->taxonomy = $taxonomy; |
| 20 | } |
| 21 | |
| 22 | public function render_cell(string $column_id, $row_id): string |
| 23 | { |
| 24 | return (string)apply_filters("manage_{$this->taxonomy}_custom_column", '', $column_id, $row_id); |
| 25 | } |
| 26 | |
| 27 | public function render_row($id): string |
| 28 | { |
| 29 | $term = get_term_by('id', $id, $this->taxonomy); |
| 30 | |
| 31 | if ( ! $term instanceof WP_Term) { |
| 32 | return ''; |
| 33 | } |
| 34 | |
| 35 | ob_start(); |
| 36 | $this->table->single_row($term); |
| 37 | |
| 38 | return ob_get_clean(); |
| 39 | } |
| 40 | |
| 41 | } |