Skip to content

Instantly share code, notes, and snippets.

View colorful-tones's full-sized avatar
💓
Don’t believe the hype!

Damon Cook colorful-tones

💓
Don’t believe the hype!
View GitHub Profile
@colorful-tones
colorful-tones / 301 & www .htaccess
Created June 11, 2013 14:56
301 & www .htaccess
RewriteEngine On
RewriteBase /
#RewriteCond %{HTTP_HOST} !^www.harmony-group.com [NC]
#RewriteRule ^(.*)$ http://www.harmony-group.com/$1 [L,R=301]
RewriteRule ^about.html /about-us/ [L,R=301]
RewriteRule ^residential.html /luxury-apartments/ [L,R=301]
RewriteRule ^commercial.html /luxury-office-space/ [L,R=301]
RewriteRule ^storage.html /self-storage-facilities/ [L,R=301]
@colorful-tones
colorful-tones / jQuery CDN w fallback
Created June 11, 2013 14:59
Grab jQuery library from Google's CDN if failed then pull local version
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.6.2.min.js"><\/script>')</script>
@colorful-tones
colorful-tones / Post Type conditional
Created June 11, 2013 15:01
Check if Post Type inside or outside of loop
<?php
/*
This allows us to be able to use conditional
to check whether is_post_type = "your custom post type here"
And can be used inside OR outside the loop
*/
function is_post_type($type){
global $wp_query;
if($type == get_post_type($wp_query->post->ID)) return true;
return false;
@colorful-tones
colorful-tones / mobile-detect.min.js
Last active May 20, 2016 00:42
Javascript user agent sniffing (don't recommend trying it, but)... #mobile
/*
* JS Redirection Mobile
*
* Developed by
* Sebastiano Armeli-Battana (@sebarmeli) - http://www.sebastianoarmelibattana.com
* Dual licensed under the MIT or GPL Version 3 licenses.
* @version 0.9.5
*/
if(!window.SA){window.SA={};}SA.redirection_mobile=function(m){var c=function(y){var x=new Date();x.setTime(x.getTime()+y);return x;};var q=function(C){if(!C){return;}var x=document.location.search,D=x&&x.substring(1).split("&"),z=0,B=D.length;for(;z<B;z++){var y=D[z],A=y&&y.substring(0,y.indexOf("="));if(A===C){return y.substring(y.indexOf("=")+1,y.length);}}};var a=navigator.userAgent.toLowerCase(),s="false",f="true",w=m||{},r=w.noredirection_param||"noredirection",t=w.mobile_prefix||"m",o=w.mobile_url,d=w.mobile_scheme?w.mobile_scheme+":":document.location.protocol,p=document.location.host,i=q(r),j=o||(t+"."+(!!p.match(/^www\./i)?p.substring(4):p)),k=w.cookie_hours||1,g=w.keep_path||false,v=w.keep_query||false,h=w.tablet_url||j,b=!!(a.match(/(iPhone|iPod|blackberry|android 0.5|htc|lg|midp|mmp|mobile|nokia|o
@colorful-tones
colorful-tones / custom-post-type-query
Created June 19, 2013 20:48
Custom Post Type query
<!-- Custom Post Type Loop -->
<?php $query = new WP_Query(array(
'post_type' => 'testimonials',
'posts_per_page' => -1,
'orderby' => 'rand'
));
while ( $query->have_posts() ) : $query->the_post();
echo '<div class="custompost">';
the_content();
@colorful-tones
colorful-tones / DRY-SASS.scss
Last active August 29, 2015 14:04
How do I make this into nice SASS mixin? with @extend?
/* COLORS FOR CAR Types */
$mini-van-base: #344556; //blue
$sedan-base: #b43d3d; //red
$suv-base: #7a4c8e; //purple
$truck-base: #d0922f; //yellow
$convertible-base: #ff5831; //orange
@each $car_type, $color in
( mini-van, $mini-van-base ),
( sedan, $sedan-base ),
@colorful-tones
colorful-tones / .htaccess
Last active October 16, 2015 14:59 — forked from gregrickaby/example-nginx.conf
redirect /uploads/ folder for dev
# Apache .htaccess
RedirectMatch 301 ^/wp-content/uploads/(.*) http://livewebsite.com/wp-content/uploads/$1
# Nginx
location ~ ^/wp-content/uploads/(.*) {
rewrite ^/wp-content/uploads/(.*)$ http://livewebsite.com/wp-content/uploads/$1 redirect;
}
@colorful-tones
colorful-tones / element-in-viewport.js
Last active September 4, 2016 13:23
Simple wayfinder js to see if element is in viewport, and add classes or remove based on if it is.
// check if element is in viewport
// if so, then add/remove class
// http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport/7557433#7557433
(function($) {
// function to check if element is in viewport
function inViewport(element) {
if (typeof jQuery === "function" && element instanceof jQuery) {
element = element[0];
@colorful-tones
colorful-tones / gravity-forms.php
Last active August 29, 2015 14:18
Gravity Forms overrides I typically need to use. I like to put this in _s /inc/, and don't forget to put this in your functions.php: ```require get_template_directory() . '/inc/gravity-forms.php';```
<?php
/**
* Maintainn Gravity Forms Hooks & Filter overrides
*
*/
/*
* Filter the Gravity Forms button type and add your own .class
*/
function your_prefix_form_submit_button( $button, $form ) {
// Usage:
// get_id_by_slug( 'any-page-slug' );
function get_id_by_slug( $page_slug ) {
$page = get_page_by_path( $page_slug );
if ( $page ) {
return $page->ID;
} else {
return null;