Skip to content

Instantly share code, notes, and snippets.

View mattwiebe's full-sized avatar

Matt Wiebe mattwiebe

View GitHub Profile
@mattwiebe
mattwiebe / no_querystrings.php
Created April 18, 2011 22:39
Gets rid of WordPress's (annoying) usage of querystrings for versioning.
<?php
add_action( 'wp_enqueue_scripts', 'piss_off_query_strings' );
function piss_off_query_strings() {
global $wp_scripts, $wp_styles;
foreach( (array) $wp_scripts->registered as $handle => $obj ) {
$wp_scripts->registered[$handle]->ver = null;
}
foreach( (array) $wp_styles->registered as $handle => $obj ) {
$wp_styles->registered[$handle]->ver = null;
@mattwiebe
mattwiebe / wp_html5ify.php
Created September 20, 2011 15:22
HTML5 script and style
<?php
/**
* HTML5 doesn't require the "type" attribute for JS or CSS.
* Say hello to leaner markup.
*/
// html5-ify it
add_action('wp_footer', 'sd_script_decruft_start', -10);
add_action('wp_head', 'sd_script_decruft_start', -10);
<?php
/**
* Load a template part into a template.
* A subdirecory-favoring variant of get_template_part() for cleaner themes.
*
* Makes it easy for a theme to reuse sections of code in a easy to overload way
* for child themes.
*
* Includes {slug}/{slug}.php for a theme or if a name is specified then a
@mattwiebe
mattwiebe / wp_plugin_stub.php
Created January 10, 2012 18:05
A good starting place for a static class-based WordPress plugin
<?php
/*
Plugin Name: A Plugin Name
Plugin URI: http://somadesign.ca/
Description: Be descriptive.
Version: 0.1
Author: Soma Design
Author URI: http://somadesign.ca/
License: GPL v2
@mattwiebe
mattwiebe / highlight-scheduled-posts.php
Created February 23, 2012 17:53
Highlight Scheduled Posts
<?php
/*
Plugin Name: Highlight Scheduled Posts
Plugin URI: http://somadesign.ca/
Description: Highlight scheduled posts in the admin
Version: 0.1
Author: Matt Wiebe
Author URI: http://somadesign.ca/
*/
@mattwiebe
mattwiebe / of-italics.php
Created March 24, 2012 14:54
Options Framework Italics checkbox
<?php
/*
Plugin Name: Options Framework Italics
Plugin URI: http://somadesign.ca/
Description: Add dedicated italics checkbox to the Options Framework typography fields.
Version: 0.1
Author: Soma Design
Author URI: http://somadesign.ca/
License: GPL v2
@mattwiebe
mattwiebe / disable-twitter-embeds.php
Created June 14, 2012 15:50
Disable Twitter Embeds
<?php
/*
Plugin Name: Disable Twitter Embeds
Description: Disables the Twitter embeds introduced in WordPress 3.4
Version: 1.0
Author: Matt Wiebe
Author URI: http://mattwiebe.wordpress.com/
*/
@mattwiebe
mattwiebe / exclude-cat.php
Created June 26, 2012 23:40
exclude category from home
<?php
function mw_exclude_cat_from_home( $query ) {
// this is the category ID(s) you want to exclude.
$to_exclude = array( 3 );
if ( $query->is_main_query() && $query->is_home() ) {
$query->set( 'category__not_in', $to_exclude );
}
}
add_action( 'pre_get_posts', 'mw_exclude_cat_from_home' );
jQuery( document ).ready( function( $ ) {
// Local vars.
var $masthead = $( '#masthead' ),
timeout = false,
$siteInfoClone,
$headerImageClone,
$socialLinksClone,
ajaxRequest = false,
$clickedModule;
@mattwiebe
mattwiebe / filter-out.php
Last active December 15, 2015 18:09
Filter out posts according to permissions and categories
<?php
add_action( 'pre_get_posts', 'mw_post_limiter' );
function mw_post_limiter( $wp_query ) {
// only modify for the main query - if we're not there, bail.
if ( ! $wp_query->is_main_query() )
return;
// category_slug => permission
$filtration_pairs = array(