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( 'search-filter/frontend/enqueue_styles', 'search_filter_remove_ugc_styles' ); | |
/** | |
* Remove UGC styles (Styles Presets CSS file) | |
*/ | |
function search_filter_remove_ugc_styles( $styles ) { | |
$position = array_search( 'search-filter-ugc-styles', $styles, true ); |
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 Search & Filter filtering to a Generate blocks query loop. | |
add_filter( 'generateblocks_query_loop_args', function ( $query_args, $attributes ) { | |
// Replace `1234` with your S&F query ID. | |
$query_args['search_filter_query_id'] = 1234; | |
return $query_args; | |
}, 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
/** | |
* These hooks re-implement the now removed useBlocker and usePrompt hooks in 'react-router-dom'. | |
* Thanks for the idea @piecyk https://github.com/remix-run/react-router/issues/8139#issuecomment-953816315 | |
* Source: https://github.com/remix-run/react-router/commit/256cad70d3fd4500b1abcfea66f3ee622fb90874#diff-b60f1a2d4276b2a605c05e19816634111de2e8a4186fe9dd7de8e344b65ed4d3L344-L381 | |
*/ | |
import { useContext, useEffect, useCallback } from 'react'; | |
import { UNSAFE_NavigationContext as NavigationContext } from 'react-router-dom'; | |
/** | |
* Blocks all navigation attempts. This is useful for preventing the page from | |
* changing until some condition is met, like saving form data. |
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
//detects the start of an ajax request being made | |
$(document).on("sf:ajaxstart", ".searchandfilter", function(){ | |
console.log("ajax start"); | |
}); | |
//detects when the ajax request has finished and the content has been updated | |
// - add scripts that apply to your results here | |
$(document).on("sf:ajaxfinish", ".searchandfilter", function(){ | |
console.log("ajax complete"); | |
//so load your lightbox or JS scripts here again |
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 filter_input_object($input_object, $sfid) | |
{ | |
//ensure we are only filtering the correct field name - in this case the field we want to filter has the name `_sfm_colours` | |
//we also want to make sure its a `select` input type we're filtering | |
if(($input_object['name']!='_sfm_colours')||($input_object['type']!='select')) | |
{ | |
return $input_object; | |
} | |
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 an ACF post relationship field type using a shortcode: | |
* [ca_acf_relationship_field field="field_name"] | |
* You can also pass `post_id` as an attribute | |
* | |
* Works with Post Object and Relationship fields, when the return | |
* format is both post object and post ID | |
* | |
* This code assumes you are copying this into functions.php of |
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 | |
//Get the search term | |
//replace `1526` with the ID of your search form | |
global $searchandfilter; | |
$sf_current_query = $searchandfilter->get(1526)->current_query(); | |
echo $sf_current_query->get_search_term(); | |
?> |
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 hck_filter_taxonomy_archives( $query_args, $sfid ) { | |
if( $sfid == 509 ) { | |
$query_args['post_type'] = 'articles'; | |
} | |
return $query_args; | |
} |
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 custom colors to the WordPress editor via `add_theme_support` | |
* | |
* This takes the existing colours (if your theme or a plugin has set any) | |
* and combines them with a new set of colours defined in the function | |
* | |
* New colours should be visible in the various color pickers found in | |
* WordPress admin | |
*/ |
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
/** | |
* WordPress dependencies | |
*/ | |
import { createReduxStore, register, controls } from '@wordpress/data'; | |
import apiFetch from '@wordpress/api-fetch'; | |
import { addQueryArgs } from '@wordpress/url'; | |
export const STORE_NAME = 'search-filter/settings'; | |
const getUniqueKey = ( args ) => { |
NewerOlder