Skip to content

Instantly share code, notes, and snippets.

View rhaglennydd's full-sized avatar

Will Beaumont rhaglennydd

View GitHub Profile
@rhaglennydd
rhaglennydd / README.md
Last active June 9, 2023 19:00
WSL script for mounting drives

Use this script to mount drives in WSL. Example: ezmount.sh f to mount the F: drive.

Thanks to https://askubuntu.com/a/1422805/778411 for specifying how to make the WSL user the default owner of files.

@rhaglennydd
rhaglennydd / README.md
Last active July 10, 2020 16:44
A (mostly) working WooCommerce solution to ensure certain attribute pulldown option combinations are impossible

A client wants it so that it's not possible for customers to select product attribute pulldown combinations that refer to either non-existent or out of stock variations (they don't like customers making a selection from four pulldowns only to be told it's invalid). I took a stab at coding a solution that mostly works.

From functions.php the class SingleProduct is instantiated and the setup method is called to kick things off. The JavaScript is in the productVariationFooterScript method. Every time the user selects an option from an attribute pulldown an AJAX request is made, which is handled by the method ajaxFilterProductAttributeOptions (it returns valid options for all the other pulldowns, which then get updated by JavaScript). Like I say it mostly works, the attribute pulldown options are filtered properly for the most part, the only hitch I've found is that if the user makes selections from the first three pulldowns sometimes they can hit a combination for which any of the options for the last

@rhaglennydd
rhaglennydd / README.md
Last active May 26, 2022 21:37
Custom jQuery Build for a Webpack Flow

Custom jQuery Build for a Webpack Flow

Why?

Sometimes you don't need all of jQuery's modules. Officially, you can use their Grunt script to build a slimmed-down jQuery, but what if Webpack is more your thing? Enter this guide.

The Steps

  1. From your project root, install jQuery as a dev dependency:
@rhaglennydd
rhaglennydd / dropdown.js
Last active July 12, 2019 17:40
Bootstrap 4 Multi-Level Dropdown
/*
* Adapted from: https://stackoverflow.com/questions/44467377/bootstrap-4-multilevel-dropdown-inside-navigation
*/
'use strict';
( function( $ ) {
$( '.dropdown-menu a.dropdown-toggle' ).on( 'click', function() {
var $subMenu,
$this = $( this ),
$ancestors = $this.parents( '.dropdown-menu' ),