page.php
4 years ago
page_author_archive.php
4 years ago
page_date_archive.php
4 years ago
page_home.php
4 years ago
page_not_found.php
4 years ago
page_post_type_archive.php
4 years ago
page_search.php
4 years ago
page_singular.php
4 years ago
page_term_archive.php
4 years ago
referrer.php
4 years ago
page_term_archive.php
98 lines
| 1 | <?php |
| 2 | |
| 3 | if (!class_exists('IAWP_Page_Term_Archive')) { |
| 4 | class IAWP_Page_Term_Archive extends IAWP_Page |
| 5 | { |
| 6 | private $term_id; |
| 7 | |
| 8 | public function __construct($row) |
| 9 | { |
| 10 | $this->term_id = intval($row->term_id); |
| 11 | parent::__construct($row); |
| 12 | } |
| 13 | |
| 14 | protected function resource_key(): string |
| 15 | { |
| 16 | return 'term_id'; |
| 17 | } |
| 18 | |
| 19 | protected function resource_value(): string |
| 20 | { |
| 21 | return $this->term_id; |
| 22 | } |
| 23 | |
| 24 | protected function calculate_is_deleted(): bool |
| 25 | { |
| 26 | try { |
| 27 | $term = get_term($this->term_id); |
| 28 | |
| 29 | return is_wp_error($term) || is_null($term); |
| 30 | } catch (Exception $e) { |
| 31 | return true; |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | protected function calculate_url() |
| 36 | { |
| 37 | return get_term_link($this->term_id); |
| 38 | } |
| 39 | |
| 40 | protected function calculate_title() |
| 41 | { |
| 42 | return $this->term()->name; |
| 43 | } |
| 44 | |
| 45 | protected function calculate_type() |
| 46 | { |
| 47 | return $this->term()->taxonomy; |
| 48 | } |
| 49 | |
| 50 | protected function calculate_type_label() |
| 51 | { |
| 52 | return get_taxonomy_labels(get_taxonomy($this->term()->taxonomy))->singular_name; |
| 53 | } |
| 54 | |
| 55 | protected function calculate_icon() |
| 56 | { |
| 57 | $icon = 'dashicons-category'; |
| 58 | |
| 59 | if (!$this->calculate_is_deleted()) { |
| 60 | if ($this->type_label() == 'Tag') { |
| 61 | $icon = 'dashicons-tag'; |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | $html = '<div class="post-type-icon">'; |
| 66 | $html .= '<span class="dashicons ' . $icon . '"></span>'; |
| 67 | $html .= '</div>'; |
| 68 | |
| 69 | return $html; |
| 70 | } |
| 71 | |
| 72 | protected function calculate_author_id() |
| 73 | { |
| 74 | return null; |
| 75 | } |
| 76 | |
| 77 | protected function calculate_author() |
| 78 | { |
| 79 | return null; |
| 80 | } |
| 81 | |
| 82 | protected function calculate_avatar() |
| 83 | { |
| 84 | return null; |
| 85 | } |
| 86 | |
| 87 | protected function calculate_date() |
| 88 | { |
| 89 | return null; |
| 90 | } |
| 91 | |
| 92 | private function term() |
| 93 | { |
| 94 | return get_term($this->term_id); |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 |