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 / 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;
@dustinleer
dustinleer / script-file.js
Last active September 17, 2021 14:12
Moving Nav Items
var
// NAV
navbutton = $('.menu-toggle'),
navWrap = $('.main-nav-wrapper'),
navmenu = $('.main-nav'),
servicemenu = $('.service-menu'),
// WATCHER
watcher = window.matchMedia("(max-width: 1179px)");
@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 );
}
@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 / 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 / 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 / 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 / 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 / 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 / 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