Skip to content

Commit

Permalink
Merge pull request #116 from ItinerisLtd/errors
Browse files Browse the repository at this point in the history
errors
  • Loading branch information
codepuncher committed Feb 19, 2024
2 parents adef2b1 + 8221f62 commit c2744e7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
10 changes: 5 additions & 5 deletions src/God.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,19 @@ public static function flGetLocations($postType): array
public static function flGetFilterCount($settings): int
{
$count = 0;
if (! $settings->show_filter) {
if (! ($settings->show_filter ?? false)) {
return $count;
}
if ($settings->show_search_filter) {
if ($settings->show_search_filter ?? false) {
$count++;
}
if (isset($settings->tax_exists) && $settings->tax_exists) {
if ($settings->tax_exists ?? false) {
$count++;
}
if ($settings->show_meta_filters) {
if ($settings->show_meta_filters ?? false) {
$count++;
}
if (isset($settings->show_role) && $settings->show_role) {
if ($settings->show_role ?? false) {
$count++;
}

Expand Down
17 changes: 9 additions & 8 deletions src/post-grid/filter-bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
// Show the posts filter.
$show_filter = false;
$tax_exists = false;
$post_type = 'main_query' === $settings->data_source ? (get_post_type() ?: 'post') : $settings->post_type;
if ($settings->show_filter) {
$post_type = (array) ('main_query' === $settings->data_source ? (get_post_type() ?: 'post') : $settings->post_type);
$post_type = reset($post_type);
if ($settings->show_filter ?? false) {
// Get the taxonomy name.
$category = ('post' === $post_type) ? 'category' : ('product' === $post_type ? 'product_cat' : $post_type . '_category');
// Check if the taxonomy exists.
Expand Down Expand Up @@ -59,10 +60,10 @@
?>
<?php if ('theme' === $settings->layout && $show_filter) : ?>
<section id="fab-search-block"
class="filter-form main-form<?php (! $settings->auto_filter) || ($settings->show_button) && print ' no-labels'; ?>"<?php $settings->auto_filter && print ' data-filter-auto="true"'; ?>>
class="filter-form main-form<?php (! ($settings->auto_filter ?? false)) || ($settings->show_button ?? false) && print ' no-labels'; ?>"<?php ($settings->auto_filter ?? false) && print ' data-filter-auto="true"'; ?>>
<form action="<?php echo esc_url(get_pagenum_link()); ?>" method="get" id="searchform">
<div class="row">
<?php if ($settings->show_search_filter) : ?>
<?php if ($settings->show_search_filter ?? false) : ?>
<div class="col-xs-12 col-sm-<?php echo sanitize_html_class($filter_col); ?>">
<div class="sfFormBox">
<div class="sfFieldWrap">
Expand All @@ -73,12 +74,12 @@ class="filter-form main-form<?php (! $settings->auto_filter) || ($settings->show
</div>
</div>
<?php endif; ?>
<?php if (isset($tax_exists) && $tax_exists) : ?>
<?php if ($tax_exists ?? false) : ?>
<div class="col-xs-12 col-sm-<?php echo sanitize_html_class($filter_col); ?>">
<?php $helper->taxonomyDropdown($category, 'Category', $post_type); ?>
</div>
<?php endif; ?>
<?php if ($settings->show_meta_filters) : ?>
<?php if ($settings->show_meta_filters ?? false) : ?>
<?php $locations = Itineris\SageFLBuilder\God::flGetLocations($post_type); ?>
<?php if (! empty($locations)) : ?>
<?php $current = get_query_var('location'); ?>
Expand All @@ -97,12 +98,12 @@ class="filter-form main-form<?php (! $settings->auto_filter) || ($settings->show
<?php endif; ?>
<?php endif; ?>
</div>
<?php if ($settings->show_button) : ?>
<?php if ($settings->show_button ?? false) : ?>
<input type="submit" class="btn btn-primary" value="Search"/>
<?php endif; ?>
</form>
</section>
<?php if ($settings->show_cat_desc) : ?>
<?php if ($settings->show_cat_desc ?? false) : ?>
<div class="filter-description"><?php echo term_description($term_id, $category); ?></div>
<?php endif; ?>
<?php endif; ?>

0 comments on commit c2744e7

Please sign in to comment.