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 / 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 / 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 / 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 -->