views
2 years ago
Category.php
2 years ago
CategoryController.php
5 years ago
Shortcodes.php
2 years ago
Category.php
46 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Download manager category |
| 4 | */ |
| 5 | |
| 6 | namespace WPDM\Category; |
| 7 | |
| 8 | |
| 9 | class Category |
| 10 | { |
| 11 | public $ID; |
| 12 | public $name; |
| 13 | public $slug; |
| 14 | public $description; |
| 15 | public $icon; |
| 16 | public $access; |
| 17 | public $url; |
| 18 | public $parent; |
| 19 | public $packageCount; |
| 20 | |
| 21 | function __construct($ID_SLUG_NAME = null) |
| 22 | { |
| 23 | if($ID_SLUG_NAME && $_term = term_exists($ID_SLUG_NAME, 'wpdmcategory')) |
| 24 | { |
| 25 | $term = get_term($_term['term_id']); |
| 26 | |
| 27 | $this->ID = $term->term_id; |
| 28 | $this->name = $term->name; |
| 29 | $this->slug = $term->slug; |
| 30 | $this->description = $term->description; |
| 31 | $this->access = maybe_unserialize(get_term_meta($this->ID, "__wpdm_access", true)); |
| 32 | $this->parent = $term->parent; |
| 33 | $this->packageCount = $term->count; |
| 34 | $this->icon = CategoryController::icon($this->ID); |
| 35 | $this->url = get_term_link($this->ID); |
| 36 | |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | function get($ID_SLUG_NAME) |
| 41 | { |
| 42 | return new Category($ID_SLUG_NAME); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 |