Skip to content

Instantly share code, notes, and snippets.

View bigdawggi's full-sized avatar

Matthew Richmond bigdawggi

  • Bigdawggi Co
  • Island Park, ID
View GitHub Profile
@bigdawggi
bigdawggi / gist:b5e241ab7ead9f626c1c
Created June 26, 2015 20:21
Business Structured Data Example
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "SportingGoodsStore",
"openingHours": "Mo,Tu,We,Th,Fr,Sa,Su 08:00-18:00",
"url": "https://www.example.com/",
"logo": "https://www.example.com/logo.png",
"address": {
"@type": "PostalAddress",
"addressLocality": "Example City",
@bigdawggi
bigdawggi / basic-example
Last active August 29, 2015 14:25
Code structure for displaying inline contents in lightbox
<!-- REQUIREMENTS:
A link with
- a rel of "lightbox"
- an href that points to the the ID of the target div
- a data-lightbox-type="inline" attribute
-->
<a href="#popup-links" rel="lightbox" data-lightbox-type="inline">Load Inline HTML</a>
<!-- A div with a class of "hide", and an ID that matches the href of the originating link -->
<div id="popup-links" class="hide">
<link href="//fonts.googleapis.com/css?family=Josefin+Sans+Std+Light:regular&subset=latin" rel="stylesheet" type="text/css" >
<style type="text/css">
body {
font-family: 'Josefin Sans Std Light', serif;
font-size: 18px;
letter-spacing: 1px;
}
</style>
@bigdawggi
bigdawggi / README.txt
Created October 24, 2011 19:31 — forked from alexkingorg/wp-switch-to-post.php
switch_to_post() stack implementation (similar to switch_to_blog()) for WordPress
# Switch to Post README
## Overview
switch_to_post() stack implementation (similar to switch_to_blog()) for WordPress
## Questions
1. Do we want to still switch to post if the get_post fails?
2. Have a (bool) return value based on get_post?
## Test Steps
@bigdawggi
bigdawggi / friendly-exception.php
Created January 10, 2012 01:51
Friendly Exceptions
<?php
class Friendly_Exception extends Exception {
public function __construct($friendly_message, $technical_message = '', $code = 0) {
$this->friendly_message = $friendly_message;
$this->technical_message = $technical_message;
parent::__construct($friendly_message, $code);
}
@bigdawggi
bigdawggi / Homestead.yaml
Created September 29, 2015 18:58
Homestead YAML
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
@bigdawggi
bigdawggi / gist:4062892
Created November 12, 2012 23:53
Import featured image on demand
add_filter(
'get_post_metadata',
array($this, 'maybe_grab_simpleview_photo_for_featured_image'),
10,
4
);
/**
* On the request for a post's featured image, it goes and retrieves it from the 3rd party site,
* attaches it to the current post, then sets it as a featured image. This only happens once per post.
@bigdawggi
bigdawggi / post-receive
Last active November 15, 2015 05:31
Post Receive Hook for Git
#!/bin/sh
echo "********************"
echo "Post receive hook: Deploying Website"
echo "********************"
# Set up some vars
export GIT_REPO=/home/git/production/example.git
export GIT_WORK_TREE=/var/www/vhosts/example.com/staging
echo "*** Clearing out any staging dir ***"
@bigdawggi
bigdawggi / basic-og-image-fallback.php
Created January 3, 2013 15:46
Super-simple fall-back open graph image for your WordPress blog. I didn't want/need a whole plugin for this, just wanted a simple og:image fall-back for my site.
<?php
// Add this to your functions.php file
function mgr_og_image_fallback() {
if (!has_post_thumbnail()) {
// Replace the image URL unless you want my mug as your image for Open Graph Image ;)
?>
<meta property="og:image" content="http://i1.wp.com/matthewgrichmond.com/files/2012/03/matt.jpg?resize=310%2C180" />
<?php
}
@bigdawggi
bigdawggi / quick-and-dirty-cache-expire-test.php
Created February 1, 2013 18:52
Quick and dirty cache expiration testing. I placed in functions.php just for a quick place to put it. Refresh the page, and it should change every 10 seconds.
<?php
if (isset($_GET['matt'])) {
$cur_time = time();
$cache = wp_cache_get('matt-time', 'matt');
if ($cache !== false) {
echo '<pre>Found'.print_r($cache, 1).'</pre>';
}
else {
wp_cache_set('matt-time', $cur_time, 'matt', 10);