Skip to content

Instantly share code, notes, and snippets.

<?php
/*
Plugin name: SameSite Cookies
Description: A WordPress plugin for using SameSite=Lax with auth cookies
*/
add_filter('send_auth_cookies', function () {
return false;
});
<?php
/*
* Plugin Name: CSP
* Description: Uses inline_js() to make CSP happen
*/
add_filter('inline_js_attributes', function ($attr) {
$nonce = wp_create_nonce('csp');
return $attr . ' nonce="'.esc_attr($nonce).'" ';
@mallorydxw
mallorydxw / .js
Created August 24, 2015 14:39
A bookmarklet that sets .noValidate=true on all forms in a page
javascript:var f=document.querySelectorAll('form');for(var i=0;i<f.length;i++){f[i].noValidate=true}
@mallorydxw
mallorydxw / gist:2c6de4e8ce361c0b7613
Created July 10, 2015 15:03
Bookmarklet to disable form validation
javascript:var f=document.querySelectorAll('form');for(var i=0;i<f.length;i++){f[i].noValidate=true}
From 6fe847423069d9bed7e6bc6c4fb4a9a12687c562 Mon Sep 17 00:00:00 2001
From: Tom Adams <tom@dxw.com>
Date: Tue, 4 Mar 2014 15:36:16 -0500
Subject: [PATCH] s/$_POST/stripslashes_deep($_POST)/
---
by-email/by-email.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/by-email/by-email.php b/by-email/by-email.php
@mallorydxw
mallorydxw / prepare-wxr.rb
Created April 14, 2014 14:40
The wordpress-importer plugin doesn't understand namespaces. Here's a workaround that converts XML generated by Go into XML this plugin understands.
#!/bin/ruby
# Read an XML document on STDIN, write an XML document on STDOUT
#
# Replace
# <wxr_version xmlns="http://wordpress.org/export/1.2/">1.2</wxr_version>
# with
# <wp:wxr_version>1.2</wp:wxr_version>
# and add xmlns:wp=... to the root node
@mallorydxw
mallorydxw / xlsx2csv.rb
Created December 2, 2013 19:46
Apparently converting XLSX to CSV and keeping formulae intact is not something you can Google and find out how to do it? This is how you do it.
#!/usr/bin/env ruby
require 'rubygems'
require 'csv'
require 'roo'
excel = Roo::Excelx.new('filename.xlsx')
CSV do |csv| # (stdout)
From 157cc551cbe2bbdbd836976fa43bb249e2608e30 Mon Sep 17 00:00:00 2001
From: Tom Adams <tom@dxw.com>
Date: Fri, 7 Jun 2013 09:01:33 -0400
Subject: [PATCH] s/$_POST/stripslashes_deep($_POST)/
---
by-email/by-email.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/by-email/by-email.php b/by-email/by-email.php
// IE img width/height polyfill
jQuery(function ($) {
$('img').each(function () {
var $this = $(this)
if ($this.attr('width') !== undefined) {
$this.css('width', $this.attr('width')+'px')
}
if ($this.attr('height') !== undefined) {
$this.css('height', $this.attr('height')+'px')
From f549fafe7510e10c4201674e679aeed89bbef3cb Mon Sep 17 00:00:00 2001
From: Tom Adams <tom@dxw.com>
Date: Thu, 24 Jan 2013 16:39:19 -0500
Subject: [PATCH] [#919] IE compatible JS syntax
---
mailchimp.php | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/mailchimp.php b/mailchimp.php