Skip to content

Instantly share code, notes, and snippets.

View thisislawatts's full-sized avatar

Luke Watts thisislawatts

View GitHub Profile
@thisislawatts
thisislawatts / location.php
Created February 22, 2012 23:16
Advanced Custom Field - Location (+Search)
<?php
/*
* Advanced Custom Fields - New field template
*
* Create your field's functionality below and use the function:
* register_field($class_name, $file_path) to include the field
* in the acf plugin.
*
* Documentation:
@thisislawatts
thisislawatts / gist:2308784
Created April 5, 2012 07:36
Adding Custom Fields to Wordpress Comments
/* Setup our custom fields variable */
global $custom_comment_meta_LA;
$custom_comment_meta_LA = array(
'rating' => '<p class="comment-form-rating"><input id="rating" name="rating" size="30" type="hidden" value="0" /></p>',
'vote_count' => '<p class="comment-form-vote_count"><input id="vote_count" name="vote_count" size="30" type="hidden" value="0" /></p>'
// 'file' => '<label for="image">Booooosh</label><input type="file" name="image" size="31" />'
);
/* Add our custom fields into comment form */
<?php
/*
* Advanced Custom Fields - Date and Time Picker field
* Copyright (c) 2012 Per Soderlind - http://soderlind.no
*
* Documentation:
*
* This is an add-on for the Advanced Custom Fields WordPress plugin that allows you to add a Time Picker field type.
*
* Version: 1.1.1
@thisislawatts
thisislawatts / gist:3163147
Created July 23, 2012 11:20
Turn a String into a href:tel formatted link
function parse_tel_number($tel_number) {
$tel = preg_replace('/\s|\-|\(0\)+/' ,'' ,$tel_number); // Remove " ", -, "(0)"
$tel = preg_replace('/^0/', '0044', $tel); // Prefix single zero string with 0044, defaults to England
$tel = preg_replace('/\+/', '00', $tel); // Replace plus prefixed numbers with 00 to represent international
$tel = preg_replace('/^([^0])/', "00$1", $tel); // Any numbers without 0 at the front are assumed to be international
return "<a href=\"tel:$tel\">$tel_number</a>";
}
@thisislawatts
thisislawatts / ACF -> ACF Flexible Fields
Created September 9, 2012 13:00
A brute force method for migrating content out of Wordpress Galleries into a ACF repeat Gallery
<?php
/** Loads the WordPress Environment and Template */
require('./wp-blog-header.php');
/**
* Move all ACF media from a post into a ACF flexible content box.
* NB: Custom WPDB prefix, and names of custom fields
*/
global $wpdb;
@thisislawatts
thisislawatts / gist:3930616
Created October 22, 2012 09:29
iPhone rotatothon
<!DOCTYPE html>
<!--[if lt IE 7]> <html dir="ltr" lang="en-US" id="h" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html dir="ltr" lang="en-US" id="h" class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html dir="ltr" lang="en-US" id="h" class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html ldir="ltr" lang="en-US" class="no-js"> <!--<![endif]-->
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<title>iPhone Tilterising</title>
<style>
@thisislawatts
thisislawatts / index.html
Created January 7, 2013 13:49
A CodePen by LA Watts.
<button class="switch">Reverse this mother!</button>
<div class="svg-container">
<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0"
width="520" height="650" viewBox="0 0 520 650" enable-background="new 0 0 520.562 650.435"
xml:space="preserve">
<g>
<path fill="#FF0000" d="M520.496,488.999c-1.104-11.037-10.346-20.31-27.508-27.636c0.765-13.233,0.962-25.827,1.143-37.207
@thisislawatts
thisislawatts / README.md
Last active December 13, 2015 20:08 — forked from dariocravero/README.md
Moved target directory from being public which is one managed via Meteor to using uploaded/ directory which will prevent the App reloading itself.

Create a Meteor app and put the client_/server_ files in a client/server directories. Also, create an uploaded dir to save the uploaded files.

@thisislawatts
thisislawatts / post-creation.php
Created February 20, 2013 10:48
Simple way for inserting a number of posts. Originally set up for 280+ records imported from a XML file.
<?
/**
* WordPress Content Generation
*
*/
/**
* Loads the WordPress Environment and Template
*/
@thisislawatts
thisislawatts / script.js
Last active December 15, 2015 04:19
Calculate a page's base em
function calculate_base_em() {
var d = document.createElement('div');
var base_height;
d.style.opacity = 0;
d.innerHTML = 'E';
document.body.appendChild(d);
base_height = d.offsetHeight;