| 1 |
<?php |
| 2 |
defined('ABSPATH') || exit; |
| 3 |
|
| 4 |
$category = ''; |
| 5 |
if ($attr['catShow']) { |
| 6 |
$category .= '<div class="ultp-category-grid ultp-category-'.$attr['catStyle'].' ultp-category-'.$attr['catPosition'].'">'; |
| 7 |
$category .= '<div class="ultp-category-in'.($attr['customCatColor'] ? ' ultp-cat-color-'.$attr['customCatColor'] : '').'">'; |
| 8 |
$cat = get_the_terms($post_id, $attr['taxonomy']); |
| 9 |
if (!empty($cat)) { |
| 10 |
$max_tax = $attr['maxTaxonomy'] == '0' ? 0 : ( $attr['maxTaxonomy'] ? $attr['maxTaxonomy'] : 30 ); |
| 11 |
foreach ($cat as $k => $val) { |
| 12 |
if ($k >= $max_tax) { break; } |
| 13 |
$color = ''; |
| 14 |
if (isset($attr['customCatColor'])) { |
| 15 |
if ($attr['customCatColor']) { |
| 16 |
$color = get_term_meta($val->term_id, 'ultp_category_color', true); |
| 17 |
$color = $color == 1 ? '#CE2746' : $color; |
| 18 |
if (isset($attr['onlyCatColor'])) { |
| 19 |
if ($attr['onlyCatColor']) { |
| 20 |
$color = 'style="color: '.($color ? $color : '#CE2746').'"'; |
| 21 |
}else{ |
| 22 |
$color = 'style="background-color: '.($color ? $color : '#CE2746').';color: #fff;"'; |
| 23 |
} |
| 24 |
}else{ |
| 25 |
$color = 'style="background-color: '.($color ? $color : '#CE2746').';color: #fff;"'; |
| 26 |
} |
| 27 |
} |
| 28 |
} |
| 29 |
if ($attr['onlyCatColor']) { |
| 30 |
$category .= '<a class="ultp-cat-'.$val->slug.'" href="'.get_term_link($val->term_id).'" '.$color.' '.($attr['openInTab'] ? 'target="_blank"' : '').'>'.$val->name.'</a>'; |
| 31 |
} else { |
| 32 |
$category .= '<a class="ultp-cat-'.$val->slug.( $attr['customCatColor'] ? ' ultp-cat-only-color-'.$attr['customCatColor'] : '').'" href="'.get_term_link($val->term_id).'" '.$color.' '.($attr['openInTab'] ? 'target="_blank"' : '').'>'.$val->name.'</a>'; |
| 33 |
} |
| 34 |
} |
| 35 |
} |
| 36 |
$category .= '</div>'; |
| 37 |
$category .= '</div>'; |
| 38 |
} |