| 1 |
<?php |
| 2 |
/** |
| 3 |
* Taxonomy Base Class |
| 4 |
* |
| 5 |
* @since 1.0.0 |
| 6 |
* |
| 7 |
* @package Timetics |
| 8 |
*/ |
| 9 |
namespace Timetics\Base; |
| 10 |
|
| 11 |
defined( 'ABSPATH' ) || exit; |
| 12 |
|
| 13 |
/** |
| 14 |
* Taxonomy Class. |
| 15 |
* |
| 16 |
* @since 1.0.0 |
| 17 |
*/ |
| 18 |
abstract class Taxonomy { |
| 19 |
/** |
| 20 |
* Store taxonomy name |
| 21 |
* |
| 22 |
* @since 1.0.0 |
| 23 |
* |
| 24 |
* @var string $name |
| 25 |
*/ |
| 26 |
protected $name; |
| 27 |
|
| 28 |
/** |
| 29 |
* Store custom post type |
| 30 |
* |
| 31 |
* @since 1.0.0 |
| 32 |
* |
| 33 |
* @var string $cpt |
| 34 |
*/ |
| 35 |
protected $cpt; |
| 36 |
|
| 37 |
/** |
| 38 |
* Store taxonomy args. |
| 39 |
* |
| 40 |
* @since 1.0.0 |
| 41 |
* |
| 42 |
* @var array $args |
| 43 |
*/ |
| 44 |
protected $args; |
| 45 |
|
| 46 |
/** |
| 47 |
* Taxonomy Constructor. |
| 48 |
* |
| 49 |
* @since 1.0.0 |
| 50 |
* |
| 51 |
* @return void |
| 52 |
*/ |
| 53 |
public function __construct() { |
| 54 |
$this->set_props(); |
| 55 |
add_action( 'init', [ $this, 'register_taxonomy' ] ); |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* Regisetr custom taxonomy |
| 60 |
* |
| 61 |
* @since 1.0.0 |
| 62 |
* |
| 63 |
* @return void |
| 64 |
*/ |
| 65 |
public function register_taxonomy() { |
| 66 |
register_taxonomy( $this->name, $this->cpt, $this->args ); |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* Set config |
| 71 |
* |
| 72 |
* @since 1.0.0 |
| 73 |
* |
| 74 |
* @return void |
| 75 |
*/ |
| 76 |
abstract public function set_props(); |
| 77 |
} |
| 78 |
|