Skip to content

Instantly share code, notes, and snippets.

View theblanchard's full-sized avatar

John Blanchard theblanchard

View GitHub Profile
@theblanchard
theblanchard / wp-author-import-auto-select.js
Created May 5, 2021 17:10 — forked from purplefeel/wp-author-import-auto-select.js
Auto-select authors for posts during WordPress import. They must already be assigned to the project. Enable jQuery in a plugin or functions.php, and paste this in the browser console.
(function($){
$('#authors li').each(function(key, value) {
var name = $(this).children('strong').first().html();
var re = /\s\([^\)]+\)/gi;
name = name.replace(re, '');
name = name.replace(':', '');
name = name.replace("'", "");
name = name.replace(".", "");
name = name.replace("&", "");
@theblanchard
theblanchard / replace_jquery.php
Created July 6, 2018 20:05
Replace WordPress default jQuery with a version from a CDN.
//Add to functions.php in your WordPress theme file
function jquery_from_cdn() {
wp_deregister_script('jquery');
wp_register_script('jquery', 'https://code.jquery.com/jquery-3.3.1.min.js', false, '3.3.1');
wp_enqueue_script('jquery');
}
add_action('init', 'jquery_from_cdn');
@theblanchard
theblanchard / wp_delete_revisions.php
Last active October 19, 2017 16:36 — forked from mrazzari/multisite_delete_revisions.php
WP - Multisite delete revisions
<pre><?php
// WordPress - Delete all revisions from all posts greater than 1 year old.
// Credit to @mrazzari, 2014.
// For context see this thread started by Kitchin at the forums:
// http://wordpress.org/support/topic/deleting-post-revisions-do-not-use-the-abc-join-code-you-see-everywhere
// HOWTO
// This snippet is meant to be called as a standalone script.
// Like http://example.com/tmp/wp_delete_revisions.php
@theblanchard
theblanchard / override.css
Created March 3, 2017 17:15 — forked from cougrimes/override.css
Marketo Forms 2.0 mobile class reset
@media only screen and (max-width: 480px), only screen and (max-device-width: 480px), only screen and (max-device-height:480px){
.mktoForm,.mktoForm *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-moz-box-sizing:border-box;padding:auto}
/* Yes, I know padding:auto isn't a real property - had to break things somehow :( */
.mktoLabel.mktoHasWidth {height: inherit !important;}
.mktoForm .mktoGutter,.mktoForm .mktoOffset{display:initial !important}
.mktoForm .mktoFormCol .mktoLabel{text-align:left;width:initial !important}
.mktoForm .mktoFormCol{float:initial !important}
.mktoForm .mktoFieldWrap{float:initial !important}
.mktoForm fieldset{padding:initial !important}
.mktoForm input[type=url],.mktoForm input[type=text],.mktoForm input[type=date],.mktoForm input[type=tel],.mktoForm input[type=email],.mktoForm input[type=number],.mktoForm textarea.mktoField,.mktoForm select.mktoField{width:100% !important;height:initial !important;line-height:initial !important;font-size:initial !i
@theblanchard
theblanchard / bitly.php
Created October 17, 2016 03:42
Get permalinks from the bit.ly API
$title = str_replace(' ', '', get_the_title());
$title = str_replace('-', '', $title);
$permalink = get_the_permalink();
// Set the path to save the data to
$cachePath = ABSPATH.'path/to/folder/'.$title.'.txt';
// See if data already exists
$getData = file_get_contents($cachePath);
$response = json_decode($getData, true);
@theblanchard
theblanchard / index.php
Created August 5, 2016 19:41
Get PHP variables to console
$data = "My variable data";
$output = "<script>console.log( 'Debug Objects: " . $data . "' );</script>";
echo $output;
@theblanchard
theblanchard / index.php
Created August 5, 2016 19:40
Show display errors in PHP pages
error_reporting(E_ALL);
ini_set('display_errors', '1');
@theblanchard
theblanchard / style.css
Created August 5, 2016 19:39
Often used CSS margin and padding styles
/* Custom margin & padding styles */
.mr0 {
margin-right: 0 !important
}
.ml0 {
margin-left: 0 !important
}
@theblanchard
theblanchard / apple-mq.css
Created March 23, 2016 16:30 — forked from AllThingsSmitty/apple-mq.css
iPhone 6/6 Plus and Apple Watch CSS media queries
/* iPhone 6 landscape */
@media only screen and (min-device-width: 375px)
and (max-device-width: 667px)
and (orientation: landscape)
and (-webkit-min-device-pixel-ratio: 2)
{ }
/* iPhone 6 portrait */
@media only screen
and (min-device-width: 375px)
@theblanchard
theblanchard / superfeedr.js
Created October 12, 2015 16:34
Superfeedr Shim for Google Feed API
/*
This is a shim that matches the Google Feed API into Superfeedr's feed API.
See blog.superfeedr.com/google-feed-api-alternative/ for details.
*/
window.google = {
feeds: {
Feed: {