Skip to content

Commit

Permalink
* Dev - Updating the FacetWP Queries
Browse files Browse the repository at this point in the history
  • Loading branch information
krugazul committed Jul 26, 2019
1 parent c49ef92 commit 18e31e5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Dev - Imroving search styles.
* Dev - Adding filter number to search results on mobile.
* Fix - Restricted the post type labels to the global search only.
* Dev - Updating the FacetWP Queries

### 1.2.0 - 21 June 2019
* Dev - Adding rel="noopener noreferrer" tags to target="_blank" links
Expand Down
6 changes: 2 additions & 4 deletions classes/class-lsx-to-search-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ public function search_form( $atts = array() ) {
<div class="<?php echo wp_kses_post( $field_class ); ?>">
<?php
$facet = FWP()->helper->get_facet_by_name( $facet );
$values = $this->get_form_facet( $facet['source'] );
$values = $this->get_form_facet( $facet['name'] );
$this->display_form_field( 'select',$facet,$values,$combo_box );
?>
</div>
Expand Down Expand Up @@ -873,17 +873,15 @@ protected function get_form_facet( $facet_source = false ) {
$values = array();
$select = 'f.facet_value, f.facet_display_value';
$from = "{$wpdb->prefix}facetwp_index f";
$where = "f.facet_source = '{$facet_source}'";
$where = "f.facet_name = '{$facet_source}'";

//Check if the current facet is showing destinations.
if ( stripos( $facet_source, 'destination_to' ) ) {
$from .= " INNER JOIN {$wpdb->posts} p ON f.facet_value = p.ID";
$where .= " AND p.post_parent = '0'";

}

$response = $wpdb->get_results( "SELECT {$select} FROM {$from} WHERE {$where}" ); // WPCS: unprepared SQL OK.

if ( ! empty( $response ) ) {
foreach ( $response as $re ) {
$values[ $re->facet_value ] = $re->facet_display_value;
Expand Down

0 comments on commit 18e31e5

Please sign in to comment.