Skip to content

Instantly share code, notes, and snippets.

View soderlind's full-sized avatar

Per Søderlind soderlind

View GitHub Profile
soderlind / expect-header-fix.php
Created March 10, 2021 23:17 — forked from carlalexander/expect-header-fix.php
WordPress "Expect" header fix
* By default, cURL sends the "Expect" header all the time which severely impacts
* performance. Instead, we'll send it if the body is larger than 1 mb like
* Guzzle does.
function add_expect_header(array $arguments)
$arguments['headers']['expect'] = !empty($arguments['body']) && strlen($arguments['body']) > 1048576 ? '100-Continue' : '';
soderlind /
Last active February 23, 2022 20:16 — forked from bjornjohansen/
Run all due cron events for WordPress with WP-CLI. Works with both single sites and multisite networks.
# Copyright © 2015 Bjørn Johansen
# This work is free. You can redistribute it and/or modify it under the
# terms of the Do What The Fuck You Want To Public License, Version 2,
# as published by Sam Hocevar. See for more details.
# Modified by Per Søderlind
MAIN_SITE="http://www.domain.tld" # --url="$MAIN_SITE" below, prevents the Undefined index: HTTP_HOST error.
soderlind /
Created September 5, 2018 11:40 — forked from morganestes/
Create multiple sites with wp-cli in WordPress multisite for testing.

These commands will install multiple dummy sites in a WordPress Multisite environment.

I wrote this to easily create an environment to work on



In the terminal, inside your WordPress directory: simply copy, paste, and run the one-line command.

You can also add it to a location available in your $PATH and invoke the script from the shell.

soderlind / licence activation.php
Created May 16, 2016 22:54 — forked from mattradford/licence activation.php
ACF5 Pro licence activation. Could be adapted for any other plugin that requires a licence key, but doesn't yet support defining it in wp-config. Fires on theme activation.
// Place this in wp-config
define( 'ACF_5_KEY', 'yourkeyhere' );
// Set ACF 5 license key on theme activation. Stick in your functions.php or equivalent.
function auto_set_license_keys() {
if ( ! get_option( 'acf_pro_license' ) && defined( 'ACF_5_KEY' ) ) {
$save = array(
'key' => ACF_5_KEY,
soderlind /
Created December 4, 2012 20:54 — forked from paulcook/ for Pow + Wordpress - based on Added rewrite rule for WordPress Multi Site. More at
# for Pow + Wordpress, based on
# added hackery to work around wordpress issues - Patrick Anderson (
# added rubygems, replaced script_path with script from path_parts, added to_return to fix return error - Paul Cook
# clearly this could be cleaner, but it does work
# added rewrite rule for WordPress Multi Site - Per Soderlind (see also
require 'rubygems'
require 'rack'
require 'rack-legacy'
require 'rack-rewrite'