Skip to content

Instantly share code, notes, and snippets.

@jwebcat
jwebcat / is-blog.php
Created January 24, 2014 08:16
Add is_blog() function to WP
function is_blog () {
global $post;
$posttype = get_post_type($post );
return ( ((is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_single()) || (is_tag())) && ( $posttype == 'post') ) ? true : false ;
}
@jwebcat
jwebcat / vertical-align.scss
Created January 24, 2014 08:14
vertical align
%vertical-align {
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
@jwebcat
jwebcat / triangle.scss
Last active June 15, 2017 11:56
scss triangle mixin
//==== Simple SCSS mixin to create CSS triangles
//==== Example: @include css-triangle("up", 10px, #fff);
@mixin css-triangle($direction: "down", $size: 20px, $color: #000) {
width: 0;
height: 0;
border-left: $size solid #{setTriangleColor($direction, "left", $color)};
border-right: $size solid #{setTriangleColor($direction, "right", $color)};
border-bottom: $size solid #{setTriangleColor($direction, "bottom", $color)};
border-top: $size solid #{setTriangleColor($direction, "top", $color)};
}
@jwebcat
jwebcat / override-woocommerce.php
Created September 9, 2013 21:48
Override Woo Commerce Add to cart and go straight to checkout page. Also, override fields comments field Checkout page.
add_filter ('add_to_cart_redirect', 'redirect_to_checkout');
function redirect_to_checkout() {
global $woocommerce;
$checkout_url = $woocommerce->cart->get_checkout_url();
return $checkout_url;
}
add_filter('single_add_to_cart_text', 'woo_custom_cart_button_text');
@jwebcat
jwebcat / on-sent-ok.js
Created September 7, 2013 10:50
for redirect on for submit success for Contact 7
on_sent_ok: "location = 'http://itunes.com/';"
@jwebcat
jwebcat / gist:6338370
Created August 26, 2013 05:39
change css based on url hash
if (window.location.hash.split('-')[0] == '#item') {
$('ul.side').addClass('hashed');
}
// the below is questionable
$(function () {
if (window.location.hash) {
getHash();
}
@jwebcat
jwebcat / hack.sh
Last active July 16, 2019 18:09
run a windows batch script with args from git bash
#!/bin/bash
$COMSPEC /c batch-file\ \"$var1\"\ \"$var2\"
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your
#!/bin/sh
GIT_WORK_TREE=/home/myuser/public_html/wp-content/themes/mytheme git checkout -f

What if controlling your media queries was as easy as adding on to a Sass list? What if I told you it now is?

This snippet comes from a modified version of mixins in the Aura Responsive Framework and came from me hijacking the respond-to mixin namespace but still wanting to use it for custom media queries. It's a little ugly and requires Sass 3.2+ (for now, (sudo) gem install sass --pre), but it works a charm.

There are two fairly mundane caveats to this method. First, every media query needs to be named. Second, every media query needs a size and assumes min-width and screen. If you want to change min-width, simply add your operator as another option, but if you want to change screen, you need to also include your operator even if you want it to be min-width.

Also, I haven't built in warnings yet for when you do bad things, so bear that in mind.

Without further adue, tada.