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