| @@ -1,43 +1,35 @@ | ||
| 1 | 1 | <?php |
| 2 | -defined( 'ABSPATH' ) || exit; | |
| 2 | +defined('ABSPATH') || exit; | |
| 3 | 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 ) { | |
| 17 | - break; } | |
| 18 | - $color = ''; | |
| 19 | - if ( isset( $attr['customCatColor'] ) ) { | |
| 20 | - if ( $attr['customCatColor'] ) { | |
| 21 | - $color = get_term_meta( $val->term_id, 'ultp_category_color', true ); | |
| 22 | - $color = $color == 1 ? '#CE2746' : $color; | |
| 23 | - if ( isset( $attr['onlyCatColor'] ) ) { | |
| 24 | - if ( $attr['onlyCatColor'] ) { | |
| 25 | - $color = 'style="color: ' . ( $color ? $color : '#CE2746' ) . '"'; | |
| 26 | - } else { | |
| 27 | - $color = 'style="background-color: ' . ( $color ? $color : '#CE2746' ) . ';"'; | |
| 28 | - } | |
| 29 | - } else { | |
| 30 | - $color = 'style="background-color: ' . ( $color ? $color : '#CE2746' ) . ';"'; | |
| 31 | - } | |
| 32 | - } | |
| 33 | - } | |
| 34 | - if ( $attr['onlyCatColor'] ) { | |
| 35 | - $category .= '<a class="ultp-cat-' . $val->slug . '" href="' . get_term_link( $val->term_id ) . '" ' . $color . ' ' . ( $attr['openInTab'] ? 'target="_blank"' : '' ) . '>' . $val->name . '</a>'; | |
| 36 | - } else { | |
| 37 | - $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>'; | |
| 38 | - } | |
| 39 | - } | |
| 40 | - } | |
| 41 | - $category .= '</div>'; | |
| 42 | - $category .= '</div>'; | |
| 43 | -} | |
| 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, 'category'); | |
| 9 | + if (!empty($cat)) { | |
| 10 | + foreach ($cat as $val) { | |
| 11 | + $color = ''; | |
| 12 | + if (isset($attr['customCatColor'])){ | |
| 13 | + if ($attr['customCatColor']){ | |
| 14 | + $color = get_term_meta($val->term_id, 'ultp_category_color', true); | |
| 15 | + if(isset($attr['onlyCatColor'])){ | |
| 16 | + if($attr['onlyCatColor']){ | |
| 17 | + $color = 'style="color: '.($color ? $color : '#CE2746').'"'; | |
| 18 | + }else{ | |
| 19 | + $color = 'style="background-color: '.($color ? $color : '#CE2746').';color: #fff;"'; | |
| 20 | + } | |
| 21 | + }else{ | |
| 22 | + $color = 'style="background-color: '.($color ? $color : '#CE2746').';color: #fff;"'; | |
| 23 | + } | |
| 24 | + } | |
| 25 | + } | |
| 26 | + if($attr['onlyCatColor']){ | |
| 27 | + $category .= '<a class="ultp-cat-'.$val->slug.'" href="'.get_term_link($val->term_id).'" '.$color.' '.($attr['openInTab'] ? 'target="_blank"' : '').'>'.$val->name.'</a>'; | |
| 28 | + } else { | |
| 29 | + $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>'; | |
| 30 | + } | |
| 31 | + } | |
| 32 | + } | |
| 33 | + $category .= '</div>'; | |
| 34 | + $category .= '</div>'; | |
| 35 | +} | |