Skip to content

Instantly share code, notes, and snippets.

Steve Grunwell stevegrunwell

Block or report user

Report or block stevegrunwell

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@stevegrunwell
stevegrunwell / airstory-update-published-posts.php
Created Aug 8, 2018
Enable the Airstory WordPress plugin to update published posts as well as drafts. A response to https://wordpress.org/support/topic/upload-to-wp-from-airstory-not-working-for-me/
View airstory-update-published-posts.php
<?php
/**
* Plugin Name: Airstory: Enable Updating of Published Posts
* Plugin URI: https://wordpress.org/support/topic/upload-to-wp-from-airstory-not-working-for-me/
* Description: Enable Airstory to update the contents of posts of any post status, not just drafts.
* Version: 0.1.0
* Author: Steve Grunwell
* Author URI: https://stevegrunwell.com
*
* @link https://wordpress.org/support/topic/upload-to-wp-from-airstory-not-working-for-me/
@stevegrunwell
stevegrunwell / cdils.php
Created Mar 6, 2018
Modify the available block formats within WordPress' TinyMCE editor. A quick solution for https://twitter.com/cdils/status/970854979735977984
View cdils.php
<?php
/**
* Change the block formats available in TinyMCE.
*
* @link http://codex.wordpress.org/TinyMCE_Custom_Styles
*
* @param array $init Default settings to be overridden.
*
* @return array The modified $init array.
View wordpress-host-checker.sh
#!/usr/bin/env bash
#
# Check a WordPress domain against CVE-2017-8295.
# https://exploitbox.io/vuln/WordPress-Exploit-4-7-Unauth-Password-Reset-0day-CVE-2017-8295.html
#
# Usage:
# ./wordpress-host-check <domain> <username>
#
# <domain>
# The WordPress domain you wish to check. For example, http://example.com.
@stevegrunwell
stevegrunwell / one-time-hooks.php
Created Feb 14, 2017
Enables action and filter callbacks to be executed exactly once via the WordPress Plugin API. https://engineering.growella.com/one-time-callbacks-wordpress-plugin-api/
View one-time-hooks.php
<?php
/**
* Registers the "One time hook" functionality.
*
* Note that this file is intentionally in the *global* namespace!
*
* @author Growella
* @license MIT
*/
View database-backup.sh
#!/bin/bash
#
# Backup local databases to Amazon S3.
#
# This script takes a single argument: an S3 bucket name with optional path.
#
# Usage:
# database-backup.sh backup.example.com
# database-backup.sh backup.example.com/some/path
#
View gist:a83c97433bb982def4c725fd57b1710c
### Keybase proof
I hereby claim:
* I am stevegrunwell on github.
* I am stevegrunwell (https://keybase.io/stevegrunwell) on keybase.
* I have a public key whose fingerprint is 56A8 ED6A 4437 6DE0 0EE9 3D74 5435 2694 8DF1 91E1
To claim this, I am signing this object:
@stevegrunwell
stevegrunwell / functions.php
Created Mar 15, 2016
WP404: Send an email to Eric Mann every time there's a 404
View functions.php
<?php
/**
* Email the error log to Eric Mann every time a 404 error occurs.
*
* @param array $report The WP404 report.
* @return array The (untouched) WP404 report.
*/
function mytheme_spam_eric_with_404s( $report ) {
wp_mail(
@stevegrunwell
stevegrunwell / .bash_profile
Created Sep 9, 2015
Upgrade WordPress plugins via WP-CLI one at a time, committing the results to Git as you go
View .bash_profile
function wp-upgrade-plugins() {
UPDATES=`wp plugin list --update=available --fields=name,title,update_version --format=csv`
i=1
while IFS="," read -r slug name version
do
test $i -eq 1 && ((i=i+1)) && continue
echo "Upgrading $name to $version..."
@stevegrunwell
stevegrunwell / gist:11c3e9d370127fa97898
Last active May 7, 2019
Bulk-upgrade WordPress plugins using WP-CLI, committing each upgrade to Git as we go
View gist:11c3e9d370127fa97898
#! /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.
#
@stevegrunwell
stevegrunwell / gist:10011122
Last active Aug 29, 2015
Example of restricting shipping to a single state for a single shipping class with WooCommerce, prepared for Evan Thorpe based on my blog post http://stevegrunwell.com/blog/woocommerce-restrict-shipping
View gist:10011122
public function is_available( $package ) {
// Determine if we have any items in the "In-state" shipping class
$restricted_shipping_class_slug = 'in-state';
$permitted_states_for_restricted_items = array( 'NY' );
$has_restricted_items = false;
foreach ( $package as $pkg ) {
if ( isset( $pkg['contents'] ) ) {
foreach ( $pkg['contents'] as $contents ) {
You can’t perform that action at this time.