This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'query', function( $query ) { | |
if ( false !== strpos( $query, 'facet_display_value LIKE' ) ) { | |
preg_match( "/LIKE '%(.*?)%'/s", $query, $matches ); | |
$keywords = $matches[1]; | |
if ( ! empty( $keywords ) ) { | |
$old_where = "facet_display_value LIKE '%$keywords%'"; | |
$new_where = array(); | |
$keywords_boom = explode( ' ', $keywords ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** always ignore archive query as main query for facet **/ | |
add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) { | |
if ( $query->is_archive() && $query->is_main_query() ) { | |
$is_main_query = false; | |
} | |
return $is_main_query; | |
}, 10, 2 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Check whether a SearchWP Engine has non-WP_Post Sources. | |
$engine = new \SearchWP\Engine( 'supplemental' ); | |
$sources = array_keys( $engine->get_sources() ); | |
$non_wp_post_sources = array_filter( $sources, function( $source ) { | |
return 0 !== strpos( $source, 'post' . SEARCHWP_SEPARATOR ); | |
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** layout builder output for woocommerce custom fields **/ | |
add_filter( 'facetwp_builder_item_value', function( $value, $item ) { | |
if ( 0 === strpos( $value, 'woo/' ) ) { | |
$field_key = substr( $value, 4 ); | |
if ( 'price' == $field_key ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* To access the data within the "Query Arguments" box, use: | |
* $this->http_params['choose_city'] | |
*/ | |
add_action( 'wp_footer', function() { | |
$choose_city = get_field( 'choose_city' ); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="path/to/fSelect.css" rel="stylesheet" type="text/css"> | |
<script src="path/to/fSelect.js"> | |
<script> | |
(function($) { | |
$(document).on('facetwp-loaded', function() { | |
$('.facetwp-sort-select').fSelect(); | |
}); | |
})(jQuery); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* only filter product queries */ | |
add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) { | |
if ( 'product_query' != $query->get( 'wc_query' ) ) { | |
$is_main_query = false; | |
} | |
return $is_main_query; | |
}, 10, 2 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'facetwp_filtered_post_ids', 'car_zero_priced_last', 10, 2); | |
function car_zero_priced_last( $post_ids, $class ) { | |
if (!isset($class->ajax_params['http_params']['get']['fwp_sort'])) { | |
return $post_ids; | |
} | |
if (isset($class->ajax_params['http_params']['get']['fwp_sort']) && $class->ajax_params['http_params']['get']['fwp_sort'] != 'price_asc') { | |
return $post_ids; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** to use this make sure all queries to be used | |
** for facets have 'facetwp' => true in query args, including the | |
** query args setting in a facetwp template | |
**/ | |
// add 'facetwp' => false anytime it is not already set | |
add_action( 'pre_get_posts', function( $query ) { | |
if ( ! isset( $query->query_var['facetwp'] ) ) { | |
$query->set( 'facetwp', false ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Translation Updates Table | |
* | |
* @author Pascal Birchler <[email protected]> | |
* @license GPL2+ | |
*/ | |
/** | |
* Displays a table with available translation updates. |
NewerOlder