Skip to content

Instantly share code, notes, and snippets.

Avatar

Ross Morsali rmorse

View GitHub Profile
@rmorse
rmorse / change-prefix.php
Last active Oct 6, 2020
Bulk change WordPress table prefix
View change-prefix.php
<?php
// Warning: There is nothing safe about this script - don't use in production - make a backup.. etc
// This file, change-prefix.php must be in a subfolder from your web root (ie, in a subfolder where wp-config.php resides)
require_once( '../wp-load.php' ); // sideload WP - use $wpdb to connect to the DB
global $wpdb;
//only change the following 2 values
$new_prefix = 'prefix_'; //the prefix you want
$old_prefix = 'wp_'; //the prefix you have currently
@rmorse
rmorse / sf-pro-filter-input-object.php
Last active Mar 1, 2020
Search & Filter Pro - Filter Input Object
View sf-pro-filter-input-object.php
<?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;
}
View sf-pro-results-template-example-extra-css.css
.search-filter-result-item{
overflow: auto;
}
.search-filter-results-image{
display: block;
width: 30%;
vertical-align: top;
float: left;
}
View sf-pro-results-template-example.php
<?php
/**
* Search & Filter Pro
*
* Sample Results Template
*
* @package Search_Filter
* @author Ross Morsali
* @link https://searchandfilter.com
* @copyright 2018 Search & Filter
@rmorse
rmorse / sf-divi-ajax-blog.js
Created Mar 23, 2017
Search & Filter Pro - Divi Theme & Ajax - Blog Module (Grid)
View sf-divi-ajax-blog.js
//this code does the re-layout work needed when using S&F with the blog module, and when S&F Ajax is enabled
(function ( $ ) {
"use strict";
$(document).on("sf:ajaxfinish", ".searchandfilter", function(){
console.log("ajax complete");
var grids = document.getElementsByClassName('et_pb_blog_grid');
salvattore['register_grid'](grids[0]);
});
}(jQuery));
@rmorse
rmorse / sf-pro-ajax-events.js
Last active Jun 28, 2019
Search & Filter Pro - Ajax Events
View sf-pro-ajax-events.js
//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
@rmorse
rmorse / sf-pro-active-query-search-term.php
Last active Jun 17, 2019
Search & Filter Pro - Active Query - Get the search term
View sf-pro-active-query-search-term.php
<?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();
?>
@rmorse
rmorse / basic-richtext-block.js
Last active Dec 26, 2018
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/
View basic-richtext-block.js
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 / filter-sf-pro-query.php
Last active Jul 21, 2017 — forked from dryan1144/filter-sf-pro-query.php
This modifies the $query_args object (rather than replacing it, which removes all the settings that are already in the object created by S&F).
View filter-sf-pro-query.php
<?php
function hck_filter_taxonomy_archives( $query_args, $sfid ) {
if( $sfid == 509 ) {
$query_args['post_type'] = 'articles';
}
return $query_args;
}
@rmorse
rmorse / sf-pro-active-query-multiple-fields.php
Last active Mar 9, 2017
Search & Filter Pro - Active Query - Get multiple fields by passing an array of field names
View sf-pro-active-query-multiple-fields.php
<?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
*/
You can’t perform that action at this time.