Guest User

Untitled

a guest
Apr 3rd, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.62 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. class td_module_3 extends td_module {
  5.  
  6. function __construct($post) {
  7. //run the parrent constructor
  8. parent::__construct($post);
  9. }
  10.  
  11. function render() {
  12. ob_start();
  13. ?>
  14.  
  15. <div class="td_mod3 td_mod_wrap <?php echo $this->get_no_thumb_class();?>" <?php echo $this->get_item_scope();?>>
  16. <?php echo $this->get_image('art-thumb');?>
  17. <div class="item-details">
  18. <?php echo $this->get_title(td_util::get_option('tds_mod3_title_excerpt'));?>
  19. <div class="meta-info">
  20. <?php //echo $this->get_author();?>
  21. <?php echo $this->get_date();?>
  22. <?php echo $this->get_category();?>
  23. <?php //echo $this->get_commentsAndViews();?>
  24. </div>
  25. </div>
  26. <?php echo $this->get_item_scope_meta();?>
  27. </div>
  28.  
  29. <?php return ob_get_clean();
  30. }
  31. function get_category() {
  32.  
  33. $buffy = '';
  34.  
  35. $buffy .= '<ul class="td-category">';
  36. $categories = get_the_category($this->post->ID);
  37. $cat_array = array();
  38.  
  39. if($categories){
  40. foreach($categories as $category) {
  41. if ($category->name != TD_FEATURED_CAT) { //ignore the featured category name
  42. //get the parent of this cat
  43. $td_parent_cat_obj = get_category($category->category_parent);
  44.  
  45. //if we have a parent, shot it first
  46. if (!empty($td_parent_cat_obj->name)) {
  47. $tax_meta__color_parent = td_util::get_category_option($td_parent_cat_obj->cat_ID,'tdc_color');//swich by RADU A, get_tax_meta($td_parent_cat_obj->cat_ID,'tdc_color');
  48. $tax_meta__hide_on_post_parent = td_util::get_category_option($td_parent_cat_obj->cat_ID,'tdc_hide_on_post');//swich by RADU A, get_tax_meta($td_parent_cat_obj->cat_ID,'tdc_hide_on_post');
  49. $cat_array[$td_parent_cat_obj->name] = array(
  50. 'color' => $tax_meta__color_parent,
  51. 'link' => get_category_link($td_parent_cat_obj->cat_ID),
  52. 'hide_on_post' => $tax_meta__hide_on_post_parent
  53. );
  54. }
  55.  
  56. //show the category, only if we didn't already showed the parent
  57. $tax_meta_color = td_util::get_category_option($category->cat_ID,'tdc_color');//swich by RADU A, get_tax_meta($category->cat_ID,'tdc_color');
  58. $tax_meta__hide_on_post_parent = td_util::get_category_option($category->cat_ID,'tdc_hide_on_post');//swich by RADU A, get_tax_meta($category->cat_ID,'tdc_hide_on_post');
  59. $cat_array[$category->name] = array(
  60. 'color' => $tax_meta_color,
  61. 'link' => get_category_link($category->cat_ID),
  62. 'hide_on_post' => $tax_meta__hide_on_post_parent
  63. );
  64. }
  65. }
  66. }
  67.  
  68. foreach ($cat_array as $td_cat_name => $td_cat_parms) {
  69. if ($td_cat_parms['hide_on_post'] == 'hide') {
  70. continue;
  71. }
  72.  
  73. if (!empty($td_cat_parms['color'])) {
  74. $td_cat_color = ' style="background-color:' . $td_cat_parms['color'] . ';"';
  75. } else {
  76. $td_cat_color = '';
  77. }
  78.  
  79.  
  80. $buffy .= '<li class="entry-category"><a ' . $td_cat_color . ' href="' . $td_cat_parms['link'] . '">' . $td_cat_name . '</a></li>';
  81. }
  82. $buffy .= '</ul>';
  83.  
  84. return $buffy;
  85. }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment