1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
<?php
class Papi_Term_Store extends Papi_Core_Meta_Store {
private $term;
protected $type = 'term';
public function __construct( $id = 0 ) {
$this->id = papi_get_term_id( $id );
$this->term = get_term( $this->id, '' );
$id = papi_get_taxonomy_type_id( $this->id );
$this->type_class = papi_get_entry_type_by_id( $id );
}
public function get_permalink() {
return get_term_link( $this->id );
}
public function get_term() {
return $this->term;
}
public function valid() {
return $this->term instanceof WP_Term;
}
public function get_property( $slug, $child_slug = '' ) {
$taxonomy_type_id = papi_get_taxonomy_type_id( $this->id, 'term' );
$taxonomy_type = papi_get_entry_type_by_id( $taxonomy_type_id );
if ( $taxonomy_type instanceof Papi_Taxonomy_Type === false ) {
return;
}
if ( $property = $taxonomy_type->get_property( $slug, $child_slug ) ) {
return $this->prepare_property( $property );
}
}
}