Skip to content

Instantly share code, notes, and snippets.

View jamesmorrison's full-sized avatar

James Morrison jamesmorrison

View GitHub Profile
@jamesmorrison
jamesmorrison / wordpress-random-post-slug.php
Last active June 7, 2021 04:56
Replace the default WP post slug with a random one in the format is "XXXX-XXXX-XXXX-XXXX"
<?php
/**
*
* Filter post slug
* This needs saving as post meta to use that value rather than regenerate a new one
*
**/
add_filter( 'wp_unique_post_slug', function( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) {
@jamesmorrison
jamesmorrison / wp-config.php
Last active January 11, 2021 11:17 — forked from MikeNGarrett/wp-config.php
All those damned wp-config constants you can never remember.
<?php
// PHP memory limit for this site
define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' ); // Increase admin-side memory limit.
// Database
define( 'WP_ALLOW_REPAIR', true ); // Allow WordPress to automatically repair your database.
define( 'DO_NOT_UPGRADE_GLOBAL_TABLES', true ); // Don't make database upgrades on global tables (like users)
// Explicitely setting url
@jamesmorrison
jamesmorrison / gist:0de9c37135e0efe113ea14b2db00be68
Created December 17, 2020 09:24
Create a self signed TLS certificate for Local Development
#!/bin/bash
# Exit on failure
set -e
# Create the root key
openssl genrsa -out ./root.key 2048
# Generate the root certificate
openssl req -x509 -new -nodes -key ./root.key -sha256 -days 3650 -out ./root.crt -subj /C=XX/ST=LocalHost/L=LocalHost/O=LocalHost/OU=LocalHost/CN=localhost
@jamesmorrison
jamesmorrison / .gitlab-ci.yml
Created April 14, 2020 09:49
Gitlab CI configuration for DNSControl
##### Define the stages for this pipeline
stages:
- check
- preview
- deploy
##### Check
Check:
@jamesmorrison
jamesmorrison / wp-basic-http-authentication.php
Last active May 21, 2019 09:41
Adding HTTP Authentication to a WordPress site
<?php
/**
* Plugin Name: WP Basic HTTP Authentication
* Plugin URI:
* Description: Adds HTTP Authentication to a WordPress site
* Author: James Morrison
* Version: 1.0.2
* Author URI: https://www.jamesmorrison.me
**/
@jamesmorrison
jamesmorrison / keybase.md
Created January 25, 2019 21:16
Verify me on Keybase.io

Keybase proof

I hereby claim:

  • I am jamesmorrison on github.
  • I am jamesmorrison (https://keybase.io/jamesmorrison) on keybase.
  • I have a public key ASCOzeBwCWH4T4s-tlSOGJ8tu6ynXAHJVJAe_Vo3U5vBcQo

To claim this, I am signing this object:

## CMD PROMPT
green=$(tput setaf 2)
blue=$(tput setaf 4)
white=$(tput setaf 7)
bold=$(tput bold)
reset=$(tput sgr0)
PS1='${debian_chroot:+($debian_chroot)}\[$green\]MAC\[$reset\]:\[$white\]\w\[$reset\]\[$green\]$(parse_git_branch)\[$reset\]\$ '
<?php
/**
* Plugin Name: User Security
* Description: Hides login errors, disables author archives (to hide usernames), changes author links to title => sitename / URL => homepage
* Version: 1.0.0
* Author: James Morrison
* Author URI: https://james.morrison.me/
**/
@jamesmorrison
jamesmorrison / custom-query-conditional-args.php
Created January 10, 2018 11:03
Custom query with conditional taxonomy args
<?php
// Set up default query
$locations_query_args = [
'post_type' => 'locations',
'post_status' => 'publish',
'posts_per_page' => 500,
];
// Add the search query if set ($town_city_selected)
@jamesmorrison
jamesmorrison / filter-wp-basic-http-authentication-credentials.php
Last active January 5, 2018 20:12
Filter WP Basic HTTP Authentication Credentials
<?php
/**
* Plugin Name: Filter WP Basic HTTP Authentication Credentials
* Description: Filter WP Basic HTTP Authentication Credentials to use environment variables
* Author: James Morrison
* Version: 1.0.0
* Author URI: https://www.jamesmorrison.me
**/
// Filter the credentials