Skip to content

Instantly share code, notes, and snippets.

View christophercochran's full-sized avatar

Christopher Cochran christophercochran

View GitHub Profile
@christophercochran
christophercochran / is-it-snowing
Created December 9, 2014 05:27
Jetpack Holiday Snow only when it is really snowing. Snow outside your window, snow on your blog.
function cc_is_it_snowing() {
// Zip Code / City Name
$location = 'North Pole';
$weather_data_api_url = 'http://api.openweathermap.org/data/2.5/weather?q=' . $location;
$weather_data_response = wp_remote_get( $weather_data_api_url );
if ( is_wp_error( $weather_data_response ) ) {
// Errors are no joy. No joy, no snow.
@christophercochran
christophercochran / gist:5774513
Created June 13, 2013 15:14
Detect parent nav items and adds a class of "parent-menu-item" using Walker_Nav_Menu.
<?php
/**
* Updates the walker arg with custom class for detecting parent nav elements.
*/
function cc_add_menu_walker_arg( $args ) {
$args['walker'] = new CC_Detect_Parents();
return $args;
}
@christophercochran
christophercochran / gist:5759587
Created June 11, 2013 18:50
Menu parent indicator CSS only. IE9 +
li > a::after {
content: '+';
padding-left: 20px;
padding-left: 2rem;
}
li > a:only-child::after {
content: '';
padding-left: 0;
padding-left: 0;
@christophercochran
christophercochran / fluid-oembed.css
Created July 24, 2012 14:08
Wrap oembeds with containing div and according styles for fluid videos in responsive design
/* OEMBED
-------------------- */
.oembed-container {
position: relative;
height: 0;
margin-top: 1em;
padding-bottom: 56.25%;
overflow: hidden;
}
.oembed-container iframe,
@christophercochran
christophercochran / Genesis Layout Logic
Created June 28, 2012 05:17
Conditionally force content sidebar layout for single posts. (For the Genesis Framework)
/**
* Conditionally force content-sidebar layout for single posts.
*/
function cc_layout_logic() {
/**
* Genesis layout helper functions.
* __genesis_return_content_sidebar
* __genesis_return_sidebar_content
* __genesis_return_content_sidebar_sidebar
* __genesis_return_sidebar_sidebar_content
@christophercochran
christophercochran / Add WordPress Menu Item Description
Created May 31, 2012 16:20
Adds Menu Description to Wordpress Menu with the walker_nav_menu_start_el filter.
add_filter( 'walker_nav_menu_start_el', 'gt_add_menu_item_description', 10, 4);
function gt_add_menu_item_description( $item_output, $item, $depth, $args ) {
$desc = __( $item->post_content );
return preg_replace('/(<a.*?>[^<]*?)</', '$1' . "<small class=\"nav-desc\">{$desc}</small><", $item_output);
}