Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Dustin Leer dustinleer

🏠
Working from home
View GitHub Profile
@dustinleer
dustinleer / woocommerce.php
Created Aug 4, 2020
This will check if upsells are active on the page and if they are none will show the realted products
View woocommerce.php
<?php
// REMOVE RELATED IF UPSELLS
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
add_action( 'woocommerce_after_single_product_summary', 'related_upsell_products', 15 );
function related_upsell_products() {
global $product;
View wp-enqueue.php
<?php
/* == Queue up all css & js files ==================================================== */
function theme_scripts_styles() {
// JS
/** Removes WP stock jQuery
* https://developer.wordpress.org/reference/functions/wp_deregister_script/
*/
wp_deregister_script( 'jquery' );
/** Adds jQuery from a CDN, loads in the footer
View cookie-setup.js
@dustinleer
dustinleer / synced-slick.js
Last active Aug 3, 2020
Synced Slick Slider
View synced-slick.js
$('.slick-nav.sync').slick({
slidesToShow: 7,
slidesToScroll: 1,
asNavFor: '.slick-slider.sync',
dots: false,
arrows: false,
fade: false,
centerMode: false,
// centerPadding: '50px',
focusOnSelect: true,
@dustinleer
dustinleer / header.php
Created Jun 7, 2019
Do you need to move nav items in a complicated navigation? Here's what I did for a solution on a WordPress site that had 3 separate navs that needed to become one at a certain breakpoint for mobile and then resume their normal states when not at that breakpoint for desktop.
View header.php
<?php
// Site specific vars
$lang_att = get_language_attributes();
$charset = get_bloginfo( 'charset' );
$pingback = get_bloginfo('pingback_url');;
$site_url = get_bloginfo( 'wpurl' );
$site_name = get_bloginfo( 'name' );
// Get Body Classes then turn them into string values
@dustinleer
dustinleer / overcast-fm-dark.css
Created Jun 5, 2019
Overcast FM Web Darkmode
View overcast-fm-dark.css
html, input, select, textarea, .pure-g [class *= "pure-u"] {
font-family: concourse_t3, Helvetica, sans-serif;
}
body {
background: #1c1a1a;
color: rgb(0, 128, 128);
font-size: 18px;
max-width: 700px;
margin: 0 auto;
@dustinleer
dustinleer / sharethis.js
Last active Dec 11, 2019
Sharethis a11y Functionality jQuery
View sharethis.js
jQuery(document).ready(function($) {
setTimeout(function(){
//--------------------------
// SHARETHIS a11y
//--------------------------
// Loop through an array of data-network names
['facebook', 'twitter', 'pinterest'].forEach(function( platform ) {
// Adds a11y to sharing icons
$('.st-btn[data-network="' + platform + '"').attr({
@dustinleer
dustinleer / functions.php
Last active Aug 3, 2020
Add function for SVG mime type
View functions.php
<?php
/*add SVG functionality*/
function cc_mime_types($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');
@dustinleer
dustinleer / functions.js
Created Dec 4, 2018
SVG Magic Function
View functions.js
jQuery(document).ready(function(){
jQuery('img').svgmagic();
});
@dustinleer
dustinleer / functions.php
Last active Aug 3, 2020
Enqueue Scripts
View functions.php
<?php
/**
* Enqueue scripts and styles.
*/
function custom_scripts() {
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'svg_magic', get_stylesheet_directory_uri() . '/js/jquery.svgmagic.js', array(), '20120206', true );
wp_enqueue_script( 'functions', get_stylesheet_directory_uri() . '/js/functions.js', array(), '20130115', true );
}
add_action( 'wp_enqueue_scripts', 'custom_scripts' );