Skip to content

Instantly share code, notes, and snippets.

@djrmom
djrmom / facet.js
Created July 17, 2020 19:49
facetwp prevents template change while still changing facets
$(function() {
FWP.hooks.addFilter('facetwp/template_html', function() {
return true;
}, 200 );
});
@djrmom
djrmom / facet.css
Created July 15, 2020 19:56
facetwp make more space for locate me icon on mobile
/** adjust as needed to fit mobile phones better **/
@media only screen and (max-width: 767px) {
#facetwp-radius {
display:block;
float: none;
width: 100%;
}
.location-wrap {
width: 100%
@djrmom
djrmom / facet.css
Last active September 7, 2020 15:33
facetwp checkbox styles
/** style checked label differently **/
.facetwp-type-checkboxes .facetwp-checkbox.checked {
color: red;
text-decoration: underline;
font-style: italic;
font-weight: bold;
}
/** basic example of inline row of checkboxes **/
.facetwp-type-checkboxes .facetwp-checkbox {
@djrmom
djrmom / custom-hooks.php
Last active September 30, 2020 19:54
facetwp set order of (or remove) flyout facets
<?php
add_action( 'wp_footer', function() {
?>
<script>
(function($) {
if ('object' !== typeof FWP) {
return;
}
FWP.hooks.addFilter('facetwp/flyout/facets', function(facets) {
return ['facet3', 'facet1', 'facet2']; // change the facet display order
@djrmom
djrmom / flyout.html
Created July 13, 2020 22:04
facetwp add reset to flyout
<div class="facetwp-flyout-tpl">
{content}
<button onclick="FWP.reset()">Reset</button>
</div>
@djrmom
djrmom / custom-hooks.php
Created July 13, 2020 13:33
facetwp enable product category display support
<?php
/** enables filter when show product catgories is enabled in woocommerce **/
add_filter( 'facetwp_woocommerce_support_categories_display', '__return_true' );
@djrmom
djrmom / facet.js
Created July 9, 2020 17:59
facetwp set a facet selections to a different facet
(function($) {
$(document).on('facetwp-refresh', function() {
if ( 'undefined' !== typeof FWP.facets['facet_1'] && FWP.facets['facet_1'].length > 0 ) {
FWP.facets['facet_2'] = FWP.facets['facet_1'];
FWP.facets['facet_1'] = [];
}
});
})(jQuery);
@djrmom
djrmom / facet.php
Last active July 9, 2020 17:57
facetwp wp bakery regex for refresh
<?php echo wp_trim_words( preg_replace( '/\[vc_empty_space(\s)*(.)*]/', ' ', strip_tags( do_shortcode( get_the_content() ) ) ), 20 ); ?>
@djrmom
djrmom / custom-hooks.php
Last active July 9, 2020 17:22
facetwp do shortcode on advanced display code
<?php
/** run shortcodes for a facetwp template **/
add_filter( 'facetwp_template_html', function( $output, $class ) {
return do_shortcode( $output );
}, 10, 2 );
@djrmom
djrmom / facet.css
Last active January 6, 2021 19:49
facetwp fselect css
/** you may need to use !important to force css styles
** width: 300px !important;
** or see https://www.w3schools.com/css/css_specificity.asp for adding css specificity to your css
** rules
**/
/** change width of fselect **/
.facetwp-type-fselect .fs-wrap,
.facetwp-type-fselect .fs-dropdown {
width: 300px;