Skip to content

Instantly share code, notes, and snippets.

@jmabbas
Created May 1, 2025 08:05
Show Gist options
  • Save jmabbas/89808802a8520dd3952375e79a9dccfc to your computer and use it in GitHub Desktop.
Save jmabbas/89808802a8520dd3952375e79a9dccfc to your computer and use it in GitHub Desktop.
Finder - functions
function finder_sidebar_button() {
?>
<button class="btn btn-primary btn-sm w-100 rounded-0 fixed-bottom d-lg-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#blog-sidebar">
<i class="fi-sidebar-right me-2"></i><?php echo esc_html('Sidebar') ?>
</button>
<?php
}
function finder_hivepress_category_filter_dropdown() {
$taxonomy = 'hp_listing_category';
$listing_get_query_args = get_queried_object();
$listing_style = finder_hivepress_get_listings_style();
$listing_category_args = array(
'taxonomy' => $taxonomy,
'hide_empty' => true,
'orderby' => 'slug',
);
$label_class = "";
if ( $listing_style === "car-finder") {
$label_class = "text-light";
}
$categories_list = get_categories( $listing_category_args );
if ( ! empty ( $categories_list )):
$i = 0;
?>
<div class="pb-4 mb-2">
<h3 class="h6 <?php echo esc_attr( $label_class ); ?>">Category</h3>
<div class="dropdown mb-sm-0 mb-3" data-bs-toggle="select">
<button class="btn btn-outline-secondary d-flex align-items-center w-100 px-4 fw-normal text-start dropdown-toggle" type="button" data-bs-toggle="dropdown"><i class="fi-list me-2 text-muted"></i><span class="dropdown-toggle-label d-block w-100"><?php echo esc_html( 'Categories' ); ?></span></button>
<?php if ( isset( $listing_get_query_args->term_id ) && $listing_get_query_args->term_id ) {
?><input type="hidden" value="<?php echo esc_attr($listing_get_query_args->term_id); ?>" name="_category" class="hivepress-elementor-dropdown"><?php
}
else{
?><input type="hidden" name="_category" class="hivepress-elementor-dropdown"><?php
}?>
<?php
?>
<ul class="dropdown-menu w-100">
<?php foreach ( $categories_list as $index => $category ) :
if( 0 === $i ){
?><li>
<a class="dropdown-item" href="#">
<?php
if ( finder_is_acf_activated() ) {
?><i class="fi-home me-2 fs-lg opacity-60"></i><?php
} ?>
<span class="dropdown-item-value d-none"><?php echo esc_html( 0 ); ?></span><span class="dropdown-item-label hivepress-advanced"><?php echo esc_html__( "All Categories", 'finder' ); ?></span>
</a>
</li><?php
}
?>
<?php if ( isset( $listing_get_query_args->taxonomy) && $listing_get_query_args->term_id === $category->term_id ) {
?><li>
<a class="dropdown-item" href="#">
<?php
if ( finder_is_acf_activated() ) {
$icon_class = finder_acf_get_term_field( 'hp_listing_category_icon', 'hp_listing_category', $category->term_id );
if ( ! empty( $icon_class )) {
?><i class="<?php echo esc_attr( $icon_class ); ?> me-2 fs-lg opacity-60"></i><?php
}
} ?>
<span class="dropdown-item-value d-none"><?php echo esc_html( $category->term_id ); ?></span><span class="dropdown-item-label hivepress-advanced"><?php echo esc_html( $category->name ); ?></span>
</a>
</li><?php
}
if( ! isset( $listing_get_query_args->taxonomy) ) {
?><li>
<a class="dropdown-item" href="#">
<?php
if ( finder_is_acf_activated() ) {
$icon_class = finder_acf_get_term_field( 'hp_listing_category_icon', 'hp_listing_category', $category->term_id );
if ( ! empty( $icon_class )) {
?><i class="<?php echo esc_attr( $icon_class ); ?> me-2 fs-lg opacity-60"></i><?php
}
} ?>
<span class="dropdown-item-value d-none"><?php echo esc_html( $category->term_id ); ?></span><span class="dropdown-item-label hivepress-advanced"><?php echo esc_html( $category->name ); ?></span>
</a>
</li><?php
}?>
<?php
$i++;
endforeach; ?>
</ul>
</div>
</div>
<?php
endif;
}
function finder_post_protected_password_form() {
global $post;
$label = 'pwbox-' . ( empty( $post->ID ) ? wp_rand() : $post->ID );
?>
<form class="protected-post-form input-group finder-protected-post-form flex-column" action="<?php echo esc_url( home_url( 'wp-login.php?action=postpass', 'login_post' ) ); ?>" method="post">
<p><?php echo esc_html__( 'This content is password protected. To view it please enter your password below:', 'finder' ); ?></p>
<div class="d-flex align-items-center w-md-50">
<label class="mb-0 me-3 d-none d-md-block" for="<?php echo esc_attr( $label ); ?>"><?php echo esc_html__( 'Password:', 'finder' ); ?></label>
<div class="d-flex flex-grow-1">
<input class="input-text form-control" name="post_password" id="<?php echo esc_attr( $label ); ?>" type="password" style="border-top-right-radius: 0; border-bottom-right-radius: 0;"/>
<input type="submit" name="submit" class="btn btn-primary btn-sm" value="<?php echo esc_attr( 'Submit' ); ?>" style="border-top-left-radius: 0; border-bottom-left-radius: 0; transform: none;"/>
</div>
</div>
</form>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment