Skip to content

Instantly share code, notes, and snippets.

View rmorse's full-sized avatar

Ross Morsali rmorse

View GitHub Profile
<?php
/**
* Search & Filter Pro
*
* Sample Results Template
*
* @package Search_Filter
* @author Ross Morsali
* @link https://searchandfilter.com
* @copyright 2018 Search & Filter
@rmorse
rmorse / class-handlebars-helpers.php
Last active May 3, 2022 09:18
Adds support for `if truthy`, `if falsy`, `if equals` and `if not equals` to Handlebars PHP - https://github.com/salesforce/handlebars-php
<?php
/**
* Adds helpers to Handlebars to support the following expressions:
*
* If truthy - `{{#if_truthy varName}}...{{/if_truthy}}`
* If falsy - `{{#if_falsy varName}}...{{/if_falsy}}`
* If equal - `{{#if_equal varName anotherVar}}...{{/if_equal}}`
* If not equal - `{{#if_not_equal varName anotherVar}}...{{/if_not_equal}}`
*
* Supports the PHP implementation of Handlebars found here: https://github.com/salesforce/handlebars-php
// re init layout after ajax request
$( document ).on( "sf:ajaxfinish", ".searchandfilter", function( e, data ) {
if ( window.elementorFrontend && window.elementorFrontend.elementsHandler && window.elementorFrontend.elementsHandler.runReadyTrigger) {
var runReadyTrigger = window.elementorFrontend.elementsHandler.runReadyTrigger;
runReadyTrigger( data.targetSelector );
// NEW - re-init elementor widgets inside the new results:
var ajaxTarget = $( data.targetSelector );
if ( ajaxTarget.length > 0 ) {
ajaxTarget.find( '.elementor-widget' ).each( function () {
@rmorse
rmorse / sf-pro-active-query-is-filtered.php
Created January 20, 2016 08:20
Search & Filter Pro - Active Query - Check to see if a user has selected any filters
<?php
//Get an array of objects containing data for the current search/filter
//replace `1526` with the ID of your search form
global $searchandfilter;
$sf_current_query = $searchandfilter->get(1526)->current_query();
echo $sf_current_query->is_filtered();
?>
@rmorse
rmorse / change-prefix.php
Last active October 26, 2020 09:22
Bulk change WordPress table prefix
<?php
// Warning: There is nothing safe about this script - don't use in production - make a backup. Always delete when finished.
/*
* Use this script to change the table prefix (renames the tables) in your WordPress install.
* Instructions:
* - Put this in a subdirectory from the root of your install - ie, create a new directory in the same folder as `wp-config.php`
and put this in it
* - Change the values `$old_prefix` and `$new_prefix` below, to match your requirements
* - Change the `$table_prefix` var in `wp-config.php` to your new prefix
.search-filter-result-item{
overflow: auto;
}
.search-filter-results-image{
display: block;
width: 30%;
vertical-align: top;
float: left;
}
@rmorse
rmorse / basic-richtext-block.js
Last active December 26, 2018 21:27
Basic Gutenberg Block, with a RichText Component and a Button on a Toolbar thats logs to console - https://codeamp.com/interacting-with-gutenbergs-richtext-component-using-a-button/
var el = wp.element.createElement;
const { __ } = wp.i18n; // Import __() from wp.i18n
const { registerBlockType } = wp.blocks; // Import registerBlockType() from wp.blocks
const { RichText, BlockControls, BlockFormatControls, AlignmentToolbar } = wp.editor;
const { Button, Dashicon, Tooltip, IconButton, Toolbar } = wp.components;
const { Component, Fragment } = wp.element;
//standard registerBlockType init
registerBlockType( 'my-block-plugin/block-w-insert-shortcode', {
title: 'Block w Shortcode Button', //any title you like
@rmorse
rmorse / sf-pro-active-query-multiple-fields.php
Last active March 9, 2017 19:09
Search & Filter Pro - Active Query - Get multiple fields by passing an array of field names
<?php
//Get a multiple fields values by passing an array of field names
//replace `1526` with the ID of your search form
global $searchandfilter;
$sf_current_query = $searchandfilter->get(1526)->current_query();
/*
* EXAMPLE 1
*/
@rmorse
rmorse / sf-marketify-ajax.js
Created March 3, 2017 16:55
Search & Filter Pro - Marketify Ajax
(function ( $ ) {
"use strict";
$(document).on("sf:ajaxfinish", ".searchandfilter", function(){
var grid;
$(el).find($('.edd_download.content-grid-download')).attr('style', '');
grid = document.querySelector(el);
salvattore['register_grid'](grid);
});
}(jQuery));
@rmorse
rmorse / sf-pro-active-query.php
Created September 22, 2015 17:47
Search & Filter Pro - Active Query
<?php
//grab the active query from our search form
//replace `1526` with the ID of your search form
global $searchandfilter;
$sf_current_query = $searchandfilter->get(1526)->current_query();
?>