| 1 |
<?php |
| 2 |
/** |
| 3 |
* The Template for displaying filter labels. |
| 4 |
* |
| 5 |
* This template can be overridden by copying it to yourtheme/filters/labels.php. |
| 6 |
* |
| 7 |
* $set - array, with the Filter Set parameters |
| 8 |
* $filter - array, with the Filter parameters |
| 9 |
* $url_manager - object, of the UrlManager PHP class |
| 10 |
* $terms - array, with objects of all filter terms except excluded |
| 11 |
* |
| 12 |
* @see https://filtereverything.pro/resources/templates-overriding/ |
| 13 |
*/ |
| 14 |
|
| 15 |
if ( ! defined('WPINC') ) { |
| 16 |
wp_die(); |
| 17 |
} |
| 18 |
|
| 19 |
?> |
| 20 |
<div class="<?php echo flrt_filter_class( $filter ); // Already escaped ?>" data-fid="<?php echo esc_attr( $filter['ID'] ); ?>"> |
| 21 |
<?php flrt_filter_header( $filter, $terms ); // Safe, escaped ?> |
| 22 |
<div class="<?php echo esc_attr( flrt_filter_content_class( $filter ) ); ?>"> |
| 23 |
<?php if( $filter['search'] === 'yes' && ! empty( $terms ) && $view_args['ask_to_select_parent'] === false ): ?> |
| 24 |
<div class="wpc-filter-search-wrapper wpc-filter-search-wrapper-<?php echo esc_attr( $filter['ID'] ); ?>"> |
| 25 |
<input class="wpc-filter-search-field" type="text" value="" placeholder="<?php esc_html_e('Search', 'filter-everything' ) ?>" /> |
| 26 |
<button class="wpc-search-clear" type="button" title="<?php esc_html_e('Clear search', 'filter-everything' ) ?>"><span class="wpc-search-clear-icon">×</span></button> |
| 27 |
</div> |
| 28 |
<?php endif; ?> |
| 29 |
<ul class="wpc-filters-ul-list wpc-filters-labels wpc-filters-list-<?php echo esc_attr( $filter['ID'] ); ?>"> |
| 30 |
<?php if( ! empty( $terms ) || $view_args['ask_to_select_parent'] ): |
| 31 |
|
| 32 |
if( $view_args['ask_to_select_parent'] !== false ) { ?> |
| 33 |
<li><?php echo esc_html( $view_args['ask_to_select_parent'] ); ?></li> |
| 34 |
<?php } else { |
| 35 |
foreach ( $terms as $id => $term_object ){ |
| 36 |
$disabled = 0; |
| 37 |
$checked = ( in_array( $term_object->slug, $filter['values'] ) ) ? 1 : 0; |
| 38 |
|
| 39 |
if( isset( $term_object->wp_queried ) && $term_object->wp_queried ){ |
| 40 |
$checked = 1; |
| 41 |
$disabled = 1; |
| 42 |
} |
| 43 |
|
| 44 |
$active_class = $checked ? ' wpc-term-selected' : ''; |
| 45 |
$disabled_class = $disabled ? ' wpc-term-disabled' : ''; |
| 46 |
$link = $url_manager->getTermUrl( $term_object->slug, $filter['e_name'] ); |
| 47 |
$link_attributes = 'href="'.esc_url($link).'"'; |
| 48 |
?> |
| 49 |
<li class="wpc-label-item wpc-term-item<?php echo esc_attr( $active_class ); ?><?php echo esc_attr( $disabled_class ); ?> wpc-term-count-<?php echo esc_attr( $term_object->cross_count ); ?> wpc-term-id-<?php echo esc_attr( $id ); ?>" id="<?php flrt_term_id('term', $filter, $id ); ?>"> |
| 50 |
<div class="wpc-term-item-content-wrapper"> |
| 51 |
<input class="wpc-label-input" <?php checked( 1, $checked ); disabled( 1, $disabled ); ?> type="checkbox" data-wpc-link="<?php echo esc_url( $link ); ?>" id="<?php flrt_term_id('checkbox', $filter, $id); ?>" /> |
| 52 |
<label for="<?php flrt_term_id('checkbox', $filter, $id); ?>"> |
| 53 |
<span class="wpc-filter-label-wrapper"> |
| 54 |
<?php |
| 55 |
/** |
| 56 |
* Allow developers to change filter terms html |
| 57 |
*/ |
| 58 |
echo apply_filters( 'wpc_filters_label_term_html', '<a '.$link_attributes.'>'.$term_object->name.'</a>', $link_attributes, $term_object, $filter ); |
| 59 |
|
| 60 |
?> <?php flrt_count( $term_object, $set['show_count']['value'] ); // Safe, escaped?> |
| 61 |
</span> |
| 62 |
</label> |
| 63 |
</div> |
| 64 |
</li> |
| 65 |
<?php } ?><!-- end foreach --> |
| 66 |
<?php } ?> |
| 67 |
<?php else: |
| 68 |
if( ! flrt_is_filter_request() ){ |
| 69 |
?><li><?php esc_html_e('There are no terms yet', 'filter-everything' ); |
| 70 |
if( flrt_is_debug_mode() ){ |
| 71 |
echo ' '.flrt_help_tip( |
| 72 |
esc_html__('Possible reasons: 1) Filter\'s criteria doesn\'t contain any terms yet and you have to add them 2) Terms may be created, but no one post that should be filtered attached to these terms 3) You excluded all possible terms in Filter\'s options.', 'filter-everything') |
| 73 |
); |
| 74 |
} |
| 75 |
?></li><?php |
| 76 |
}else{ |
| 77 |
esc_html_e('N/A', 'filter-everything' ); |
| 78 |
} |
| 79 |
?> |
| 80 |
<?php endif; ?><!-- end if --> |
| 81 |
</ul> |
| 82 |
</div> |
| 83 |
</div> |