Skip to content

Instantly share code, notes, and snippets.

View jamesmorrison's full-sized avatar

James Morrison jamesmorrison

View GitHub Profile
@jamesmorrison
jamesmorrison / install.php
Last active June 10, 2016 13:26
Custom WordPress install script - add to /wp-content/install.php before running the installer
<?php
/**
* Creates the initial content for a newly-installed site.
*
* Adds sensible defaults for a new install
*
* @param int $user_id User ID.
*/
<?php
/**
* Plugin Name: Force SSL
* Description: Force all URL's to use SSL
* Version: 1.0.0
* Author: James Morrison
* Author URI: https://www.jamesmorrison.me/
**/
/**
<?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/
**/
INITIALISATION
==============
load wp-config.php
set up default constants
load wp-content/advanced-cache.php if it exists
load wp-content/db.php if it exists
connect to mysql, select db
load object cache (object-cache.php if it exists, or wp-include/cache.php if not)
load wp-content/sunrise.php if it exists (multisite only)
@jamesmorrison
jamesmorrison / remote-uploads.php
Created December 9, 2016 11:22
WordPress - Use media from a remote site. Designed to remove the need to download the uploads folder when working locally
<?php
/**
* Plugin Name: Remote Uploads
* Plugin URL: https://www.jamesmorrison.me/plugins/remote-uploads/
* Version: 1.0.0
* Author: James Morrison
* Author URI: https://www.jamesmorrison.me/
*
*
@jamesmorrison
jamesmorrison / taxonomy-tag-cloud.php
Created January 31, 2017 11:39
Tag cloud for custom taxonomy
<?php
wp_tag_cloud( [
'taxonomy' => '%%TAXONOMY-NAME%%',
'separator' => ' ',
'include' => implode(',', wp_list_pluck( get_the_terms( get_the_ID(), '%%TAXONOMY-NAME%%' ), 'term_id' ) )
] );
@jamesmorrison
jamesmorrison / wp-config-local.php
Created February 21, 2017 12:52
WP Config for local development on Apollo Vagrant
<?php
// WP CLI
if ( defined( 'WP_CLI' ) && ! isset( $_SERVER[ 'SERVER_NAME' ] ) ) {
$_SERVER[ 'SERVER_NAME' ] = '';
}
// Database
@jamesmorrison
jamesmorrison / wp-remote-uploads.php
Created March 6, 2017 11:15
Use a remote site / URL for media. Avoids the need to copy all the files down for local development.
<?php
/**
* Plugin Name: Remote Uploads
* Plugin URL: https://www.jamesmorrison.me/plugins/remote-uploads/
* Version: 1.0.0
* Author: James Morrison
* Author URI: https://www.jamesmorrison.me/
*
*
## 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\]\$ '
@jamesmorrison
jamesmorrison / wp-cache-controller.php
Created July 7, 2017 11:52
Set a max age for WP pages
<?php
/**
* Plugin Name: Cache Controller
* Plugin URI: #
* Description: HTTP Cache Control headers for WordPress.
* Version: 0.0.1
* Author: James Morrison
* Author URI: https://james.morrison.me/
**/