Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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;
}
});
prefix="<?php
/**#@+
Authentication Unique Keys and Salts.
Change these to different unique phrases!
You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
*/"
for salt in `find ./ -name wp-salt.php`; do echo "$prefix" > $salt; curl https://api.wordpress.org/secret-key/1.1/salt/ >> $salt; done
@lucas-pelton
lucas-pelton / post.js
Created December 7, 2016 05:58
JS function to navigate to a URL and include a POST array
function post(path, params, method) {
method = method || "post"; // Set method to post by default if not specified.
// The rest of this code assumes you are not using a library.
// It can be made less wordy if you use one.
var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", path);
for(var key in params) {
@lucas-pelton
lucas-pelton / .htaccess
Created November 11, 2016 00:48
Silent rewrite to grab static content based on subdomain
<IfModule mod_rewrite.c>
RewriteEngine On
# RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|ipad|iemobile" [NC]
# RewriteCond %{HTTP_COOKIE} !atomic-show-full-site=true [NC]
RewriteCond %{SERVER_NAME} ^m.thisisatotal.cf$ [NC]
RewriteCond %{REQUEST_FILENAME} !^favicon.ico$ [NC]
RewriteCond %{REQUEST_URI} ^/$ [NC]
RewriteRule ^ /mobile.html [NC,L]
</IfModule>
@lucas-pelton
lucas-pelton / 0_reuse_code.js
Created December 12, 2015 13:37
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@lucas-pelton
lucas-pelton / functions.php
Created December 3, 2015 20:31
Remove Vantage-added components from Page Builder
add_action ('init', 'lp_remove_vantage_row_options_from_pagebuilder',12);
add_action ('admin_head', 'lp_remove_vantage_row_options_from_pagebuilder',12);
function lp_remove_vantage_row_options_from_pagebuilder() {
remove_filter('siteorigin_panels_prebuilt_layouts', 'vantage_prebuilt_page_layouts');
remove_filter('siteorigin_panels_row_styles', 'vantage_panels_row_styles');
remove_filter('siteorigin_panels_row_style_fields', 'vantage_panels_row_style_fields', 11);
remove_filter('siteorigin_panels_row_style_attributes', 'vantage_panels_panels_row_style_attributes', 10, 2);
remove_filter('siteorigin_panels_row_attributes', 'vantage_panels_panels_row_attributes', 10, 2);
remove_filter('siteorigin_panels_widgets', 'vantage_panels_add_widget_groups');