WC_GZD_Taxonomy

The Units Class stores units/measurements data.

Defined (1)

The class is defined in the following location(s).

/includes/abstracts/abstract-wc-gzd-taxonomy.php  
  1. class WC_GZD_Taxonomy { 
  2.  
  3. private $taxonomy = ''; 
  4.  
  5. /** 
  6. * Adds the units from i18n template 
  7. */ 
  8. public function __construct( $taxonomy = '' ) { 
  9. $this->taxonomy = $taxonomy; 
  10.  
  11. /** 
  12. * Get units by key 
  13. * @param mixed $key 
  14. * @return mixed 
  15. */ 
  16. public function __get( $key ) { 
  17. return $this->get_term( $key ); 
  18.  
  19. public function get_term_object( $key, $by = 'slug' ) { 
  20. if ( $term = get_term_by( $by, $key, $this->taxonomy ) )  
  21. return $term; 
  22. return false; 
  23.  
  24. public function get_term( $key, $by = 'slug' ) { 
  25. if ( $term = $this->get_term_object( $key, $by ) )  
  26. return $term->name; 
  27. return false; 
  28.  
  29. public function get_taxonomy() { 
  30. return $this->taxonomy; 
  31.  
  32. /** 
  33. * Returns mixed units array 
  34. * @return mixed units as array 
  35. */ 
  36. public function get_terms() { 
  37. $list = array(); 
  38. $terms = get_terms( $this->taxonomy, array( 'hide_empty' => false ) ); 
  39. if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) { 
  40. foreach ( $terms as $term ) 
  41. $list[ $term->slug ] = $term->name; 
  42. return $list;