Skip to content

Instantly share code, notes, and snippets.

@jhebb
jhebb / Truncate.Filter.js
Created February 15, 2016 13:48 — forked from CMCDragonkai/Truncate.Filter.js
JS: AngularJS Truncate Filter for Words and Characters. Adapted from https://github.com/sparkalow/angular-truncate
define(['angular'], function(angular){
'use strict';
/**
* Truncates characters or words. Truncate characters by default does not truncates on a word.
*/
angular.module('Filters')
.filter('TruncateCharacters', [
function(){
@jhebb
jhebb / gist:7125184
Created October 23, 2013 19:34
WordPress taxonomy custom orderby description
// Custom 'orderby' for taxonomies
function customtaxorder_applyorderfilter($orderby, $args) {
if($args['orderby'] == 'description')
return 'tt.description';
else
return $orderby;
}
add_filter('get_terms_orderby', 'customtaxorder_applyorderfilter', 10, 2);
@jhebb
jhebb / widget_link_title.php
Created May 21, 2013 14:26
Allows you to define a link that is wrapped around WordPress widget titles.
@jhebb
jhebb / grid.less
Last active December 17, 2015 10:39
Semantic alternative to Chris's excellent grid demo at CSS-Tricks : http://css-tricks.com/dont-overthink-it-grids/
/*********************************************
SIMPLE GRID
A very basic semantic Less grid system using padding.
Based on Chris Coyier's excellent grid demo at CSS-Tricks : http://css-tricks.com/dont-overthink-it-grids/
********************************************/
// Default grid padding, change to override
@gridpad: 2em;
@jhebb
jhebb / grid.scss
Last active December 16, 2015 17:58
Basic SCSS grid system using margin gutters - allows grid items to have background colors/images without bleeding into gutters
/*
* KNOWN ISSUES
- gutter needs to be percentage based
- grid containers that don't fit full-width don't clear grid containers below them. May need "clear: both" on grid containers.
* TODO
- test further
- add bottom margin to grid-container?
- move margin-bottom to grid-container instead of removing from last-child?
@jhebb
jhebb / is_blog.php
Last active December 16, 2015 02:59 — forked from wesbos/is_blog.php
Add is_blog() function to WordPress
function is_blog () {
global $post;
$posttype = get_post_type($post );
return ( ( is_archive() || is_home() || is_single() ) && ( $posttype == 'post') ) ? true : false ;
}
Usage:
<?php if (is_blog()) { echo 'You are on a blog page'; } ?>
@jhebb
jhebb / Custom Taxonomy Markup
Last active December 12, 2015 01:08 — forked from johnbhartley/Custom Tax
Show custom taxonomy with custom markup
<?php
$query = new WP_Query(array('post_type' => 'custom-post-type'));
while ($query->have_posts()) : $query->the_post();
$terms = get_the_terms( $post->id, 'custom-taxonomy' ); // registered custom taxonomy in custom post type
if( $terms && ! is_wp_error( terms ) ) {
foreach( $terms as $term ) {
echo '<a class="term-' . $term->slug . '" href="' . get_term_link($term) . '" title="' . $term->name .'">' . $term->name .'</a>';
}
}
@jhebb
jhebb / is_subpage.php
Last active July 19, 2023 14:54
WordPress is_subpage() function to check if a page against it's immediate parent or all it's parents
/**
* Is SubPage?
*
* Checks if the current page is a sub-page and returns true or false.
*
* @param $page mixed optional ( post_name or ID ) to check against.
* @param $single boolean optional - default true to check against all parents, false to check against immediate parent.
* @return boolean
*/