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
@dustinleer
dustinleer / slider.js
Last active January 18, 2022 16:04
Find the Height of Vertical Slider and animate with button click
jQuery(window).on('load resize scroll', function(){
jQuery('.home-hero').next().attr('id', 'after-hero'); //adds and anchor id to the sibling element to the home-hero
var numItems = jQuery('.home-hero__item').length, //finds all the items
numItems = numItems - 1, //subtracts one item as the first slide is not a true slide
outerHeightSlide = jQuery('.slide-0').outerHeight(), //finds the height of the first slide item
outerHeightSlides = jQuery('.slide-1').outerHeight(), //finds the height of all the slides in the slider
scroll = jQuery(window).scrollTop(), //find scroll position
allSlidesHeight = outerHeightSlides * numItems + outerHeightSlide - scroll; //does the math to get how far to scroll to the main content
/**
@dustinleer
dustinleer / sass.md
Last active January 14, 2022 23:03
Plain Sass Example
@dustinleer
dustinleer / NodeSass.md
Last active November 15, 2021 14:40
Node Sass and NPM Build Issues

To Rebuild Node Sass, these commands are helpful.

npm uninstall node-sass
npm i node-sass
npm rebuild node-sass
@dustinleer
dustinleer / node-nodes.md
Created November 8, 2021 15:03
Gulp Issues

Ref Link


Gulp 3.* doesn't work on Node 12.* or above. You have to downgrade Node, or upgrade Gulp.

If you are short on time, downgrade Node to v11.* or below; if you need newer features, and have time to possibly fix a load of broken dependencies, upgrade Gulp to 4.* or above!

As others have already mentioned, Gulp 3.* is not supported on Node 12 or above, so you will have to downgrade your Node version to 11.* or below, OR upgrade your Gulp to 4.0.

@dustinleer
dustinleer / acf-wp-image.php
Last active April 28, 2022 14:23
Uses default wp_get_attchment for image with ACF
<?php
$image = get_field('acf_field_name', 'options');
if( !empty( $image ) ) {
$image_id = $image['ID'];
$alt = $image['alt'];
$alt = $image['alt'] ? $image['alt'] : $image['title'];
$size = 'medium'; // (thumbnail, medium, large, full or custom size)
@dustinleer
dustinleer / full-width.css
Created September 28, 2021 19:00
Full width outer container inside a fixed container
.full-width {
width: 100vw;
position: relative;
left: 50%;
right: 50%;
margin-left: -50vw;
margin-right: -50vw;
}
@dustinleer
dustinleer / browser-dectection.js
Created September 21, 2021 15:28
Adds body class based on browser detection
function GetIEVersion() {
var sAgent = window.navigator.userAgent;
var Idx = sAgent.indexOf("MSIE");
// If IE, return version number.
if (Idx > 0) {
return parseInt(sAgent.substring(Idx+ 5, sAgent.indexOf(".", Idx)));
// If IE 11 then look for Updated user agent string.
@dustinleer
dustinleer / admin-styles.php
Last active September 21, 2021 09:58
Override Admin Styles
// customize admin bar css
function override_admin_bar_css() {
if ( is_admin_bar_showing() ) {
/* Could add a custom enqueue here instead of a style tag */
/* Example 👇 */
$version = time();
wp_enqueue_style( 'ip_master-style', get_stylesheet_directory_uri() . '/dist/css/style.css', array(), $version );
?>
<style type="text/css">
/* Add Styles Here */
@dustinleer
dustinleer / disable-guteberg-widgets.php
Created September 17, 2021 13:59
Disables Gutenberg for the Widget Area in WordPress
// Disables the block editor from managing widgets in the Gutenberg plugin.
add_filter( 'gutenberg_use_widgets_block_editor', '__return_false', 100 );
// Disables the block editor from managing widgets.
add_filter( 'use_widgets_block_editor', '__return_false' );
if ( ! function_exists( 'themename_activate_classic_widgets' ) ) :
function themename_activate_classic_widgets() {
remove_theme_support( 'widgets-block-editor' );
}
@dustinleer
dustinleer / functions.php
Created July 20, 2021 18:11 — forked from srikat/functions.php
How to set up smooth scrolling for hash links in WordPress. https://sridharkatakam.com/set-smooth-scrolling-hash-links/
// Enqueue site-wide scripts
add_action( 'wp_enqueue_scripts', 'sk_enqueue_scripts' );
function sk_enqueue_scripts() {
wp_enqueue_script( 'global', get_stylesheet_directory_uri() . '/js/global.js', array( 'jquery' ), '', true );
}