Skip to content

Instantly share code, notes, and snippets.

View mattboon's full-sized avatar

Matt Berridge mattboon

View GitHub Profile
@mattboon
mattboon / gist:1337181
Created November 3, 2011 17:51
Fix YouTube Embeds appearing over position: fixed; items
// Fix YouTube embeds
$('iframe[src*="youtube"]').each(function() {
var url = $(this).attr("src");
$(this).attr("src",url+"?wmode=transparent");
});
@mattboon
mattboon / gist:2021115
Created March 12, 2012 10:45
WordPress - Query Posts with date custom field, hide those in past
<ul class="feed events">
<?php
global $post;
$args = array(
'numberposts' => 3,
'category' => 3,
'meta_key' => 'event_date',
'meta_value' => date("Y-m-d"),
'meta_compare' => '>=',
'orderby' => 'meta_value',
@mattboon
mattboon / gist:2158494
Created March 22, 2012 13:58
jQuery - Action when user has scrolled
$(document).scroll(function(e) {
var nav = $('nav'),
page = $('body'),
scrollValue = page[0].offsetTop - window.pageYOffset;
if(scrollValue < -20 ) {
nav.addClass('scrolled');
}
else {
nav.removeClass('scrolled');
@mattboon
mattboon / gist:2421469
Created April 19, 2012 14:55
WordPress - Gravity forms snippets
<?php
// Anchor when erroring
add_filter("gform_confirmation_anchor", create_function("","return true;"));
// Error message
add_filter("gform_validation_message", "change_message", 10, 2);
function change_message($message, $form){
//return "Failed Validation - " . $form["title"];
return "<strong class=\"message error\">Please complete the required fields and try again</strong>";
@mattboon
mattboon / gist:2480565
Created April 24, 2012 15:22
WordPress - Call an external template via shortcode
<?php
function shortcode_your_shortcode() {
ob_start();
include (TEMPLATEPATH . '/inc/your-template.php');
$output_string = ob_get_contents();
ob_end_clean();
return $output_string;
}
add_shortcode('SHORTCODE', 'shortcode_your_shortcode');
@mattboon
mattboon / gist:2658869
Created May 11, 2012 10:31
WordPress - Add Tag ID column for post_tags
<?
// Remove columns from Tags section and add Tag ID
// -------------------------------------------------------------
add_filter('manage_edit-post_tag_columns', 'my_post_tag_columns', 5);
function my_post_tag_columns($defaults) {
$defaults['tag_id'] = 'Tag ID';
unset($defaults['description']);
unset($defaults['slug']);
return $defaults;
@mattboon
mattboon / gist:2731316
Created May 19, 2012 16:01
jQuery - ResponsiveReel
// Simple Slideshow
$(function () {
var visibleClass = 'visible'; // no .
var currentClass = 'current'; // no .
var animationTime = 300; // fade duration
var containerClass = '.slides'; // class on container
var slideItem = 'img'; // what are we sliding?
var slideItems = $(containerClass).find(slideItem); // all slides
var slideNumbers = $(".slide-nav a"); // pagination numbers
var slideNext = $(".next"); // next link
@mattboon
mattboon / gist:2929125
Created June 14, 2012 08:49
WordPress - Query / test the_excerpt
<?php
function my_query_excerpt($page) {
global $post;
$save_post = $post;
$post = get_post($page);
$output = '<p>' . get_the_excerpt() . '</p>';
$post = $save_post;
return $output;
}
@mattboon
mattboon / gist:2929172
Created June 14, 2012 08:58
WordPress - Remove inline <img> sizes / attributes
<?php
// Remove <img> dimensions
// -------------------------------------------------------------
add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10 );
add_filter( 'image_send_to_editor', 'remove_thumbnail_dimensions', 10 );
add_filter( 'the_content', 'remove_thumbnail_dimensions', 10 );
function remove_thumbnail_dimensions( $html ) {
$html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
@mattboon
mattboon / gist:2929500
Created June 14, 2012 10:33
WordPress - Remove inline CSS from .wp-caption (plugin)
<?php
/*
Plugin Name: FixWpCaption
Plugin URI: #
Description: Removes inline CSS from .wp-caption
*/
class FixWpCaption{
public function __construct(){
add_filter('img_caption_shortcode', array($this, 'fixcaption'), 10, 3);