Skip to content

Instantly share code, notes, and snippets.

@chasereeves
chasereeves / gist:2045571
Created March 15, 2012 17:46
Thesis child theme CSS stripping all but child theme
<?php
// Initial sanity check
if (! defined('ABSPATH'))
die('Please do not directly access this file');
// Bring in the main functions file so we have access to all the yummy Thesis goodness
include_once(TEMPLATEPATH . '/functions.php');
class thesis_responsive_child_theme extends thesis_custom_loop {
@chasereeves
chasereeves / gist:2045873
Created March 15, 2012 18:30
Thesis CSS stripping within skin (custom_functions.php)
<?php
// deny direct access
if (! defined('ABSPATH'))
die('Please do not directly access this file');
class thesis_skin_example extends thesis_custom_loop {
public function __construct() {
parent::__construct(); // this "activates" the Custom Loop API
add_action('init', array($this, 'init'));
}
@chasereeves
chasereeves / gist:2220340
Created March 27, 2012 21:18
Wordpress show recent posts
<?php
$args=array('showposts'=>5,'caller_get_posts'=>1);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<h2>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
<?php if (get_comments_number()==0) { } else { ?>
<a href="<?php the_permalink(); ?>#comments"><?php comments_number( '', '1 Comment', '% Comments' ) ?></a>
<?php } ?>
@chasereeves
chasereeves / gist:2296683
Created April 4, 2012 00:32
Wordpress list all posts by categories
<?php
foreach( get_categories('hide_empty=1','order_by=name') as $cat ) :
if( !$cat->parent ) {
echo '<h2><a href="#">' . $cat->name . '</a></h2>';
echo '<ul>';
process_cat_tree( $cat->term_id );
}
endforeach;
wp_reset_query(); //to reset all trouble done to the original query
@chasereeves
chasereeves / gist:2339127
Created April 8, 2012 18:47
Customize thesis comment intro
function replace_comments_intro($content, $number) {
$content = "Comment &amp; Add Your Voice\n";
return $content;
}
add_filter('thesis_comments_intro', 'replace_comments_intro');
@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)})}});
@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: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: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: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 );