Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
burhandodhy committed Jun 15, 2022
1 parent 7a8c3d0 commit c061392
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions includes/classes/Feature/Facets/Facets.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,11 @@ public function is_facetable( $query ) {
return false;
}

if ( $query->is_home()
|| $query->is_search()
|| $query->is_tax()
|| $query->is_tag()
|| $query->is_category()
|| $query->is_post_type_archive() ) {
return true;
if ( ! $this->is_facetable_page( $query ) ) {
return false;
}

return false;
return true;
}

/**
Expand Down Expand Up @@ -556,4 +551,15 @@ public function get_facetable_taxonomies() {
*/
return apply_filters( 'ep_facet_include_taxonomies', $taxonomies );
}

/**
* Figure out if Facet widget can display on page.
*
* @param WP_Query $query WP Query
* @since 4.2.1
* @return bool
*/
protected function is_facetable_page( $query ) {
return $query->is_home() || $query->is_search() || $query->is_tax() || $query->is_tag() || $query->is_category() || $query->is_post_type_archive();
}
}

0 comments on commit c061392

Please sign in to comment.