Skip to content

Instantly share code, notes, and snippets.

View harryfinn's full-sized avatar
:shipit:

Harry Finn harryfinn

:shipit:
View GitHub Profile
@harryfinn
harryfinn / index.php
Last active August 29, 2015 14:03
Blank HTML5 template page using Bootstrap CSS CDN - Valid HTML5 W3C as of June 2014
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<?php if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) header('X-UA-Compatible: IE=edge,chrome=1'); ?>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1" />
<title>Untitled</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<!-- Optional theme -->
@harryfinn
harryfinn / wp_nav_menu_args.php
Last active August 29, 2015 14:05
WordPress - Default menu fallback_cb for non-existent menus
function hf_default_menu_fallback($nav_elem, $nav_class) {
echo (!empty($nav_elem) ? '<' . $nav_elem . (!empty($nav_class) ? ' class="' . $nav_class . '">' : '>') : '')
. '<ul class="menu">'
. '<li class="menu-item">'
. '<a href="' . admin_url('nav-menus.php?action=edit&menu=0') . '">Add Menu</a>'
. '</li>'
. '</ul>'
. ($nav_elem !== false ? '</' . $nav_elem . '>' : '');
}
@harryfinn
harryfinn / README.md
Last active May 9, 2017 15:16
WordPress autoloader for PHP Classes

WordPress PHP Class autoloader

The issue

I recently came across an issue whereby installing the popular Yoast SEO plugin caused the frontend of a production site to crash, stating that it couldn't find many of the custom PHP classes written and included in the project theme via the __autoload() php function.

I found others had experienced similar issues when trying to use Yoast with custom PHP classes but not found a fix. Although this issue was also known to the Yoast plugin authors, a fix had yet to appear, so I started to try to find/create a fix myself.

The Fix

@harryfinn
harryfinn / Preferences.sublime-settings
Created November 24, 2015 15:40
Sublime Text 3 - User settings
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"color_scheme": "Packages/User/SublimeLinter/Material-Theme (SL).tmTheme",
"ensure_newline_at_eof_on_save": true,
"font_options":
[
"gray_antialias"
],
"font_size": 14,
@harryfinn
harryfinn / jquery.isonscreen.js
Created February 17, 2016 09:33
isOnScreen jQuery plugin for check if given element is within the current viewport
(function($) {
$.fn.isOnScreen = function(x_offset, y_offset) {
if(x_offset == null || typeof x_offset == 'undefined') x_offset = 1;
if(y_offset == null || typeof y_offset == 'undefined') y_offset = 1;
var win = $(window),
viewport = {
top : win.scrollTop(),
left : win.scrollLeft()
},
@harryfinn
harryfinn / wp-cli-migrate-db.md
Created March 24, 2016 11:59
WP-CLI DB migrate instructions

Instructions for using WP-CLI to migrate a WordPress DB

# Export current (local) DB
wp db export db.sql

# Copy file from local to server (may need to amend server path if not in html folder)
# The example below is for local to remote, simply swap these 2 around for remote to local
scp -r db.sql www-data@IP_ADDRESS:/var/www/html

# SSH onto box (should be same connection details as above)
@harryfinn
harryfinn / pagespeed-module.md
Last active July 21, 2023 05:06
Pagespeed module (Apache) instructions

Using Google Pagespeed module (Apache)

Install

Follow initial install instructions here

Recommended additional modules

Add the following to the bottom (but inside the <IfModule /> block) of /etc/apache2/mods-available/pagespeed.conf

@harryfinn
harryfinn / wp_with_brunch.sh
Last active May 19, 2016 19:18
bash script to pull down wp-with-brunch framework files
#/bin/bash
function get_branch {
valid_branches=("theme" "component")
if `echo ${valid_branches[@]} | grep -qw "$1"`; then
echo "Branch selected: $1-framework"
git clone -b "$1-framework" git@github.com:1minus1limited/wp-with-brunch.git .
rm -rf .git .gitignore
@harryfinn
harryfinn / ubuntu16.04-lamp-nodejs-wp-cli.md
Last active May 17, 2022 14:12
Ubuntu 16.04: LAMP w/ NodeJS & WP-CLI

Ubuntu 16.04 LAMP w/ NodeJS & WP-CLI

Setup LAMP stack

Apache

apt-get update
apt-get install apache2
@harryfinn
harryfinn / README.md
Last active August 8, 2016 16:39
WordPress helper class for building themes with Brunch support

WP Brunch

Usage

To use this file simply add this to your WordPress theme (in your includes folder or similar) then add the following to your functions.php file:

require_once(get_template_directory() . '/includes/class.wp-brunch.php');