Skip to content

Instantly share code, notes, and snippets.

View bradyvercher's full-sized avatar

Brady Vercher bradyvercher

View GitHub Profile
@bradyvercher
bradyvercher / cpt-class.mustache
Created February 27, 2014 16:25
Mustache templates for generating WordPress CPT code.
/**
* {{singular}} CPT
*
* @package {{plural}}
* @author Your Name <email@example.com>
* @license http://www.gnu.org/licenses/gpl-2.0.html
* @link http://www.blazersix.com/wordpress-code-generators/
*
* @todo Remove unused code and update where needed.
*
@bradyvercher
bradyvercher / child-theme.js
Last active August 29, 2015 13:58
A concept for overriding parent theme JavaScript in a child theme.
window.themeName = window.themeName || {};
(function( window, $, undefined ) {
'use strict';
// Override the carousel config properties.
themeName.config.carousel.autoPlay = true;
themeName.setupCarousel = function() {
// Override the carousel set up without affecting anything else.
@bradyvercher
bradyvercher / wpsc-split-the-query-fix.php
Created July 18, 2014 05:47
Allow pre_get_posts hooks attached after WP eCommerce's wpsc_split_the_query() to run.
<?php
/**
* Plugin Name: WP eCommerce Query Hotfix
* Description: Allow pre_get_posts hooks attached after wpsc_split_the_query() to run.
*/
/**
* Fix 'pre_get_post' hooks when WP eCommerce is active.
*
* The wpsc_split_the_query() pre_get_posts callback attempts to run only once
@bradyvercher
bradyvercher / discussion-view.php
Last active August 29, 2015 14:05
Rough proof of concept to display blog posts similar to a topic view in a forum. Save the file as a plugin and drop the [discussion] shortcode in a page.
<?php
/**
* Plugin Name: Discussion View
* Version: 0.1.0
* Description: Display blog posts similar to a the topic view in a forum.
* Author: Brady Vercher
*/
class DiscussionView {
public function load() {
@bradyvercher
bradyvercher / html-class.php
Last active October 13, 2015 13:38
WordPress: Template tag to allow for easily filtered CSS classes across templates. (http://www.blazersix.com/blog/wordpress-class-template-tag/)
<?php
/**
* WordPress template tag to allow for CSS classes to be easily filtered across templates.
*
* @author Brady Vercher (twitter.com/bradyvercher)
* @link http://www.blazersix.com/blog/wordpress-class-template-tag/
*
* @param string $id Element identifier.
* @param array|string $classes Optional. List of default classes as an array or space-separated string.
* @param array|string $args Optional. Override defaults.
@bradyvercher
bradyvercher / gist:4254893
Last active October 13, 2015 20:58
WordPress: Helpful nav menu classes.
<?php
add_filter( 'wp_nav_menu_objects', 'blazersix_nav_menu_classes', 10, 2 );
/**
* Add helpful nav menu item classes.
*
* Adds class hooks to various nav menu items since child pseudo selectors
* aren't supported in all browsers.
*/
function blazersix_nav_menu_classes( $items, $args ) {
@bradyvercher
bradyvercher / gist:4343518
Created December 20, 2012 07:19
WordPress: Filter default image sizes on read to set custom sizes in a theme. Based on approach by Tammy Hart: http://10up.com/blog/2012/12/enforcing-wordpress-image-sizes-within-your-theme/
<?php
add_filter( 'pre_option_thumbnail_crop', 'themename_default_image_options' );
add_filter( 'pre_option_thumbnail_size_h', 'themename_default_image_options' );
add_filter( 'pre_option_thumbnail_size_w', 'themename_default_image_options' );
add_filter( 'pre_option_medium_size_h', 'themename_default_image_options' );
add_filter( 'pre_option_medium_size_w', 'themename_default_image_options' );
add_filter( 'pre_option_large_size_h', 'themename_default_image_options' );
add_filter( 'pre_option_large_size_w', 'themename_default_image_options' );
function themename_default_image_options( $value ) {
@bradyvercher
bradyvercher / gist:5025368
Created February 24, 2013 20:06
WordPress: Better Internal Link Search modifier to limit search results to a particular post type.
<?php
/**
* Search for a post type.
*
* <code>-cpt:{post_type} {query}</code>
*/
function bils_cpt_search( $results, $args ) {
$search_args = array(
'post_status' => 'any',
'post_type' => $args['modifier'][1],
@bradyvercher
bradyvercher / gist:5033090
Created February 25, 2013 20:40
WordPress: Better Internal Link Search modifier to search for posts within a particular category. http://wordpress.org/support/topic/filter-by-categories
<?php
/**
* Search for posts in a category.
*
* <code>-categ:{category slug} {query}</code>
*/
function bils_category_search( $results, $args ) {
$post_types = get_post_types( array( 'public' => true ), 'objects' );
$search_args = array(
@bradyvercher
bradyvercher / infinite-wp-list-tables.php
Last active December 20, 2015 08:39
WordPress Plugin: Infinite scroll support for WP List Tables in the WordPress admin panel.
<?php
/**
* Plugin Name: Infinite WP List Tables
* Description: Infinite scroll support for WP List Tables in the WordPress admin panel.
* Version: 0.1.0
* Author: Brady Vercher
* Author URI: http://www.blazersix.com/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/