Skip to content

Instantly share code, notes, and snippets.

View soderlind's full-sized avatar

Per Søderlind soderlind

View GitHub Profile
@soderlind
soderlind / expect-header-fix.php
Created March 10, 2021 23:17 — forked from carlalexander/expect-header-fix.php
WordPress "Expect" header fix
<?php
/**
* 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
soderlind / run-wp-cron.sh
Last active February 23, 2022 20:16 — forked from bjornjohansen/run-wp-cron.sh
Run all due cron events for WordPress with WP-CLI. Works with both single sites and multisite networks.
#!/bin/bash
# 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 http://www.wtfpl.net/ for more details.
# Modified by Per Søderlind
WP_PATH="/path/to/wp"
MAIN_SITE="http://www.domain.tld" # --url="$MAIN_SITE" below, prevents the Undefined index: HTTP_HOST error.
@soderlind
soderlind / .readme.md
Created September 5, 2018 11:40 — forked from morganestes/.readme.md
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 https://core.trac.wordpress.org/ticket/15317.

Usage

Shell

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
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
soderlind / config.ru
Created December 4, 2012 20:54 — forked from paulcook/config.ru
config.ru for Pow + Wordpress - based on http://stuff-things.net/2011/05/16/legacy-development-with-pow/. Added rewrite rule for WordPress Multi Site. More at http://soderlind.no/archives/2012/12/02/wordpress-and-pow/
# config.ru for Pow + Wordpress, based on http://stuff-things.net/2011/05/16/legacy-development-with-pow/
# added hackery to work around wordpress issues - Patrick Anderson (patrick@trinity-ai.com)
# 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 http://soderlind.no/archives/2012/12/02/wordpress-and-pow/)
require 'rubygems'
require 'rack'
require 'rack-legacy'
require 'rack-rewrite'