Campaign.php
2 years ago
Current_Traffic.php
2 years ago
Device.php
2 years ago
Geo.php
2 years ago
Page.php
2 years ago
Page_Author_Archive.php
2 years ago
Page_Date_Archive.php
2 years ago
Page_Home.php
2 years ago
Page_Not_Found.php
2 years ago
Page_Post_Type_Archive.php
2 years ago
Page_Search.php
2 years ago
Page_Singular.php
2 years ago
Page_Term_Archive.php
2 years ago
Page_Virtual.php
2 years ago
Referrer.php
2 years ago
View_Stats.php
2 years ago
Visitor.php
2 years ago
WooCommerce_Stats.php
2 years ago
Page_Term_Archive.php
85 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP_SCOPED\IAWP\Models; |
| 4 | |
| 5 | /** @internal */ |
| 6 | class Page_Term_Archive extends Page |
| 7 | { |
| 8 | private $term_id; |
| 9 | public function __construct($row) |
| 10 | { |
| 11 | $this->term_id = \intval($row->term_id); |
| 12 | parent::__construct($row); |
| 13 | } |
| 14 | protected function resource_key() : string |
| 15 | { |
| 16 | return 'term_id'; |
| 17 | } |
| 18 | protected function resource_value() : string |
| 19 | { |
| 20 | return $this->term_id; |
| 21 | } |
| 22 | protected function calculate_is_deleted() : bool |
| 23 | { |
| 24 | try { |
| 25 | $term = \get_term($this->term_id); |
| 26 | return \is_wp_error($term) || \is_null($term); |
| 27 | } catch (\Throwable $e) { |
| 28 | return \true; |
| 29 | } |
| 30 | } |
| 31 | protected function calculate_url() |
| 32 | { |
| 33 | return \get_term_link($this->term_id); |
| 34 | } |
| 35 | protected function calculate_title() |
| 36 | { |
| 37 | return $this->term()->name; |
| 38 | } |
| 39 | protected function calculate_type() |
| 40 | { |
| 41 | return $this->term()->taxonomy; |
| 42 | } |
| 43 | protected function calculate_type_label() |
| 44 | { |
| 45 | return \get_taxonomy_labels(\get_taxonomy($this->term()->taxonomy))->singular_name; |
| 46 | } |
| 47 | protected function calculate_icon() |
| 48 | { |
| 49 | $icon = 'dashicons-category'; |
| 50 | if (!$this->calculate_is_deleted()) { |
| 51 | if ($this->type() == 'Tag') { |
| 52 | $icon = 'dashicons-tag'; |
| 53 | } |
| 54 | } |
| 55 | $html = '<div class="post-type-icon">'; |
| 56 | $html .= '<span class="dashicons ' . $icon . '"></span>'; |
| 57 | $html .= '</div>'; |
| 58 | return $html; |
| 59 | } |
| 60 | protected function calculate_author_id() |
| 61 | { |
| 62 | return null; |
| 63 | } |
| 64 | protected function calculate_author() |
| 65 | { |
| 66 | return null; |
| 67 | } |
| 68 | protected function calculate_avatar() |
| 69 | { |
| 70 | return null; |
| 71 | } |
| 72 | protected function calculate_date() |
| 73 | { |
| 74 | return null; |
| 75 | } |
| 76 | protected function calculate_category() |
| 77 | { |
| 78 | return []; |
| 79 | } |
| 80 | private function term() |
| 81 | { |
| 82 | return \get_term($this->term_id); |
| 83 | } |
| 84 | } |
| 85 |