Skip to content

Instantly share code, notes, and snippets.

# 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
@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\"
@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 / 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 / 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 / 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 / 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 / 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 / cpt-to-main-loop.php
Created January 24, 2014 08:18
Add custom post types to pre_get_posts for main loop WP
add_filter( 'pre_get_posts', 'my_get_posts' );
function my_get_posts( $query ) {
if ( is_category() && $query->is_main_query() )
$query->set( 'post_type', array( 'post', 'page', 'fonts' ) );
return $query;
}
@jwebcat
jwebcat / cpt-tags-cats-boxes.php
Created January 24, 2014 08:19
Add category and tag boxes to custom post type admin edit screen WP
add_action('init', 'demo_add_default_boxes');
function demo_add_default_boxes() {
register_taxonomy_for_object_type('category', 'fonts');
register_taxonomy_for_object_type('post_tag', 'fonts');
}