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 | |
/** index a url or file path value as the extension to create a file type facet | |
** facet datasource needs to be a value that contains a url or file path for the file that includes the file extension | |
**/ | |
add_filter( 'facetwp_index_row', function( $params, $class ) { | |
if ( 'my_facet_name' == $params['facet_name'] ) { | |
$raw_value = $params['facet_value']; | |
$extension = end( explode ( '.', $raw_value) ); | |
if ( !$extension ) |
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_index_row', function( $params, $class ) { | |
if ( 'walking_mobility' == $params['facet_name'] ) { | |
if ( "No" == $params['facet_display_value'] ) { | |
$params['facet_value'] = ''; // skip indexing | |
} elseif ( "Yes" == $params['facet_display_value'] ) { | |
$params['facet_display_value'] = 'Walking Mobility'; | |
} | |
} |
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 | |
/** | |
** output only total results | |
**/ | |
add_filter( 'facetwp_result_count', function( $output, $params ) { | |
$output = $params['total'] . ' results'; | |
return $output; | |
}, 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
(function($) { | |
$(document).on('change', '.facetwp-facet-product_tags', function() { // change product_tags to name of dropdown facet | |
FWP.parse_facets(); | |
FWP.set_hash(); | |
var query = FWP.build_query_string(); | |
window.location.href = '/search-results/?' + query; // search-results to correct page | |
}); | |
})(jQuery); |
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 | |
function fwp_preload_facets() { | |
?> | |
<script> | |
(function($) { | |
$(document).on('facetwp-loaded', function() { | |
if ( '' == FWP.build_query_string() && 'shop' == FWP_HTTP.uri) { | |
FWP.is_reset = true; | |
FWP.facets['product_categories'] = ['clothing']; |
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
(function($) { | |
$(document).on('facetwp-refresh', function() { | |
if ( 'fr/accueil' == FWP_HTTP.uri && 'undefined' !== typeof FWP.facets['categories'] && FWP.facets['categories'].length > 0 ) { | |
var query = FWP.build_query_string(); | |
window.location.href = '/search-results/?' + query; | |
} | |
}); | |
})(jQuery); |
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 | |
/** | |
* adds js code to check for any facets being selected | |
*/ | |
add_action( 'wp_head', function() { ?> | |
<script> | |
(function($) { | |
$(document).on('facetwp-loaded', function() { | |
var facets_in_use = function() { | |
var in_use = 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
<script> | |
(function($) { | |
/** | |
* check if a facet exists but is empty, change 'categories' to name of the facet being checked | |
*/ | |
$(document).on('facetwp-loaded', function() { | |
if ('undefined' !== typeof FWP.facets['categories'] && FWP.facets['categories'].length < 1 ) { | |
// do something if facet is empty | |
} | |
}); |
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
(function($) { | |
$(document).on('facetwp-loaded', function() { | |
$('.facetwp-type-checkboxes').children('.facetwp-checkbox').addClass( 'disabled '); | |
}); | |
})(jQuery); |
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_action( 'wp_head', function() { ?> | |
<script> | |
(function($) { | |
$(function() { | |
FWP.hooks.addAction('facetwp/loaded', function() { | |
$('.facetwp-type-checkboxes .facetwp-depth.visible').prev('.facetwp-checkbox').toggleClass('expanded'); | |
}, 100 ); | |
}); |