Skip to content

Instantly share code, notes, and snippets.

View keybase.md

Keybase proof

I hereby claim:

  • I am bjornjohansen on github.
  • I am bjornjohansen (https://keybase.io/bjornjohansen) on keybase.
  • I have a public key ASCrTUGCadfybRYNvfqSValmQEdSig65WPGxp2HvGsifigo

To claim this, I am signing this object:

@bjornjohansen
bjornjohansen / test-password-permutations.php
Last active Feb 2, 2017
Test a bunch of permutations of the password when logging into WordPress.
View test-password-permutations.php
<?php
/**
* Test a bunch of permutations of the password when logging into WordPress.
*
* Drop this file in your mu-plugins directory.
* Inspired by Facebook: https://twitter.com/gcpascutto/status/821755332984717314/photo/1
* Works with any properly coded hashing pluggables, like RootsWP Password bcrypt.
*
* @author bjornjohansen
* @version 0.1.4
@bjornjohansen
bjornjohansen / top-wp.sh
Created Jan 18, 2017 — forked from kasparsd/top-wp.sh
Finding WordPress in Alexa top 1 million sites, see http://crawler.wproll.com
View top-wp.sh
#!/bin/bash
touch checked.csv
while IFS=',' read -r POS HOSTNAME; do
if cat checked.csv | grep -qxF "$HOSTNAME"; then
echo "Skipping $HOSTNAME, already checked."
continue
fi
@bjornjohansen
bjornjohansen / moderate_comments.sh
Created Oct 2, 2016
Moderate comments in a WordPress installation with WP-CLI
View moderate_comments.sh
#!/bin/bash
# Copyright © 2016 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.
# Check if WP-CLI is available
if ! hash wp 2>/dev/null; then
echo "WP-CLI is not available"
exit
@bjornjohansen
bjornjohansen / cloudproxy-whitelist-ip.php
Last active May 26, 2016
Whitelist the remote IP in CloudProxy when the user logs into WordPress
View cloudproxy-whitelist-ip.php
<?php
/**
* Whitelist the remote IP in CloudProxy when the user logs into WordPress
*
* @param string $user_login The provided $user->user_login
* @param WP_User $user The WP_User object
*/
function whitelist_ip_in_cloudproxy( $user_login, $user ) {
@bjornjohansen
bjornjohansen / default.vcl
Created May 11, 2016
Varnish 4.0 VCL for WordPress
View default.vcl
vcl 4.0;
import std;
import directors;
backend server1 { # Define one backend
.host = "localhost";
.port = "8080";
.max_connections = 300;
@bjornjohansen
bjornjohansen / le-renew.sh
Last active Jun 11, 2016
Let's Encrypt renewal script for Nginx
View le-renew.sh
#!/bin/bash
#================================================================
# Let's Encrypt renewal script for Nginx based on the script
# by Erika Heidi for Apache on Ubuntu/Debian
# @author Erika Heidi<erika@do.co>
# @author Bjørn Johansen <post@bjornjohansen.no>
# Usage: ./le-renew.sh [base-domain-name] [path-to-webroot]
#================================================================
domain=$1
webroot=$2
@bjornjohansen
bjornjohansen / run-wp-cron.sh
Last active Oct 16, 2020
Run all due cron events for WordPress with WP-CLI. Works with both single sites and multisite networks.
View run-wp-cron.sh
#!/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.
WP_PATH="/path/to/wp"
# Check if WP-CLI is available
if ! hash wp 2>/dev/null; then
@bjornjohansen
bjornjohansen / wp-ms-cron-run.sh
Created Dec 9, 2015
Run cron events for all sites in a WordPress multisite network
View wp-ms-cron-run.sh
#!/bin/bash
WP_PATH="/path/to/wp"
for SITE_URL in $(wp site list --fields=url --archived=0 --deleted=0 --format=csv --path="$WP_PATH" | sed 1d)
do
for EVENT_HOOK in $(wp cron event list --format=csv --fields=hook,next_run_relative --url="$SITE_URL" --path="$WP_PATH" | grep now$ | awk -F ',' '{print $1}')
do
wp cron event run "$EVENT_HOOK" --url="$SITE_URL" --path="$WP_PATH" --quiet
done
done
@bjornjohansen
bjornjohansen / wp-ms-cron-ping.sh
Last active Dec 9, 2015
Ping cron for all sites in a WordPress multisite network
View wp-ms-cron-ping.sh
#!/bin/bash
WP_PATH="/path/to/wp"
for SITE_URL in $(wp site list --fields=url --archived=0 --deleted=0 --format=csv --path="$WP_PATH" | sed 1d)
do
/usr/bin/curl -L -s -o /dev/null "${SITE_URL}wp-cron.php"
done