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 / sass.md
Last active January 14, 2022 23:03
Plain Sass Example
@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 / plugin.php
Created February 3, 2022 20:39
Start a WP plugin
<?php
/**
* Plugin Name:
* Plugin URI :
* Description:
* Version: 1.0.0
* Author: Inverse Paradox
* Author URI: https://inverseparadox.com
* Text Domain:
* Domain Path: /languages
@dustinleer
dustinleer / important_filter.php
Created February 28, 2022 14:09
Removes the !important
<?php
/**
* Lowering specificity of WordPress global styles.
*/
add_action( 'init', function() {
// WP5.9+ only.
if ( ! function_exists( 'wp_get_global_stylesheet' ) ) {
return;
}
@dustinleer
dustinleer / columns.css
Created March 25, 2022 13:34
Columns css equality
ul.columns {
column-count: 2;
column-gap: 20px;
}
ul.columns li {
font-size: 16px;
line-height: 2;
/* This will keep the li from breaking on to new lines */
-webkit-column-break-inside: avoid;
@dustinleer
dustinleer / woocommerce.php
Created May 25, 2022 15:48
Removes my account menu items
<?php
function remove_my_account_menu_items( $items ) {
unset( $items['edit-address'] );
unset( $items['orders'] );
unset( $items['downloads'] );
return $items;
}
add_filter( 'woocommerce_account_menu_items', 'remove_my_account_menu_items' );
@dustinleer
dustinleer / woocommerce.php
Last active May 25, 2022 20:54
Changes the WooCommerce breakpoint
<?php
function woo_custom_breakpoint( $px ) {
$px = '782px';
return $px;
}
add_filter( 'woocommerce_style_smallscreen_breakpoint', 'woo_custom_breakpoint' );
@dustinleer
dustinleer / woocommerce.php
Created May 25, 2022 20:53
Reorders WooCommerce menu links
<?php
/**
* Reorder my-account menu
*
* @param array $menu_links Array containing menu items
* @return array Filtered links
*/
function ip_reorder_my_account_menu( $menu_links ){
$logout_link = $menu_links['customer-logout'];
@dustinleer
dustinleer / woocommerce.php
Created May 25, 2022 21:03
Add a custom WooCommerce My Account endpoint
<?php
/**
* Add endpoint rewrite.
*/
function ip_custom_endpoint() {
add_rewrite_endpoint( 'edit-wishlists', EP_ROOT | EP_PAGES );
}
add_action( 'init', 'ip_custom_endpoint', 10, 1 );
/**
@dustinleer
dustinleer / user-class-functions.php
Last active June 10, 2022 18:19
Add User Role Class to Body
<?php
/**
* Add User Role Class to Body
*/
function print_user_classes() {
if ( is_user_logged_in() ) {
add_filter( 'body_class','class_to_body' );
add_filter( 'admin_body_class', 'class_to_body_admin' );
}
}