Skip to content

Instantly share code, notes, and snippets.

View adamwalter's full-sized avatar

Adam Walter adamwalter

View GitHub Profile
@adamwalter
adamwalter / wistia-crop-fill.js
Last active April 13, 2021 15:26
Wistia Crop-Fill Plugin
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
@adamwalter
adamwalter / add-wordpress-settings-page.php
Created May 28, 2020 16:21 — forked from DavidWells/add-wordpress-settings-page.php
WordPress :: Add Settings Page with All Fields
<?php
/*
Plugin Name: Homepage Settings for BigBang
Plugin URI: http://www.inboundnow.com/
Description: Adds additional functionality to the big bang theme.
Author: David Wells
Author URI: http://www.inboundnow.com
*/
// Specify Hooks/Filters
@adamwalter
adamwalter / wp-last-login.php
Last active February 27, 2019 20:42
Captures user login timestamp and saves to user meta in WordPress
<?php
/**
* Captures user login timestamp and saves to user meta
*
* @param string $user_login Username of user logging in
* @param object $user WP_User object of user logging in
*/
add_action('wp_login', function($user_login, $user) {
$timestamp = date('Y-m-d H:i:s', current_time('timestamp', 1));
update_user_meta($user->ID, 'last_login', $timestamp);
@adamwalter
adamwalter / bulk-thumbnail-import.sh
Created February 21, 2019 21:01
Bulk import WordPress featured images
#!/bin/bash
# File names should be suffixed with "_{postid}"
# example_42.jpg
for filename in ./photos/*.jpg; do
ID1=$(echo $filename| cut -d'_' -f 2)
ID2=$(echo $ID1| cut -d'.' -f 1)
wp media import $filename --post_id=$ID2 --featured_image
@adamwalter
adamwalter / remove-uploads-via-bfg.bash
Last active January 25, 2019 19:01
Remove WordPress uploads (or any large files) from a Git repo
# 1. Install BFG CLI
# https://rtyley.github.io/bfg-repo-cleaner/
brew install bfg
# 2. Download BFG
# https://rtyley.github.io/bfg-repo-cleaner/
# 3. Rename BFG's JAR file to 'bfg.jar' and move to ~/bfg.jar
# Test BFG by running empty "bfg" command
@adamwalter
adamwalter / jqueryxss.js
Last active January 23, 2019 17:12
Applies jQuery patch to fix CVE-2015-9251 in order to pass PCI compliance
// Patch code
jQuery.ajaxPrefilter(function(s) {
if (s.crossDomain) {
s.contents.script = false;
}
});
// Patch code (minified)
jQuery.ajaxPrefilter(function(n){n.crossDomain&&(n.contents.script=!1)});
@adamwalter
adamwalter / lets-encrypt-via-certbot.sh
Created November 13, 2018 16:09
Generate Let's Encrypt certificate via Certbot
# Install Certbot
brew install certbot
# Generate certificate with DNS challenge and CSR from hosting server
sudo certbot certonly --manual --preferred-challenges dns --csr ~/Desktop/example.csr
@adamwalter
adamwalter / add-acf-map-meta.php
Last active June 28, 2018 18:19
Geocode address and insert into ACF map field
<?php
/**
* WP-CLI EVAL FILE
*
* Command: wp eval-file filename.php {run}
*
* Usage: If the 'run' argument is passed, this script will
* process the RUN block. Otherwise it will process the DRY RUN.
*
* https://github.com/wp-cli/wp-cli/wiki/API
@adamwalter
adamwalter / wp-upgrade-plugins.sh
Last active November 29, 2018 16:10 — forked from stevegrunwell/gist:11c3e9d370127fa97898
Bulk-upgrade WordPress plugins using WP-CLI, committing each upgrade to Git as we go
#! /bin/bash
# Find available updates for WordPress plugins via WP-CLI, then upgrade theme one at a time.
# After each upgrade, commit the changed files to Git.
#
# Requires that WP-CLI be installed and in your path: http://wp-cli.org/
#
# Currently, it will only work when run from the root of the WordPress installation, and has
# a hard-coded path for wp-content/plugins.
#
@adamwalter
adamwalter / bitbucket-migrate.sh
Last active September 10, 2016 15:01
Bulk repo migration from GitHub to Bitbucket
#!/bin/bash -e
# Usage: ./bitbucket-migrate.sh repos.txt
#
# repos.txt should have one repository per line.
echo "Reading $1"
while read line
do