Skip to content

Instantly share code, notes, and snippets.

View chriskoelle's full-sized avatar

Chris Koelle chriskoelle

View GitHub Profile
@chriskoelle
chriskoelle / functions.php
Last active December 28, 2015 18:59
Wordpress - Add this filter to your functions.php file to allow private and draft pages to be selected as parent pages.
function allow_private_parent_pages_nh( $dropdown_args, $post = 0 ) {
$dropdown_args['post_status'] = array('publish', 'draft', 'private');
return $dropdown_args;
}
add_filter('page_attributes_dropdown_pages_args', 'allow_private_parent_pages_nh', 10, 2);
add_filter('quick_edit_dropdown_pages_args', 'allow_private_parent_pages_nh', 10, 2);
@chriskoelle
chriskoelle / widget-fb-like.php
Created November 26, 2013 17:01
A Wordpress widget for a Facebook like box
<?php
class FB_Like_Widget extends WP_Widget {
private static $scripts_added;
public function __construct() {
parent::__construct(
'fb-like-box-widget', // ID
'Facebook Widget ', // Name
array(
@chriskoelle
chriskoelle / functions.php
Created December 2, 2013 00:09
This changes the Wordpress template hierarchy to use archive.php instead of home.php for the posts page if the front page settings are set to display a static page
/**
* Archive Template for Posts Page
*
* This changes the Wordpress template hierarchy to use archive.php for the posts page
*
* @author Chris Koelle
*
* @param string $template
* @return string
*/
@chriskoelle
chriskoelle / _custom-mixins.scss
Created December 2, 2013 20:20
SASS Custom Mixins
// Cross browser opacity
@mixin opacity ( $value: 0.5 ) {
opacity: $value;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=" $value * 100 ")";
filter: alpha(opacity= $value * 100 );
zoom: 1;
}
// Media Queries
@mixin mq($query) {
@chriskoelle
chriskoelle / custom_meta_box.php
Last active December 30, 2015 04:09
Custom Meta Box - Custom Meta Types - for use with Jared Atchison's Custom Metaboxes and Fields for WordPresshttps://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress
<?php
// Custom Post Type Dropdown
function cmb_post_type_dropdown($field, $meta) {
wp_dropdown_pages(array(
'show_option_none' => '-- Select One ---',
'name' => $field['id'],
'id' => $field['id'],
'post_type' => $field['post_type'],
'selected' => $meta
));
@chriskoelle
chriskoelle / functions.php
Created December 5, 2013 20:17
Wordpress Body Class Cleanup Removes some of the rerely used classes output by Wordpresses body_class function in order to cut down on markup
function cleanup_post_class( $classes, $class, $post_id ) {
foreach($classes as $key => $class):
if(preg_match('/(^tag)|(^post)|(hentry)|(uncategorized)|(status)/', $class)) unset($classes[$key]);
endforeach;
$classes[] = 'post-'.$post_id;
return $classes;
}
add_filter('post_class', 'cleanup_post_class', 10 , 3);
@chriskoelle
chriskoelle / functions.php
Created December 5, 2013 20:57
Wordpress Change Embed Shortcode Defaults
function new_embed_sizes() {
return array( 'width' => 640, 'height' => 9999);
}
add_filter('embed_defaults', 'new_embed_sizes');
@chriskoelle
chriskoelle / shuffle.js
Created December 27, 2013 22:46
Javascript Array Shuffle
Array.prototype.shuffle = function() {
var i = this.length, j, temp;
if ( i === 0 ) return this;
while ( --i ) {
j = Math.floor( Math.random() * ( i + 1 ) );
temp = this[i];
this[i] = this[j];
this[j] = temp;
}
return this;
@chriskoelle
chriskoelle / functions.php
Created January 8, 2014 03:30
Wordpress Cleanup wp_nav_menu Classes
// Cleanup some of the extra menu item classes added to wp_nav_menu
function nh_allowed_menu_item_classes($classes, $item) {
// Get custom classes added from within the menus admin page
$new_classes = (array) get_post_meta( $item->ID, '_menu_item_classes', true );
// Consolidate the assorted "current..." classes
$current_classes = preg_grep('/current/', $classes);
if(!empty($current_classes)) $new_classes[] = 'current';
@chriskoelle
chriskoelle / .htaccess
Created March 10, 2014 00:29
Disable compatibility mode in IE
Header set X-UA-Compatible "IE=edge"