Skip to content

Instantly share code, notes, and snippets.

James Morrison jamesmorrison

Block or report user

Report or block jamesmorrison

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jamesmorrison
jamesmorrison / keybase.md
Created Jan 25, 2019
Verify me on Keybase.io
View keybase.md

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:

@jamesmorrison
jamesmorrison / custom-query-conditional-args.php
Created Jan 10, 2018
Custom query with conditional taxonomy args
View custom-query-conditional-args.php
<?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 Jan 5, 2018
Filter WP Basic HTTP Authentication Credentials
View filter-wp-basic-http-authentication-credentials.php
<?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
@jamesmorrison
jamesmorrison / filter-wp-basic-http-authentication-environments.php
Last active Jan 5, 2018
Filter WP Basic HTTP Authentication Environments
View filter-wp-basic-http-authentication-environments.php
<?php
/**
* Plugin Name: Filter WP Basic HTTP Authentication Environments
* Description: Filter WP Basic HTTP Authentication Environments to use environment variables
* Author: James Morrison
* Version: 1.0.0
* Author URI: https://www.jamesmorrison.me
**/
// Filter the environments
@jamesmorrison
jamesmorrison / wp-basic-http-authentication.php
Last active May 21, 2019
Adding HTTP Authentication to a WordPress site
View wp-basic-http-authentication.php
<?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 / display-git-branch.php
Created Jan 3, 2018
WordPress plugin to display your Git branch in the admin bar
View display-git-branch.php
<?php
/**
* Plugin Name: Display Git Branch
* Version: 1.0.0
* Description: Shows which Git branch you're working on. Highlights restricted branches in red.
* Author: James Morrison
* Author URI: https://www.jamesmorrison.me/
**/
// Namespace
@jamesmorrison
jamesmorrison / 30_wpcli.config
Created Nov 9, 2017 — forked from Azrael808/30_wpcli.config
Elastic Beanstalk extension for installing WP CLI.
View 30_wpcli.config
commands:
"01":
command: curl https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -o /usr/local/bin/wp
"02":
command: chmod +x /usr/local/bin/wp
@jamesmorrison
jamesmorrison / disable-network-active-plugin.php
Last active Jan 2, 2018
Disable one or more network active plugins for one or more sites
View disable-network-active-plugin.php
<?php
add_filter( 'site_option_active_sitewide_plugins',
function( $value ) {
// Lookup the current site object global
$current_blog;
// This would disable the plugins on sites with ID's 2, 3 and 5
if ( in_array( $current_blog->blog_id, [ 2, 3, 5 ] ) ) {
@jamesmorrison
jamesmorrison / 000-default.conf
Created Oct 25, 2017
Nginx Config for Apollo with nocache headers for all content
View 000-default.conf
server {
server_name apollo;
listen 80 default_server;
listen 443 ssl default_server;
ssl_certificate ssl/selfsigned.crt;
ssl_certificate_key ssl/selfsigned.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
@jamesmorrison
jamesmorrison / functions.php
Created Oct 5, 2017
When enqueueing a script or style, use `filemtime` to set the file version to the Unix timestamp for when the file was last modified
View functions.php
<?php
/* Obviously, add this to a function that hooks into wp_enqueue_scripts() (or admin_enqueue_scripts()) */
wp_enqueue_style( 'main', get_stylesheet_directory_uri() . '/style.css', false, filemtime( get_stylesheet_directory() . '/style.css' ) );
You can’t perform that action at this time.