Skip to content

Instantly share code, notes, and snippets.

View tankbar's full-sized avatar

Tankbar tankbar

View GitHub Profile
@tankbar
tankbar / _media-queries.scss
Last active June 23, 2016 09:50
Media Queries helper in your SCSS project
// These mixins make media queries a breeze with SCSS.
// The media queries from mobile up until desktop all trigger at different points along the way.
// This helper is focused on mobile first. You style your block as it whould appear in mobile and then add CSS for how it scales up.
//
// Example
// .block {
// height: 250px;
//
// @include MQ(M) {
// height: 300px;
@tankbar
tankbar / wc-replace-breadcrumbs-with-yost
Created June 27, 2016 11:44
Remove default WooCommerce breadcrumbs and add Yoast ones instead
// Remove default WooCommerce breadcrumbs and add Yoast ones instead
remove_action( 'woocommerce_before_main_content','woocommerce_breadcrumb', 20, 0);
add_action( 'woocommerce_before_main_content','my_yoast_breadcrumb', 20, 0);
if (!function_exists('my_yoast_breadcrumb') ) {
function my_yoast_breadcrumb() {
yoast_breadcrumb('<p id="breadcrumbs">','</p>');
}
}
@tankbar
tankbar / wc-strip-unwanted-product-categories-loop-output
Last active June 27, 2016 12:43
Strip unwanted product categories in categories loop on single product page and/or woocommerce loop
//Strip unwanted product categories in categories loop on single product page and/or woocommerce loop
//Add this manually to your wanted hook or filter
function list_clean_categories() {
global $post;
$terms = get_the_terms( $post->ID, 'product_cat' );
$unwanted_cat_slugs = array();
//Example: $unwanted_cat_slugs[] = "campaign-summer";
$unwanted_cat_slugs[] = "xxx";
$unwanted_cat_slugs[] = "yyy-yyy";
@tankbar
tankbar / wc-facebook-tracking-pixel-thank-you-page
Created June 27, 2016 14:23
Facebook tracking pixel on Thank you page
// Facebook tracking pixel on Thank you page
function fb_pixeltracking( $order_id ) {
$order = new WC_Order( $order_id );
$order_total = $order->get_total();
?>
<!-- Facebook Conversion Code -->
<script>(function() {
var _fbq = window._fbq || (window._fbq = []);
if (!_fbq.loaded) {
@tankbar
tankbar / _typography.scss
Last active August 23, 2016 08:37
CSS default font-smoothing for typography.scss
// These text rendering optimization settings are default on all our sites from 2016.
body {
-moz-font-smoothing: antialiased;
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
/* Recommended default font-size and line-height */
line-height: 1.5;
font-size: 16px;
@tankbar
tankbar / gravity-forms-ajax-spinner
Last active September 14, 2016 12:25
Change the Default Gravity Forms AJAX Spinner - If you want to change the default Gravity Forms AJAX spinner, Gravity Forms provides us with a filter to do so: gform_ajax_spinner_url. Paste the following code into your installed and activated custom snippets plugin.
add_filter( 'gform_ajax_spinner_url', 'cwwp_custom_gforms_spinner' );
/**
* Changes the default Gravity Forms AJAX spinner.
*
* @since 1.0.0
*
* @param string $src The default spinner URL
* @return string $src The new spinner URL
*/
function cwwp_custom_gforms_spinner( $src ) {
@tankbar
tankbar / _box-shadow.scss
Last active December 13, 2016 07:22
A nice shadow transition for boxes/blocks in a grid
//Use <div class="box box-shadow"> for a nice hover effect.
//@requires our _media-queries.scss
//Available classes <div class="box box-rounded box-border box-rounded box-shadow">
.box {
background-color: #fff;
overflow: hidden;
&.box-no-padding {
padding: 0;
@tankbar
tankbar / functions.php
Created January 2, 2017 09:48
WordPress body class browser and OS detection
/**
* Browser and OS detection
* @link http://www.wpbeginner.com/wp-themes/how-to-add-user-browser-and-os-classes-in-wordpress-body-class/
*/
function dxms_browser_os_body_class( $classes ) {
global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;
if( $is_lynx ) $classes[] = 'lynx';
elseif( $is_gecko ) $classes[] = 'gecko';
@tankbar
tankbar / functions.php
Created January 24, 2017 07:51 — forked from gregrickaby/functions.php
Filter a custom post type after it's been registered
<?php
/**
* Filter the Products CPT to register more options.
*
* @param $args array The original CPT args.
* @param $post_type string The CPT slug.
*
* @return array
*/
@tankbar
tankbar / remove-emoji-support.php
Created January 24, 2017 07:52 — forked from gregrickaby/remove-emoji-support.php
Remove WordPress Emoji Support
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below into functions.php
/**
* Remove emoji support.
*/
function grd_remove_emoji() {
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );