Skip to content

Instantly share code, notes, and snippets.

@djrmom
djrmom / custom-hooks.php
Created November 16, 2017 16:01
facetwp select all
<?php
/**
* attaches a click even to a div that selects all of a checkbox facets available options and triggers a refresh
* change "product_categories" to the name of your facet
* <div class="facetwp-checkbox select-all">Select all</div> creates a div that looks like facet checkboxes
*
*/
add_action( 'wp_head', function() { ?>
<script>
@djrmom
djrmom / custom-hooks.php
Last active November 30, 2021 04:39
facetwp remove search from fselect
<?php
/**
** set option to disable fselect search field
**/
add_action( 'wp_footer', function() { ?>
<script>
(function($) {
FWP.hooks.addFilter('facetwp/set_options/fselect', function(opts, facet) {
if (facet.facet_name == 'product_categories') {
opts.showSearch = false;
@djrmom
djrmom / custom-hooks.php
Created July 24, 2018 20:19
facetwp auto enable filtering button on map
<?php
/**
** enable filtering on load of map
**/
add_action( 'wp_footer', function() {
?>
<script>
(function($) {
$(document).on('facetwp-loaded', function() {
var filterButton = $( ".facetwp-map-filtering" );
@djrmom
djrmom / scripts.js
Created January 8, 2018 22:06
facetwp check FWP in js
<script>
(function($) {
$(function() {
if ( 'undefined' !== typeof FWP ) {
// Make checkbox options semi-transparent
FWP.loading_handler = function(params) {
params.element.find('.facetwp-checkbox').css('opacity', 0.5);
}
}
});
@djrmom
djrmom / custom-hooks.php
Last active July 20, 2021 15:32
facetwp show/hide labels
<?php
add_action( 'wp_footer', function() {
?>
<script>
(function($) {
if ('object' !== typeof FWP) {
return;
}
$(function() {
@djrmom
djrmom / custom-hooks.php
Last active July 11, 2021 13:31
facetwp add tooltips to slider
<?php
/** adds tooltips to slider handles
** https://refreshless.com/nouislider/slider-options/#section-tooltips
** note that you need an array even if you want true for both handles
**/
add_action( 'wp_footer', function() { ?>
<script>
(function($) {
if ('object' != typeof FWP) {
@djrmom
djrmom / pagination-old.php
Last active June 9, 2021 13:22
facetwp woocommerce pagination
<?php
/**
* Pagination - Show numbered pagination for catalog pages
*
* This template can be overridden by copying it to yourtheme/woocommerce/loop/pagination.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
@djrmom
djrmom / functions.php
Created August 10, 2018 12:13
facetwp replace woocommerce sort with facet sort
<?php
if ( ! function_exists( 'woocommerce_catalog_ordering' ) ) {
/**
* Output facet sort box instead of woocommerce's
*/
function woocommerce_catalog_ordering() {
echo facetwp_display( 'sort' );
}
}
@djrmom
djrmom / custom-hooks.php
Created October 25, 2019 19:12
facetwp add reset button to flyout
<?php
/** appends your custom html before the facets output **/
add_action( 'wp_head', function() {
?>
<script>
(function($) {
$(function() {
if ('object' != typeof FWP) {
return;
}
@djrmom
djrmom / facet.js
Created March 20, 2019 19:52
facetwp trigger open of marker on map
(function($) {
$(document).on('click', '.post-item', function() {
var postid = $(this).attr('data-id');
var markers = FWP_MAP.get_post_markers(postid);
$.each( markers, function( key, value ) {
google.maps.event.trigger(value, 'click');
});
});
})(jQuery);