Skip to content

Instantly share code, notes, and snippets.

View Kevinlearynet's full-sized avatar

Kevinleary.net Kevinlearynet

View GitHub Profile
@Kevinlearynet
Kevinlearynet / meta-setup.php
Created March 16, 2012 18:59
Migrating existing custom field values into a meta box created with the WordPress WP Alchemy Meta Box Class
<?php
include_once( plugin_dir_path( __FILE__ ) . 'classes/MetaBox.php' );
include_once( plugin_dir_path( __FILE__ ) . 'classes/MediaAccess.php' );
$meta_boxname = new WPAlchemy_MetaBox( array(
'id' => '_boxname_meta',
'title' => 'Metabox Name',
'template' => plugin_dir_path( __FILE__ ) . 'meta-template.php',
'mode' => WPALCHEMY_MODE_EXTRACT,
) );
@Kevinlearynet
Kevinlearynet / Responsive WordPress oEmbeds
Created April 12, 2012 22:40
This plugin adjusts the WordPress automatic media embeds, allowing for responsive width and height scaling when the device or browser resolution changes.
<?php
/**
* Responsive Embeds in WordPress
*
* Custom embed sizing for basic listing template
*/
class ResponsiveVideoEmbeds
{
/**
* Setup the object
@Kevinlearynet
Kevinlearynet / widget-helper.php
Created September 13, 2012 13:13
These functions can be added to Matt Varone's widget helper class (https://github.com/sksmatt/WordPress-Widgets-Helper-Class) to add a Media Upload field to a WordPress widget
/**
* Load Media Upload Scripts
*
* Load the JS & CSS needed for the media upload field
*/
function enqueue_scripts() {
// Only load on widgets screen
$screen = get_current_screen();
if ( $screen->id != 'widgets' )
@Kevinlearynet
Kevinlearynet / Popular Posts This Month
Created October 8, 2012 13:52
Popular Posts Tracking
@Kevinlearynet
Kevinlearynet / template-curated-archive.php
Created October 10, 2012 12:55
Curated Content Query
<?php
/**
* Template Name: Around The Web
*
* The template for displaying a curated resources Archive.
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package _s
* @since _s 1.0
@Kevinlearynet
Kevinlearynet / google-cdn-jquery-wordpress
Created October 10, 2012 14:50
Google CDN Hosted jQuery in WordPress
/**
* Google hosted jQuery
*/
function google_hosted_jquery( $src, $handle ) {
// Only run for jQuery
if ( $handle == "jquery" ) {
$parse_url = parse_url( $src );
$version = str_replace( 'ver=', '', $parse_url['query'] );
return "//ajax.googleapis.com/ajax/libs/jquery/$version/jquery.min.js";
@Kevinlearynet
Kevinlearynet / Example usage
Created October 12, 2012 17:27
Automatically match the height of your primary and secondary content columns by hiding asides or callouts if they over extend the main content region.
(function($){
$(window).load( function() {
// Equalize columns
$('.wrapper').equalizeColumns({
'primary_identifier' : '.primary-content',
'secondary_identifier' : '.secondary-content',
'callout_identifier' : 'aside',
'margin_offset' : 40
@Kevinlearynet
Kevinlearynet / Custom Taxonomy Term Description
Created November 30, 2012 18:20
Display a custom taxonomy term's description within an archive theme template
// Show an optional taxonomy term description
if ( is_tax() ) {
$term_description = term_description();
if ( ! empty( $term_description ) )
echo apply_filters( 'taxonomy_archive_meta', '<div class="taxonomy-description">' . $term_description . '</div>' );
}
@Kevinlearynet
Kevinlearynet / post_types_author_archives()
Created December 5, 2012 15:45
Add custom post types to author archives in WordPress
/**
* Add Custom Post Types to Author Archives
*/
function post_types_author_archives($query) {
// Add 'videos' post type to author archives
if ( $query->is_author )
$query->set( 'post_type', array('videos', 'post') );
// Remove the action after it's run
/**
* Woo: Custom Download View
*
* Enable custom download box from plugin, if plugin is de-activated
* fallback to woocommerce default.
*/
function rapid_mydownloads( $template, $slug, $name ) {
if ( $template == 'myaccount/my-downloads.php' && function_exists( 'rapid_show_custom_download_box' ) ) {
global $woocommerce;
rapid_show_custom_download_box();