Skip to content

Instantly share code, notes, and snippets.

View zanematthew's full-sized avatar

Zane Matthew zanematthew

View GitHub Profile
@zanematthew
zanematthew / site-name.conf
Last active April 19, 2023 06:39
Nginx – Redirect WP uploads directory to another server.
####
#
# Note this file should be place in:
# cd /etc/nginx/custom-sites/
# Then be sure to restart nginx:
# $ sudo service nginx restart
location ~ ^/wp-content/uploads/(.*) {
if (!-f $request_filename) {
rewrite ^/wp-content/uploads/(.*)$ https://SOME-OTHER-URL-HERE.com/$1 redirect;
}
@zanematthew
zanematthew / gist:3199265
Created July 29, 2012 14:38
WordPress Update Meta Key
<?php
/**
* Rename meta keys
* Usage: update_meta_key( 'old_key', 'new_key');
*/
function update_meta_key( $old_key=null, $new_key=null ){
global $wpdb;
$query = "UPDATE ".$wpdb->prefix."postmeta SET meta_key = '".$new_key."' WHERE meta_key = '".$old_key."'";
@zanematthew
zanematthew / post-receive.sh
Created January 22, 2013 19:03
This is a git post-receive hook that "deploys" code to your working tree using native git commands, edit as needed.
post-receive#!/bin/sh
###
# This file will deploy code from the repository into the
# specified web-root.
#
# File name: post-receive
#
# Instructions:
# 1. Uncomment and edit the lines below as needed
@zanematthew
zanematthew / routes.php
Created June 19, 2012 02:48
Custom routes for using WordPress as an Application
<?php
/**
* This file handles redirecting of our templates to our given views
* dir and anything else.
*
* Check if the themer has made a theme file in their
* theme dir, if not load our default.
*
* @uses template_redirect http://codex.wordpress.org/Plugin_API/Action_Reference/template_redirect
*/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AlternateMouseScroll</key>
<true/>
<key>AppleAntiAliasingThreshold</key>
<integer>1</integer>
<key>ApplePressAndHoldEnabled</key>
<false/>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.25332435965538025</real>
@zanematthew
zanematthew / Dockerfile
Created April 9, 2020 14:59
NGINX Dockerfile
ARG NODE_VERSION=node:8.11
ARG WEB_ROOT
FROM $NODE_VERSION as dev_frontend_assets
RUN mkdir -p /app/public
COPY /src /app
WORKDIR /app
RUN npm install && npm run development
FROM nginx as frontend_dev
@zanematthew
zanematthew / bootstrap.sh
Last active December 1, 2019 17:33
My shell script for creating a Vagrant 64bit development server
#!/usr/bin/env bash
echo "Running boostrap.sh..."
echo "+---------------------------------------------------+"
echo "| Update apt-get |"
echo "+---------------------------------------------------+"
apt-get update
@zanematthew
zanematthew / abstract.php
Created May 2, 2012 13:42
The abstract class for creating Custom Post Types
<?php
/**
*
* This is used to regsiter a custom post type, custom taxonomy and provide template redirecting.
*
* This abstract class defines some base functions for using Custom Post Types. You should not have to
* edit this abstract, only add additional methods if need be. You must use what is provided for you
* in the interface.
*
*/
// A
return state[item_type].indexOf(item_id) != -1 ? true : false;
// B
return Boolean(state[item_type].find(items => items === item_id));