Skip to content

Instantly share code, notes, and snippets.

View ebinnion's full-sized avatar

Eric Binnion ebinnion

View GitHub Profile
@ebinnion
ebinnion / slideshow.php
Last active August 29, 2015 14:01
Crane|WEST Slideshow CPT Snippet with Aqua Resizer
<?php
$slides = new WP_Query(
array(
'post_type' => 'slideshow',
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'asc',
)
);
@ebinnion
ebinnion / redirect_non_admin.php
Created May 23, 2014 20:40
Redirect non-admin user in WordPress
<?php
add_action( 'wp_login', 'redirect_non_admins', 10, 2 );
function redirect_non_admins( $user_id, $user ) {
$user = wp_get_current_user();
$admin_roles = array('administrator');
if( 0 == count( array_intersect( $admin_roles, $user->roles ) ) ) {
wp_redirect( home_url() );
exit;
}

Pure SASS-adaption of Lea Verou's contrast-ratio javascript. Can be useful when eg. generating colored buttons from a single supplied color as you can then check which out of a couple of text colors would give the best contrast.

This script currently lacks the support for alpha-transparency that Lea supports in her script though.

In addition to the color-contrast adaption there's also some math methods that were needed to be able to calculate the exponent of a number and especially so when the exponent is a decimal number. A 2.4 exponent is used to calculate the luminance of a color and calculating such a thing is not something that SASS supports out of the box and not something I found a good pure-SASS script for calculating and I much prefer pure-SASS over ruby extensions. The math methods might perhaps be unecessary though if you're running Compass or similar as they may provide compatible math methods themselves.

Normal usage: `color: pick_best_color(#f00

# View my Jekyll blog http://paulstamatiou.com and my jekyll migration post http://paulstamatiou.com/how-to-wordpress-to-jekyll/
#
#
# based on the import script by icebreaker, which is based on mojombo's
# https://github.com/mojombo/jekyll/blob/master/lib/jekyll/migrators/wordpress.rb
# https://gist.github.com/303570
# edited to rewrite image URLs to use my CloudFront URL
require 'rubygems'
require 'sequel'
@ebinnion
ebinnion / Javascript (using jQuery)
Created December 23, 2011 08:57
Jquery Modal Window
$(document).ready(function() {
//select all the a tag with name equal to modal
$('a[name=modal]').click(function(e) {
//Cancel the link behavior
e.preventDefault();
//Get the A tag
var id = $(this).attr('href');
@ebinnion
ebinnion / .m File
Created January 17, 2012 08:51
Set map region in iOS Mapkit
CLLocationCoordinate2D location;
location.latitude=yourlatitude;
location.longitude=yourlongitude;
span.latitudeDelta=0.01; //or whatever zoom level
span.longitudeDelta=0.01;
region.span=span;
region.center=location;
@ebinnion
ebinnion / hideMenu.js
Created January 24, 2012 05:12
Jquery Hide/Show Menu Responsive Web Design
$('#menu-button').click(function(){
$('.menu').slideToggle('fast',function() {});
});
function menuHide (){
if ($(window).width() < 1024){
$("body").addClass("mobile");
}
else {
$("body").removeClass("mobile");
@ebinnion
ebinnion / Recommended Shortcode
Created March 25, 2012 22:14
Thesis Shortcodes
@ebinnion
ebinnion / Rotating Header Image
Created April 1, 2012 00:52
Thesis Hooks Reference
// This code will add a rotating header image to Thesis
function header_rotator() {
echo thesis_image_rotator();
}
add_action('thesis_hook_feature_box','header_rotator');
@ebinnion
ebinnion / Body Code
Created April 6, 2012 05:16
Embed Google Map with Geocode
<div id="map" style="width: 413px; height: 300px;"></div>
<script type="text/javascript">
var mapOptions = {
zoom: 16,
center: new google.maps.LatLng(54.00, -3.00),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var geocoder = new google.maps.Geocoder();
var address = '3410 Taft Blvd Wichita Falls, TX 76308';
geocoder.geocode( { 'address': address}, function(results, status) {