Skip to content

Instantly share code, notes, and snippets.

@jrevillini
jrevillini / jquery.waypoints.min.js
Created August 31, 2021 21:05
waypoints for elementor which will not override window.onload handlers/listeners
!function(){"use strict";var e=0,r={};function i(t){if(!t)throw new Error("No options passed to Waypoint constructor");if(!t.element)throw new Error("No element option passed to Waypoint constructor");if(!t.handler)throw new Error("No handler option passed to Waypoint constructor");this.key="waypoint-"+e,this.options=i.Adapter.extend({},i.defaults,t),this.element=this.options.element,this.adapter=new i.Adapter(this.element),this.callback=t.handler,this.axis=this.options.horizontal?"horizontal":"vertical",this.enabled=this.options.enabled,this.triggerPoint=null,this.group=i.Group.findOrCreate({name:this.options.group,axis:this.axis}),this.context=i.Context.findOrCreateByElement(this.options.context),i.offsetAliases[this.options.offset]&&(this.options.offset=i.offsetAliases[this.options.offset]),this.group.add(this),this.context.add(this),r[this.key]=this,e+=1}i.prototype.queueTrigger=function(t){this.group.queueTrigger(this,t)},i.prototype.trigger=function(t){this.enabled&&this.callback&&this.callback.apply(th
// this should work in most cases to fix escaped quotes when querystring var has a quote (' or ") and is the value of an input or textarea
// it does not handle hidden fields ... feel free to improve on it or leave a comment with ideas
jQuery( function ( $ ) {
$( document ).on( 'nfFormReady', function ( ) {
$( 'textarea.ninja-forms-field,input[type=text].ninja-forms-field' ).each( function () {
var $input = $(this),
val = $input.val();
val = val.replace(/\\'/gm,"'").replace(/\\"/gm,'"');
$input.val(val).change();
} ); //each
@jrevillini
jrevillini / auto-open-slidebars.php
Last active July 21, 2019 14:50
open slidebar after 2 secconds
add_action( 'wp_footer', function () { ?>
<script>
// don't run until main slidebars init has happened to avoid JS error
jQuery( window ).on( 'ocs_after', function () {
// @TODO add cookie test
// @TODO add skip list
// @TODO add config based on body class or something
@jrevillini
jrevillini / lazy-elementor-background-images.php
Last active June 22, 2022 16:31
lazyload elementor background images
<?php
// NEWS!!! NEWS!!! **** FEBRUARY 2020 //
// I rolled this code into a plugin!
// Download plugin Lazy Load Background Images for Elementor. Link is in comments below.
// Or go to https://james.revillini.com/projects/
// if you don't want another plugin, the code below works (last time I checked)
@jrevillini
jrevillini / bp-custom.php
Last active March 18, 2021 21:51
BBPress / REDIRECT REPLY POSTS TO TOPIC WITH REPLY ANCHOR
<?php
// ---------------------------------------- REDIRECT REPLY POSTS TO TOPIC WITH REPLY ANCHOR
function jrevillini_reply_redirect( $wp_query ) {
if ( !function_exists('bbp_get_reply_url') ) return; // skip this if bbpress not active
if ( !isset($wp_query->query['reply']) ) return; // skip if not a bbpress reply page
if ( isset($wp_query->query['edit']) ) return; //skip if we are EDITING a bbpress reply
wp_safe_redirect( bbp_get_reply_url( $wp_query->query['reply'] ) );
}
add_action('pre_get_posts', 'jrevillini_reply_redirect');
@jrevillini
jrevillini / auto-focus-username.login-with-ajax.js
Last active April 16, 2018 13:47
Auto-focus username field for Wordpress Plugin Login With Ajax
// ------------------ AUTOFOCUS ON USERNAME FIELD WHEN SIGNING IN
$(document).on('click', '.lwa-links-modal', function(e){
$('#lwa_user_login').focus();
});