| @@ -1,25 +1,47 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * The Template for displaying Apply button. |
| 4 | 4 | * |
| 5 | - * This template can be overridden by copying it to yourtheme/filter/apply-button.php. | |
| 5 | + * This template can be overridden by copying it to yourtheme/filters/apply-button.php. | |
| 6 | 6 | * |
| 7 | 7 | * @see https://filtereverything.pro/resources/templates-overriding/ |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -if ( ! defined('WPINC') ) { | |
| 11 | - wp_die(); | |
| 10 | +if ( ! defined('ABSPATH') ) { | |
| 11 | + exit; | |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | $set_id = isset( $set['ID'] ) ? esc_html( $set['ID'] ) : 0; |
| 15 | +$horizontal_view = false; | |
| 16 | +if(!empty($set['horizontal_view']['value']) && $set['horizontal_view']['value'] === 'yes'){ | |
| 17 | + $horizontal_view = true; | |
| 18 | +} | |
| 19 | +$apply_button_page_type = false; | |
| 20 | +if(!empty($set['apply_button_page_type']['value']) && $set['apply_button_page_type']['value'] !== 'no_page___no_page'){ | |
| 21 | + $apply_button_page_type = true; | |
| 22 | +} | |
| 23 | +// Clean permalink of the Apply button location, WITHOUT the current filter | |
| 24 | +// segments. The JS appends the freshly selected segments to this base — using | |
| 25 | +// $apply_url for that duplicated the segments already present in the page URL. | |
| 26 | +$apply_base_url = isset( $apply_base_url ) ? $apply_base_url : ''; | |
| 27 | +$term_count_hidden_class = ''; | |
| 28 | +if(empty($is_filter_request) && !$is_filter_request){ | |
| 29 | + $term_count_hidden_class .= ' wpc-hidden-term-count'; | |
| 30 | +} | |
| 31 | +if (empty($found_posts)){ | |
| 32 | + $found_posts = 0; | |
| 33 | +} | |
| 15 | 34 | ?> |
| 16 | -<div class="wpc-filters-section wpc-filters-section-<?php echo $set_id; ?> wpc-filter-layout-submit-button"> | |
| 17 | - <a class="wpc-filters-submit-button" href="<?php echo esc_url( $apply_url ); ?>"><?php | |
| 18 | - $button_text = isset( $set['apply_button_text']['value'] ) ? esc_html( $set['apply_button_text']['value'] ) : esc_html__('Apply', 'filter-everything'); | |
| 19 | - echo $button_text; | |
| 20 | - ?></a> | |
| 21 | - <a class="wpc-filters-reset-button" href="<?php echo esc_attr( $reset_url ) ?>"><?php | |
| 22 | - $reset_button_text = isset( $set['reset_button_text']['value'] ) ? esc_html( $set['reset_button_text']['value'] ) : esc_html__('Reset', 'filter-everything'); | |
| 23 | - echo $reset_button_text; | |
| 24 | - ?></a> | |
| 35 | +<div class="wpc-filters-section wpc-filters-section-<?php echo $set_id; ?> wpc-filter-layout-submit-button <?php echo $horizontal_view ? '' : 'wpc-pc-sticky-buttons'; ?>"> | |
| 36 | + <div class="wpc-sticky-buttons"> | |
| 37 | + <a class="wpc-filters-submit-button" href="<?php echo esc_url( $apply_url ); ?>" data-wpc-apply-url="<?php echo esc_url( $apply_url ); ?>" data-wpc-apply-base-url="<?php echo esc_url( $apply_base_url ); ?>" data-apply-button-page="<?php echo esc_attr( $apply_button_page_type ) ?>"> | |
| 38 | + <?php | |
| 39 | + $button_text = isset( $set['apply_button_text']['value'] ) ? esc_html( $set['apply_button_text']['value'] ) : esc_html__('Show', 'filter-everything'); | |
| 40 | + echo $button_text . "<span class='wpc-pc-apply-button " . $term_count_hidden_class . "'>(" . esc_html($found_posts) . ")</span>"; | |
| 41 | + ?></a> | |
| 42 | + <a class="wpc-filters-reset-button wpc-filters-reset-button-<?php echo $set_id; ?>" href="<?php echo esc_attr( $reset_url ) ?>" data-wpc-apply-reset-url="<?php echo esc_url( $reset_url ); ?>"><?php | |
| 43 | + $reset_button_text = isset( $set['reset_button_text']['value'] ) ? esc_html( $set['reset_button_text']['value'] ) : esc_html__('Reset', 'filter-everything'); | |
| 44 | + echo $reset_button_text; | |
| 45 | + ?></a> | |
| 46 | + </div> | |
| 25 | 47 | </div> |