Skip to content

Instantly share code, notes, and snippets.

View bradyvercher's full-sized avatar

Brady Vercher bradyvercher

View GitHub Profile
@bradyvercher
bradyvercher / installed-plugin-details.php
Created February 2, 2013 05:23
WordPress Plugin: Show a "Details" link for installed plugins to view information from the WordPress.org plugin directory.
<?php
/**
* Plugin Name: Installed Plugin Details
* Description: Show a "Details" link for installed plugins to view information from the WordPress.org plugin directory.
* Version: 1.0.0
* Author: Blazer Six
* Author URI: http://www.blazersix.com/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*
@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: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 / 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 / url-tokens.php
Last active May 21, 2016 17:46
Basic URL signing functions for WordPress
<?php
/**
* Basic URL Signing functions for WordPress.
*
* @author Brady Vercher (twitter.com/bradyvercher)
* @link http://www.blazersix.com/blog/protect-your-products-and-improve-your-systems-with-signed-urls/
*/
/**
* Sign a URL to ensure it hasn't been tampered with.
@bradyvercher
bradyvercher / gist:1576900
Created January 8, 2012 02:24
WordPress: Sort an array of post objects by any property, remove duplicates, and use post ids as the key in the returned array.
<?php
function sort_posts( $posts, $orderby, $order = 'ASC', $unique = true ) {
if ( ! is_array( $posts ) ) {
return false;
}
usort( $posts, array( new Sort_Posts( $orderby, $order ), 'sort' ) );
// use post ids as the array keys
if ( $unique && count( $posts ) ) {