| 1 |
<?php |
| 2 |
|
| 3 |
class WPUPG_Template_Post_Taxonomy_Terms extends WPUPG_Template_Block { |
| 4 |
|
| 5 |
public $taxonomy; |
| 6 |
public $separator; |
| 7 |
public $editorField = 'postTaxonomyTerms'; |
| 8 |
|
| 9 |
public function __construct( $type = 'post-taxonomy-terms' ) |
| 10 |
{ |
| 11 |
parent::__construct( $type ); |
| 12 |
} |
| 13 |
|
| 14 |
public function taxonomy( $taxonomy ) |
| 15 |
{ |
| 16 |
$this->taxonomy = $taxonomy; |
| 17 |
return $this; |
| 18 |
} |
| 19 |
|
| 20 |
public function separator( $separator ) |
| 21 |
{ |
| 22 |
$this->separator = $separator; |
| 23 |
return $this; |
| 24 |
} |
| 25 |
|
| 26 |
public function output( $post, $args = array() ) |
| 27 |
{ |
| 28 |
if( !$this->output_block( $post, $args ) ) return ''; |
| 29 |
|
| 30 |
$taxonomy = explode( ';', $this->taxonomy ); |
| 31 |
$taxonomy_terms = wp_get_post_terms( $post->ID, $taxonomy ); |
| 32 |
|
| 33 |
$terms = array(); |
| 34 |
foreach( $taxonomy_terms as $term ) { |
| 35 |
$terms[] = $term->name; |
| 36 |
} |
| 37 |
$terms = implode( $this->separator, $terms ); |
| 38 |
|
| 39 |
$output = $this->before_output(); |
| 40 |
|
| 41 |
$output .= '<span' . $this->style() . '>' . $terms . '</span>'; |
| 42 |
|
| 43 |
return $this->after_output( $output, $post ); |
| 44 |
} |
| 45 |
} |