Skip to content

Instantly share code, notes, and snippets.

View mattboon's full-sized avatar

Matt Berridge mattboon

View GitHub Profile
@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);
@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:4072631
Created November 14, 2012 15:04
WordPress - Add PDF filter to media library
<?php
// Add PDF filter to media library
add_filter( 'post_mime_types', 'modify_post_mime_types' );
function modify_post_mime_types( $post_mime_types ) {
// select the mime type, here: 'application/pdf'
// then we define an array with the label values
$post_mime_types['application/pdf'] = array( __( 'PDFs' ), __( 'Manage PDFs' ), _n_noop( 'PDF <span class="count">(%s)</span>', 'PDFs <span class="count">(%s)</span>' ) );
// then we return the $post_mime_types variable
return $post_mime_types;
@mattboon
mattboon / gist:2953889
Created June 19, 2012 12:36
WordPress - Remove / unregister taxonomy
<?php
add_action( 'init', 'unregister_taxonomy');
function unregister_taxonomy(){
global $wp_taxonomies;
$taxonomy = 'post_tag';
if ( taxonomy_exists( $taxonomy))
unset( $wp_taxonomies[$taxonomy]);
}
@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: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:3780739
Created September 25, 2012 09:01
WordPress - Local Admin CSS broken
<?
// no idea why this works but add to wp-config.php
define('SCRIPT_DEBUG', true);
@mattboon
mattboon / gist:3637228
Created September 5, 2012 14:11
Opt-in Typography
/*----------------------------------------------------------------------------------------*/
/* Opt-in typography - http://goo.gl/H6sGd
* Zero off common semantic elements to stop re-definition
* Use .text class on the parent of anything requiring text styles
/*----------------------------------------------------------------------------------------*/
$baseline: 1.5em;
@mixin zero-text-elements {
h1, h2, h3, h4, h5, h6, blockquote, pre,
@mattboon
mattboon / gist:1275191
Created October 10, 2011 12:32
WordPress - Query Custom Post Type and taxonomy term by ID
<?php
// gets the ID from a custom field to show posts on a specific page
$buildType = get_post_meta($post->ID, 'build_type_id', true);
// run query
query_posts(array(
'post_type' => 'portfolio',
'showposts' => -1,
'tax_query' => array(
array(
@mattboon
mattboon / gist:4202188
Created December 4, 2012 09:34
WordPress - Split content above and below <!--more--> tag
<?php
$morestring = '<!--more-->';
$explode_content = explode( $morestring, $post->post_content );
$content_before = apply_filters( 'the_content', $explode_content[0] );
$content_after = apply_filters( 'the_content', $explode_content[1] );
?>