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