Skip to content

Instantly share code, notes, and snippets.

View tddewey's full-sized avatar

Taylor Dewey tddewey

View GitHub Profile
@tddewey
tddewey / index.html
Created September 24, 2012 23:24
Portland WP Meetup Group Demo
<!doctype HTML>
<html>
<head>
<title>Typography Demo</title>
<style type="text/css">
body {
max-width: 50rem;
margin: 5.5rem auto 5.5rem auto;
@tddewey
tddewey / gist:3862239
Created October 9, 2012 23:53
Moving meta boxes with WP_Content editors
/**
* Moves meta boxes in the 'normal' context to the front of the 'advanced' context.
* To be used when inserting content via the edit_form_advanced hook (example given)
*/
class MoveMetaBoxes {
public $CPT_Slug = 'tdd_library';
function __construct() {
add_action( 'edit_form_advanced', array( $this, 'edit_form_advanced' ), 1 );
@tddewey
tddewey / gist:4100522
Created November 17, 2012 21:43
Explaining comment_reply_link nuance
<?php
/**
* Very simplified comment callback to illustrate one particular nuance. Yours should be more robust.
*
* param $comment object The comments object
* param $args array Array of parameters passed to wp_list_comments
* param $depth integer How deep we are in the nested comments
*/
function tdd_demo_comments_callback( $comment, $args, $depth ) {
?>
@tddewey
tddewey / .bash_profile
Created January 29, 2013 03:46
Rsync -- modify DEVENV for your own setup.
vipsync() {
local DEVENV="/Users/tddewey/Sites/vip/wp-content/themes/vip/"
rsync -rv --delete --exclude='.svn' $DEVENV$1/* $DEVENV$2
cd $DEVENV$2
svn status | grep '^!' | awk '{print $2}' | xargs svn rm
svn status | grep '^?' | awk '{print $2}' | xargs svn add
}
@tddewey
tddewey / .bash_profile
Created February 15, 2013 20:57
Rsync Script for dev->vip repo (or back again, really)
vipsync() {
local DEVENV="/Users/tddewey/Sites/vip/wp-content/themes/vip/"
rsync -rv --delete --exclude='.svn' $DEVENV$1/* $DEVENV$2
cd $DEVENV$2
svn status | grep '^!' | awk '{print $2}' | xargs svn rm
svn status | grep '^?' | awk '{print $2}' | xargs svn add
}
@tddewey
tddewey / HTML CSS cheat sheet
Last active December 17, 2015 00:29
HTML and CSS Cheat Sheet made quickly for codewithme
Do not copy and paste this. Your fingers need the muscle memory.
# HTML Cheat Sheet
<!-- basic structure tags -->
<html></html>
<head></head>
<body></body>
<!-- link to a stylesheet -->
<link rel="stylesheet" href="/css/style.css">
@tddewey
tddewey / singleton_template.php
Created July 23, 2013 07:51
Singleton template I'm currently using to namespace stuff.
class My_Singleton {
/**
* The only instance of the My_Singleton Object
* @var My_Singleton
*/
private static $instance;
/**
* Returns the main instance.
<?php
/**
* Only allow super admins to upload files
*
* @see map_meta_cap()
*
* @param array $caps Primitive capabilities assigned to meta caps.
* @param string $cap Meta capability.
* @param int $user_id The current user id.
* @param array $args An array of contextual arguments, sometimes empty.
@tddewey
tddewey / admin.js
Created September 11, 2013 01:05
In javascript, do something if the featured image (post thumbnail) is updated
// Do something if the featured image is updated by inspecting ajaxComplete callback
jQuery(document).ajaxComplete(function(event, xhr, settings){
// Parse the request
var vars = {};
var requestVars = settings.data.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, key, value) {
vars[key] = value;
});
// Take action if the action parameter is for the thumbnail
@tddewey
tddewey / kses.php
Created October 28, 2013 18:30
Kses whitelist for 'posts'
$allowedposttags = array(
'address' => array(),
'a' => array(
'href' => true,
'rel' => true,
'rev' => true,
'name' => true,
'target' => true,
),
'abbr' => array(),