Skip to content

Instantly share code, notes, and snippets.

@jjeaton
jjeaton / create_ssl.sh
Created October 15, 2015 17:29
Bash script to generate self-signed certificates for local dev.
#!/bin/sh
################################################################################
# Generates a self-signed certificate based on a domain name parameter
# Domain name should be the hostname and TLD only.
# Key and certificate will be output into the current working directory.
# This is useful for generating certificates to be used with VVV.
#
# @link https://github.com/Varying-Vagrant-Vagrants/VVV/wiki/Site-specific-self-signed-SSL-certificates
################################################################################
@jjeaton
jjeaton / .vimrc
Last active August 29, 2015 14:28 — forked from JeffreyWay/.vimrc
My .vimrc file
set nocompatible " Disable vi-compatibility
set t_Co=256
colorscheme xoria256
set guifont=menlo\ for\ powerline:h16
set guioptions-=T " Removes top toolbar
set guioptions-=r " Removes right hand scroll bar
set go-=L " Removes left hand scroll bar
set linespace=15
@jjeaton
jjeaton / .gitignore
Created August 5, 2015 01:54
WordPress root .gitignore. Ignore everything and then opt-in (exclude from the ignore) for your custom code.
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your
@jjeaton
jjeaton / gist:41eedccdd5256cf756ec
Created March 5, 2015 15:28
Search by post slug in the WP Admin
add_filter( 'posts_search', 'jje_search_by_slug', 10, 2 );
/**
* Add post slugs to admin search for a specific post type
*
* Rebuilds the search clauses to include post slugs.
*
* @param string $search
* @param WP_Query $query
* @return string
*/
@jjeaton
jjeaton / switch-theme.php
Created February 11, 2015 13:26
Switches the theme, only for the homepage. May not help if widgets/menus also need to be switched.
<?php
add_action( 'setup_theme', 'this_setup_theme' );
/**
* Sets a different theme on the homepage from the rest of the site.
*
* Just checks the REQUEST_URI. Works, but hasn't been tested thoroughly.
* Currently it will only change if the query string is also empty, but if there
* needs to be query strings (e.g. utm_campaign, etc.) that can be dropped.
*
* Code from https://github.com/Rarst/toolbar-theme-switcher
function Selector_Cache() {
var elementCache = {};
var get_from_cache = function( selector, $ctxt, reset ) {
if ( 'boolean' === typeof $ctxt ) { reset = $ctxt; }
var cacheKey = $ctxt ? $ctxt.selector + ' ' + selector : selector;
if ( undefined === elementCache[ cacheKey ] || reset ) {
elementCache[ cacheKey ] = $ctxt ? $ctxt.find( selector ) : jQuery( selector );
//********************************************************
// plugin for equalizing heights, responsively
//********************************************************
(function ($) {
$.fn.eqHeights = function() {
var el = $(this);
if (el.length > 0 && !el.data('eqHeights')) {
$(window).on('resize.eqHeights', function() {
el.eqHeights();
});
@jjeaton
jjeaton / site_sync.sh
Created September 30, 2014 17:19
Bash script to push/pull a WordPress site's files and MySQL DB between production and a local environment
#!/bin/sh
# Just an abbreviation for creating filenames
SHORT_NAME=je
# hostname as configred in ~/.ssh/config
SERVER_NAME=je
# Database name in production
DB_NAME=XXXX
# Database user in production
DB_USER=XXXX
@jjeaton
jjeaton / wp-config.php
Last active November 5, 2020 13:27
WP_DEBUG in wp-config.php using debug.log
<?php
define( 'WP_DEBUG', true );
if ( WP_DEBUG ) {
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
define( 'SAVEQUERIES', true );
define( 'SCRIPT_DEBUG', true );
@ini_set( 'display_errors', 0 );
if ( function_exists( 'xdebug_disable' ) ) {
git log --pretty=format:"- %s%n%b" --since="$(git show -s --format=%ad `git rev-list --tags --max-count=1`)"