Skip to content

Instantly share code, notes, and snippets.

View iamcanadian1973's full-sized avatar

Kyle Rumble iamcanadian1973

View GitHub Profile
@iamcanadian1973
iamcanadian1973 / header-widget.php
Created January 22, 2014 18:52
Genesis Move header widget
remove_action('genesis_header', 'genesis_do_header');
add_action('genesis_header', 'kr_do_header');
function kr_do_header()
{
global $wp_registered_sidebars;
if ((isset($wp_registered_sidebars['header-right']) && is_active_sidebar('header-right')) || has_action('genesis_header_right')) {
genesis_markup(array(
'html5' => '<aside %s>',
'xhtml' => '<div class="widget-area header-widget-area">',
@iamcanadian1973
iamcanadian1973 / gist:8854187
Created February 6, 2014 22:56
Genesis HTML conditional tags
/**
* HTML5 DOCTYPE
* removes the default Genesis doctype, adds new html5 doctype with IE8 detection
*/
function mb_html5_doctype() {
?>
<!DOCTYPE html>
<!--[if IE 8]> <html class="lt-ie9" <?php language_attributes( 'html' ); ?>> <![endif]-->
<!--[if gt IE 8]><!--> <html <?php language_attributes( 'html' ); ?>> <!--<![endif]-->
@iamcanadian1973
iamcanadian1973 / get-image-attachment.php
Last active August 29, 2015 14:02
Get image attachment (title, alt, caption, url, width, height)
/**
* Get image attachment (title, alt, caption, url, width, height)
*
*/
// get attachment ID if featured image
$attachment_id = get_post_thumbnail_id( $post->ID );
// best function ever - http://codex.wordpress.org/Function_Reference/wp_prepare_attachment_for_js
@iamcanadian1973
iamcanadian1973 / post-meta.php
Created June 27, 2014 22:52
Retrieve all post meta for a given $key by $post_type. This function is useful if you need to do any front-end sorting of posts by meta key/values and need to populate a select
/**
* Retreive all post meta for a given $key by $post_type
*
* This function is useful if you need to do any frontend sorting of posts by meta key/values and need to populate a select
*
* @param string
* @param string
* @param string
* @param bool
* @return array
@iamcanadian1973
iamcanadian1973 / helpers_html.php
Created June 27, 2014 23:03
Generate a safe HTML anchor
/**
* Generates a safe email HTML anchor
*
*
* @access public
* @param string
* @return string
*/
function safe_email($email = '' ){
@iamcanadian1973
iamcanadian1973 / widgets.php
Created June 30, 2014 18:03
Flexible Posts Widget - add template name as class to widget. Because you can have multiple templates, its nice to be able to style them individually.
add_filter( 'widget_display_callback', 'kr_widget_display_callback', 10, 3 );
function kr_widget_display_callback($instance, $widget, $args) {
if ( strpos( $args['widget_id'], 'dpe_fp_widget' ) === FALSE && !isset($instance['template'])) {
return $instance;
}
$widget_classname = $widget->widget_options['classname'];
$my_classnames = basename( $instance['template'], '.php' );
@iamcanadian1973
iamcanadian1973 / menus.php
Created July 5, 2014 02:31
Enable menu description
add_filter( 'walker_nav_menu_start_el', 'child_enable_menu_description', 10, 2 );
function child_enable_menu_description( $item_output, $item ) {
if ( ' ' !== $item->post_content )
return preg_replace( '/(<a.*?>[^<]*?)</', '$1' . '<span>' . $item->post_content . '</span><', $item_output );
return $item_output;
}
class Menu_With_Description extends Walker_Nav_Menu {
@iamcanadian1973
iamcanadian1973 / widgets.php
Created July 11, 2014 00:46
Skeleton widget
// Creating the widget
class KR_WIDGET extends WP_Widget {
const WIDGET_DOMAIN = 'fusemail';
const WIDGET_ID = 'kr_widget';
const WIDGET_NAME = 'KR Widget';
const WIDGET_DESCRIPTION = 'KR Widget Description.';
const WIDGET_TITLE = '';
function __construct() {
@iamcanadian1973
iamcanadian1973 / genesis-column-clases.scss
Created July 14, 2014 01:17
Genesis Column Classes (SASS)
// @mixin create column widths
@function col_width( $n, $total_columns, $total_width: 1140px, $gutter_width: 48px )
{
$col_width: ($total_width - ($gutter_width * ($total_columns - 1))) / $total_columns;
$total_width: $total_width;
$columns_width: ($n * $col_width) + (($n - 1) * $gutter_width);
@return percentage($columns_width/$total_width);
}
//
@iamcanadian1973
iamcanadian1973 / change-youtube-url-attributes.js
Last active January 9, 2016 00:45
Remove Youtube video toolbar and branding
$('iframe[src*="youtube.com"]').each(function() {
var url = $(this).attr("src");
var char = "?";
if(url.indexOf("?") != -1)
char = "&";
$(this).attr("src",url+char+"modestbranding=1&wmode=transparent&showinfo=0&rel=0&autohide=1");
});