Skip to content

Instantly share code, notes, and snippets.

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 / menu-item-inserter.php
Created January 20, 2018 18:11
Horribly inefficient function to create a menu with all pages as menu items.
<?php
/**
* Insert menu items for all pages.
*
* @package BJ\Menu
* @author bjornjohansen
* @version 0.1.0
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License version 2 (GPLv2)
*/
@bjornjohansen
bjornjohansen / wordpress-menu-cache-timing.php
Created January 20, 2018 17:49
Timing for the WordPress menu cache
<?php
/**
* WordPress menu cache timing.
*
* @package BJ\Menu
* @author bjornjohansen
* @version 0.1.0
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License version 2 (GPLv2)
*/
@bjornjohansen
bjornjohansen / default.vcl
Created May 11, 2016 23:25
Varnish 4.0 VCL for WordPress
vcl 4.0;
import std;
import directors;
backend server1 { # Define one backend
.host = "localhost";
.port = "8080";
.max_connections = 300;
@bjornjohansen
bjornjohansen / top-wp.sh
Created January 18, 2017 11:58 — forked from kasparsd/top-wp.sh
Finding WordPress in Alexa top 1 million sites, see http://crawler.wproll.com
#!/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 / class-assetspusher.php
Created January 29, 2018 21:24
HTTP/2 server push WordPress assets
<?php
/**
* HTTP/2 server push WordPress assets.
*
* @package BJ\AssetsPusher
* @author bjornjohansen
* @version 0.1.0
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License version 2 (GPLv2)
*/
@bjornjohansen
bjornjohansen / auth.php
Last active October 16, 2020 12:33
Changes the expiration of the WordPress authentication cookie to 365 days if the user ticks the “Remember Me” checkbox.
<?php
/**
* Authentication customizations.
*
* @package BJ\Auth
*/
/**
* Filters the duration of the authentication cookie expiration period.
*
@bjornjohansen
bjornjohansen / reorder-attributes.php
Created January 26, 2021 14:46
Reorder the visible attributes on the frontend.
<?php
/**
* Reorder the visible attributes on the frontend.
*/
add_filter( 'woocommerce_product_get_attributes', function( $old_attributes, $obj ) {
$order = [ 'pa_colour', 'pa_size' ];
$new_attributes = [];
@bjornjohansen
bjornjohansen / gravityforms-privacyactions.php
Last active June 8, 2021 19:09
Personal data exporter and eraser for Gravity Forms.
<?php
/**
* Personal data exporter and eraser for Gravity Forms.
*
* @package BJ\GravityForms\PrivacyActions
* @author bjornjohansen
* @version 0.1.1
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License version 2 (GPLv2)
*/
@bjornjohansen
bjornjohansen / wordpress.conf
Last active April 1, 2022 13:46
Nginx config for WordPress
index index.php index.html;
# Don’t log favicon requests
location /favicon.ico {
log_not_found off;
access_log off;
}
# Disallow access to readme.html
location /readme.html {