Skip to content

Instantly share code, notes, and snippets.

View jamesmorrison's full-sized avatar

James Morrison jamesmorrison

View GitHub Profile
<?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/
**/
/**
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/
*
*
@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/
**/
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
@jamesmorrison
jamesmorrison / rewrite-search-urls.php
Created August 10, 2017 18:05
Rewrite search URL's to "pretty" permalinks. A custom permalink structure must be set.
<?php
/**
*
* Plugin Name: Rewrite Search URL's
* Description: Rewrite search URL's to "pretty" permalinks. A custom permalink structure must be set.
* Version: 1.0.1
* Author: James Morrison
* Author URI: https://www.jamesmorrison.me/
*
**/
@jamesmorrison
jamesmorrison / header-wp-signup.php
Last active September 21, 2017 21:29
Adding this to your theme will redirect any requests for wp-signup.php (triggered upon visiting a multisite network address that doesn't exist) to the network home URL along with some GA parameters
<?php
/**
* @package Header for WP Signup
* @author James Morrison
* @link https://gist.github.com/jamesmorrison/5f8a3108b2a773cd07db430b73992e9d/edit
*
* This file is called by the WP core /wp-signup.php file; we can force a redirect from here
*
* Whilst you can do this from the NOBLOGREDIRECT constant, the advantage of using this header
* file is that you can capture the path that triggered the call to signup; as seen in the example