Gists

5 months ago
<?php

/**
 *
 * This assumes a facet named "product_catalogue" using "product_cats" taxonomy
 *
 * If the facet is in use, it will send to the browser an object containing terms
 * (type `FWP_JSON.product_cat` into the browser console)
 *
 */
add_filter( 'facetwp_assets', function( $assets ) {
    $facet_name = 'product_catalogue';
    $taxonomy = 'product_cat';

    if ( isset( FWP()->facet->facets[ $facet_name ] ) ) {
        $selected = FWP()->facet->facets[ $facet_name ]['selected_values'];

        if ( ! empty( $selected ) ) {
            FWP()->display->json[ $taxonomy ] = FWP()->helper->get_term_depths( $taxonomy );
        }
    }

    return $assets;
});
2 years ago
<?php
/** remove facet's custom javascript for woocommerce **/
add_filter( 'facetwp_assets', function( $assets ) {
    unset( $assets['woocommerce.js'] );
    return $assets;
});
2 years ago
<?php
/** remove facet's copy of google maps when another plugin or theme is already loading it **/
add_filter( 'facetwp_assets', function( $assets ) {
    unset( $assets['gmaps'] );
    return $assets;
});
2 years ago
<?php

add_filter( 'facetwp_load_assets', '__return_true' );

add_filter( 'facetwp_assets', function( $assets ) {
    $assets['fSelect.js'] = FACETWP_URL . '/assets/vendor/fSelect/fSelect.js';
    $assets['fSelect.css'] = FACETWP_URL . '/assets/vendor/fSelect/fSelect.css';
    return $assets;
});
5 years ago
<?php

add_filter( 'facetwp_assets', function( $assets ) {
    $assets['accessibility.js'] = FACETWP_URL . '/assets/js/src/accessibility.js';
    return $assets;
});