Skip to content

Instantly share code, notes, and snippets.

@lucas-pelton
lucas-pelton / blockClicks.js
Last active July 3, 2019 14:28
Prevent multiple clicks and submissions in Contact Form 7
//http://epsiloncool.ru/programmirovanie/preventing-multiple-submits-in-contact-form-7
jQuery(document).on('click', '.wpcf7-submit', function(e){
if( jQuery('.ajax-loader').hasClass('is-active') ) {
e.preventDefault();
return false;
}
});
@lucas-pelton
lucas-pelton / search-replace.bash
Last active June 29, 2017 23:14
Search and replace for Wordfence WAF after CloudWays site clone
find . -type f -name "wordfence-waf.php" -exec sed -i 's/[0-9\-]*.cloudwaysapps.com/NEW.cloudwaysapps.com/g' {} +
find . -type f -name ".user.ini" -exec sed -i 's/[0-9\-]*.cloudwaysapps.com/NEW.cloudwaysapps.com/g' {} +
@lucas-pelton
lucas-pelton / auto-download.js
Created August 16, 2017 22:54
Auto Download Content from DataURL
// AUTO DOWNLOAD THE IMAGES --> Can be modified to use any DataURL, I suppose
var a = document.createElement('a');
a.href = canvas.toDataURL("image/jpeg");
a.download = 'sample.jpg';
document.body.appendChild(a);
a.click();
@lucas-pelton
lucas-pelton / data-scraper-bookmarklet.js
Created October 6, 2017 17:03
Artoo Data Scraper for Oregon Public Records
// include notify tool
!function(){function n(n,t){for(property in t)t.hasOwnProperty(property)&&(n[property]=t[property]);return n}function t(n,t){var e=document.createElement("div");e.className="notyf__toast";var o=document.createElement("div");o.className="notyf__wrapper";var i=document.createElement("div");i.className="notyf__icon";var a=document.createElement("i");a.className=t;var r=document.createElement("div");r.className="notyf__message",r.innerHTML=n,i.appendChild(a),o.appendChild(i),o.appendChild(r),e.appendChild(o);var c=this;return setTimeout(function(){e.className+=" notyf--disappear",e.addEventListener(c.animationEnd,function(n){n.target==e&&c.container.removeChild(e)});var n=c.notifications.indexOf(e);c.notifications.splice(n,1)},c.options.delay),e}function e(){var n,t=document.createElement("fake"),e={transition:"animationend",OTransition:"oAnimationEnd",MozTransition:"animationend",WebkitTransition:"webkitAnimationEnd"};for(n in e)if(void 0!==t.style[n])return e[n]}this.Notyf=function(){this
@lucas-pelton
lucas-pelton / process-cf7-submission.php
Created October 6, 2017 22:11
Grab CF7 submission on the way by and send to MailJet via API
<?php
/**
* The plugin bootstrap file
*
* This file is read by WordPress to generate the plugin information in the plugin
* admin area. This file also includes all of the dependencies used by the plugin,
* registers the activation and deactivation functions, and defines a function
* that starts the plugin.
*
@lucas-pelton
lucas-pelton / front-end.js
Last active October 6, 2017 22:53
FullSlate front end API WP plugin
// http://jillix.github.io/jQuery-sidebar/
(function($){$.fn.sidebar=function(options){var self=this;if(self.length>1){return self.each(function(){$(this).sidebar(options)})}var width=self.outerWidth();var height=self.outerHeight();var settings=$.extend({speed:200,side:"left",isClosed:false,close:true},options);self.on("sidebar:open",function(ev,data){var properties={};properties[settings.side]=0;settings.isClosed=null;self.stop().animate(properties,$.extend({},settings,data).speed,function(){settings.isClosed=false;self.trigger("sidebar:opened")})});self.on("sidebar:close",function(ev,data){var properties={};if(settings.side==="left"||settings.side==="right"){properties[settings.side]=-self.outerWidth()}else{properties[settings.side]=-self.outerHeight()}settings.isClosed=null;self.stop().animate(properties,$.extend({},settings,data).speed,function(){settings.isClosed=true;self.trigger("sidebar:closed")})});self.on("sidebar:toggle",function(ev,data){if(settings.isClosed){self.trigger("sidebar:open",[data])}el
@lucas-pelton
lucas-pelton / stuck-footer.css
Created August 15, 2018 00:07
Stuck footer revealed on scroll
@lucas-pelton
lucas-pelton / custom-fonts.php
Created May 3, 2019 18:38 — forked from jamesdixon/custom-fonts.php
Wordpress Allow Custom Font Upload
<?php
// add to your theme's functions.php file
add_filter('upload_mimes', 'add_custom_upload_mimes');
function add_custom_upload_mimes($existing_mimes) {
$existing_mimes['otf'] = 'application/x-font-otf';
$existing_mimes['woff'] = 'application/x-font-woff';
$existing_mimes['ttf'] = 'application/x-font-ttf';
$existing_mimes['svg'] = 'image/svg+xml';
$existing_mimes['eot'] = 'application/vnd.ms-fontobject';
return $existing_mimes;
@lucas-pelton
lucas-pelton / bash.sh
Created June 29, 2019 04:40
Cloudways npm path config
npm config set prefix "/home/master/bin/npm/lib/node_modules"
@lucas-pelton
lucas-pelton / async.js
Created October 18, 2019 23:11
"Synchronous" fetch with async/await
const request = async () => {
const response = await fetch('https://api.com/values/1');
const json = await response.json();
console.log(json);
}
request();
// https://dev.to/johnpaulada/synchronous-fetch-with-asyncawait