Skip to content

Instantly share code, notes, and snippets.

@chasereeves
chasereeves / gist:3885925
Created October 13, 2012 19:53
Wordpress Custom Meta Box
//=========================================================== Custom Meta Box - Video
$prefix = 'matterful_optionbox_';
$meta_box = array(
'id' => 'matterful_optionbox',
'title' => 'Ice Brimmin’ Options',
'page' => 'post',
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
@chasereeves
chasereeves / gist-shortcode.php
Created October 1, 2012 15:45 — forked from norcross/gist-shortcode-css.css
embed gist shortcode
function gist_shortcode($atts, $content = NULL) {
extract( shortcode_atts( array(
'id' => '',
'title' => ''
), $atts ) );
if (empty ($id) )
return;
@chasereeves
chasereeves / gist:3794400
Created September 27, 2012 14:45
Course Objectives Initials Outline/Questions
Course Information
==================
Course Name:
------------
Description:
------------
@chasereeves
chasereeves / gist:3757911
Created September 20, 2012 19:42
Wordpress WP_Query example
<ul class="none">
<?php $lessons_query = new WP_Query( array('post_type' => 'lesson', 'cat' => 21,'orderby' => date, 'order' => DESC, 'posts_per_page' => 5));
while ( $lessons_query->have_posts() ) : $lessons_query->the_post(); ?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endwhile; wp_reset_postdata(); ?>
</ul>
@chasereeves
chasereeves / gist:3350644
Created August 14, 2012 16:30
Wordpress similar posts without plugin
<?php
//=========================================================== SIDEBAR == Similar Posts
function similar_posts() {
echo "<li class=\"widget similar_posts\">";
echo "<h3>Similar Posts</h3>";
echo "<ul>";
global $post;
//stores the original post data
$original_post = $post;
@chasereeves
chasereeves / gist:3124135
Created July 16, 2012 18:25
Wordpres Custom Menu/Navigation Walker - remove all list items from menu, only links remain.
//========================================================== CUSTOM MENU WALKER - remove list stuff, only links
class custom_menu_walker_remove_list extends Walker_Nav_Menu {
function start_el(&$output, $item, $depth, $args) {
global $wp_query;
$class_names = $value = '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$classes[] = 'menu-item-' . $item->ID;
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
$class_names = ' class="' . esc_attr( $class_names ) . '"';
$id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );
@chasereeves
chasereeves / gist:3005606
Created June 27, 2012 17:38
textmate's convert selection to entity (disregarding html tags)
#!/usr/bin/env ruby
$KCODE = 'U'
$char_to_entity = { }
File.open("#{ENV['TM_BUNDLE_SUPPORT']}/entities.txt").read.scan(/^(\d+)\t(.+)$/) do |key, value|
$char_to_entity[[key.to_i].pack('U')] = value
end
def encode (text)
text.gsub(/[^\x00-\x7F]|["'<>&]/) do |ch|
@chasereeves
chasereeves / gist:2956909
Created June 19, 2012 22:32
Remove list from wordpress nav, replace with span
<p class="menu-main-menu-container">
<?php wp_nav_menu( array( 'menu' => 'Main Menu','container' => false,'items_wrap' => '%3$s','walker' => new no_list_custom_nav_walker() ) ); ?>
</p>
class no_list_custom_nav_walker extends Walker {
var $tree_type = array( 'post_type', 'taxonomy', 'custom' );
var $db_fields = array( 'parent' => 'menu_item_parent', 'id' => 'db_id' );
function start_lvl(&$output, $depth) {
$indent = str_repeat("\t", $depth);
@chasereeves
chasereeves / gist:2361153
Created April 11, 2012 18:24
PHP: List all images from directory
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>&lt;img src="Matterful"&gt;</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="Chase Reeves">
<!-- Date: 2012-04-04 -->
@chasereeves
chasereeves / gist:2345229
Created April 9, 2012 18:22
jQuery form placeholder fallback for older browsers
// == ## ========================================================== Replace placeholder in older browsers
jQuery(function(){jQuery.support.placeholder=false;test=document.createElement("input");if("placeholder" in test){jQuery.support.placeholder=true}});$(function(){if(!$.support.placeholder){$("input[placeholder]").each(function(){var val=$(this).attr("placeholder");$(this).attr("value",val)})}});