Skip to content

Instantly share code, notes, and snippets.

@seamusleahy
seamusleahy / NextGEN echo gallery pictures
Created February 7, 2011 19:23
Output a list of the images in a NextGEN gallery
@seamusleahy
seamusleahy / gist:2028532
Created March 13, 2012 12:41
Adding mobile-only show/hide toggle button to your navigation with Twitter Bootstrap
<!-- I noticed that Twitter Bootstrap has a feature to make your navigation work on mobile.
It just appears that the documentation is missing for it.
Take the navigation bar and then add a toggle button and wrap the navigation list in '.nav-collapse'.
-->
<nav class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<!-- Add toggle button -->
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
@seamusleahy
seamusleahy / gist:3098949
Created July 12, 2012 15:46
Create a curve to text using Lettering.js, Sass, and Compass
/* Add a wave alignment to your title text using Sass, Compass, and Lettering.js.
*
* Lettering.js wraps each letter with a span with a class of .char<#>.
* Compass provides math functions including the sin which provides the wave form.
*/
$length: 11; // The word is 11 letters long
@for $i from 1 through $length {
.char#{$i} {
@include transform(translateY( sin(($i - 1)/($length - 1)*2*pi()) * -25px) );
@seamusleahy
seamusleahy / get_postmeta_tuples.php
Created September 11, 2012 17:00
A utility function for WordPress to retrieve metadata from post to display in a list or drop-down
<?php
/**
* Retrive the tuples of metadata in a given set of post-types.
*
* @param $metakeys string|array - The metakeys to be the tuple elements
* @param $post_types string|array optional - The post-types to limit the query on. Defaults to the current post-type
*
* <?php
* $cities = get_postmeta_tuples( array( 'city', 'state' ), 'chapters' );
* ?>
@seamusleahy
seamusleahy / functions.php
Created September 11, 2012 17:08
Simply add AJAX callbacks to your WordPress Theme
<?php
/**
* 1. Add this to your theme's functions.php file.
* 2. Create an 'ajax' folder in your theme directory.
* 3. Create a PHP file to handle the AJAX call in the ajax folder.
* 4. From Javascript, make an AJAX call using jQuery:
* 5. $.get( window.themeSettings.ajaxUrl, {action: window.themeSettings.themeAjaxAction, template: 'YOUR TEMPLATE NAME (MINUS THE .php EXTENSION)'}, function( data ) { } );
*/
@seamusleahy
seamusleahy / Retro
Last active December 10, 2015 21:39
Fancy Effects with WP.com's Proton API http://developer.wordpress.com/docs/photon/api/
?colorize=40,10,-40&contrast=2
?colorize=30,10,-40&contrast=5&brightness=-40
?colorize=10,10,-20&contrast=5&brightness=-10
?colorize=10,10,-20&contrast=5&brightness=15
?colorize=-20,10,20&contrast=5&brightness=-30
?colorize=-20,10,20&contrast=5&brightness=-30&filter=blurgaussian
@seamusleahy
seamusleahy / gist:4758617
Created February 11, 2013 23:29
Send additional header info for inserted media.
<?php
function send_extra_media_info( $html, $send_id, $attachment ) {
@header( "X-Attachment-ID: " . intval( $send_id ) );
foreach( array('post_title', 'image-size' ) as $key ) {
if( array_key_exists($key, $attachment) ) {
@header( "X-".$key.": " . str_replace( array( "\r", "\n"), ' ', $attachment[$key] ) );
}
}
@seamusleahy
seamusleahy / gist:4956037
Last active December 13, 2015 18:29
A function to retrieve the bare structure of a WordPress menu.
<?php
/**
* Retrieve the bare structure of a nav menu instead of the formatted output.
*
* @param unknown $args - the same arguments you pass into wp_nav_menu (the fallback and output arguments do not apply)
*/
function prefix_get_nav_menu( $args=array() ) {
$args = wp_parse_args( $args, array() );
$args = apply_filters( 'wp_nav_menu_args', $args );
$args = (object) $args;
@seamusleahy
seamusleahy / gist:5388747
Last active December 16, 2015 05:59
Open external links in a new window using jQuery.
// Open external links in new windows
jQuery(document).ready(function($) {
var re = new RegExp( '^([^/]+:)?//([^/]+\\.)?' + window.location.host.replace(/\./g, '\\.') + '/');
$('body').on('click', 'a', function(event) {
if(!re.test(this.href)) {
window.open(this.href, '_blank');
return false;
}
});
});
@seamusleahy
seamusleahy / gist:5621434
Created May 21, 2013 17:06
Remove ability to create new posts of a custom post type in WordPress.
<?php
register_post_type( 'custom_post_type_name', array(
'capabilities' => array(
'create_posts' => false,
)
));