Skip to content

Instantly share code, notes, and snippets.

View fabrizim's full-sized avatar

fabrizim

View GitHub Profile
@fabrizim
fabrizim / replace-bird-with-x.php
Last active November 28, 2023 09:30
Elementor: Replace Twitter Icon with new X Icon
<?php
add_filter( 'elementor/widget/render_content', function($output){
// replace the
$re = '/(<svg[^>]+class="[^"]*e-fab-twitter".*?<path\s+d=")(.+?)(".+?<\/svg>)/s';
$output = preg_replace_callback($re, function($matches){
$path = "M389.2 48h70.6L305.6 224.2 487 464H345L233.7 318.6 106.5 464H35.8L200.7 275.5 26.8 48H172.4L272.9 180.9 389.2 48zM364.4 421.8h39.1L151.1 88h-42L364.4 421.8z";
return $matches[1].$path.$matches[3];
}, $output);
return $output;
@fabrizim
fabrizim / get_posts_related_by_common_terms.php
Last active June 22, 2021 12:42
get_posts_related_by_common_terms.php
function stripScript( html ){
let match;
const re = /<script[^>]+?src=['"](.+?)['"][^>]*?><\/script>/gi;
while( (match =re.exec(html)) ){
const script = document.createElement('script');
script.src = match[1];
document.body.appendChild( script );
}
html = html.replace(re, '');
import Cookies from './cookies';
import distance from './geo';
const $ = jQuery;
class UserLocation {
constructor(){
this.stores = cabothouse_config.locations;
this.initLocation();
this.initEvents();
@fabrizim
fabrizim / snippet.html
Last active June 18, 2019 20:19
Installing the LIHTC chart
<div
style="margin-bottom: 30px; position: relative; z-index: 2"
data-freddiemac-chart="lihtc"
data-xls="PATH/TO/DIST/lihtc/data/LIHTC-data.xlsx"
></div>
<script type="text/javascript" src="PATH/TO/DIST/common/embed.js"></script>
{% capture email_title %}Thank you for your purchase! {% endcapture %}
{% capture email_body %}Hi {{ customer.first_name }}, we're getting your order ready to be shipped. We will notify you when it has been sent.{% endcapture %}
{% assign presale_order = false %}
{% for line in line_items %}
{% if line.sku == 'WAV-E-B1' %}
{% assign presale_order = true %}
{% endif %}
{% endfor %}
@fabrizim
fabrizim / vc_row.php
Last active May 8, 2018 15:36
Jupiter Theme 6.1.3 - ID Attribute Escaped Twice
<?php
$path = pathinfo( __FILE__ ) ['dirname'];
include( $path . '/config.php' );
wp_enqueue_script( 'wpb_composer_front_js' );
$fullwidth_start = $output = $fullwidth_end = '';
@fabrizim
fabrizim / .htaccess
Last active March 12, 2020 17:36
wp-content/uploads filler for staging environments
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^wp\-content\/uploads(.*)$ https://production-domain.com/wp-content/uploads$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^wp\-content\/blogs(.*)$ https://production-domain.com/wp-content/blogs$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
@fabrizim
fabrizim / search.js
Created April 28, 2017 17:23
Search Form Handler
var $ = jQuery;
module.exports = {
init : function(){
$(document).on('submit', 'form.searchform', function(e){
if( window.angular ){
e.preventDefault();
var $form = $(e.currentTarget);
var data = $form.serialize();
var $injector = angular.element( $('html')[0] ).injector();
@fabrizim
fabrizim / jquery.prebind.js
Created October 17, 2015 01:29 — forked from jonathanconway/jquery.prebind.js
preBind() - Add an event binding *before* any pre-existing bindings. (An early version, may not work in all scenarios)
$.fn.preBind = function(type, data, fn) {
var currentBindings = this.data('events')[type];
var currentBindingsLastIndex = currentBindings.length - 1;
var newBindings = [];
// bind the event
this.bind(type, data, fn);
// move the new event to the top of the array
newBindings.push(currentBindings[currentBindingsLastIndex]);