Skip to content

Instantly share code, notes, and snippets.

View dustinleer's full-sized avatar
🏠
Working from home

Dustin Leer dustinleer

🏠
Working from home
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dustinleer
dustinleer / functions.js
Created December 4, 2018 17:57
SVG Magic Function
jQuery(document).ready(function(){
jQuery('img').svgmagic();
});
@dustinleer
dustinleer / header.php
Created June 7, 2019 17:19
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.
<?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 / sharethis.js
Last active December 11, 2019 20:26
Sharethis a11y Functionality jQuery
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({
<?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
@dustinleer
dustinleer / functions.php
Last active August 3, 2020 17:04
Enqueue Scripts
<?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' );
@dustinleer
dustinleer / functions.php
Last active August 3, 2020 17:05
Add function for SVG mime type
<?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 / synced-slick.js
Last active August 3, 2020 17:06
Synced Slick Slider
$('.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 / woocommerce.php
Created August 4, 2020 13:53
This will check if upsells are active on the page and if they are none will show the realted products
<?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;