Skip to content

Instantly share code, notes, and snippets.

View djcowan's full-sized avatar

djcowan djcowan

View GitHub Profile
@djcowan
djcowan / readyExec.js
Created May 24, 2016 12:28 — forked from miguel-perez/readyExec.js
How to add the ability to re-run $(document).ready() functions
/**
* Replace jQuery's $.fn.ready() function with a mod exec
*
* Sites that make heavy use of the $(document).ready function
* are generally incompatable with asynchrounous content. The
* the $.fn.ready function only runs once. This script replaces
* the ready function with a module execution controller that
* let's us register functions and execute all of the functions
* as we need them. This is useful after HTML gets injected on the
* page and we want to rebind functionally to the new content.
@djcowan
djcowan / functions.php
Created December 1, 2019 00:42 — forked from corsonr/functions.php
Display WooCommerce product variations dropdown select on the shop page
<?php
// Display variations dropdowns on shop page for variable products
add_filter( 'woocommerce_loop_add_to_cart_link', 'woo_display_variation_dropdown_on_shop_page' );
function woo_display_variation_dropdown_on_shop_page() {
global $product;
if( $product->is_type( 'variable' )) {
<?php
class ClassRegistry {
/**
* @var array The store for all objects
*/
private array $store = [];
/**
@djcowan
djcowan / wpmudev-forminator-send-input-ajax-request.php
Created November 19, 2021 10:58 — forked from wpmudev-sls/wpmudev-forminator-send-input-ajax-request.php
[Forminator Pro] - Make an AJAX request upon an input
<?php
/**
* Plugin Name: [Forminator Pro] - Make an AJAX request upon an input
* Plugin URI: https://premium.wpmudev.org/
* Description: Send an AJAX request when an input is filled (as of 1.11.3)
* Author: Alessandro Kaounas @ WPMUDEV
* Author URI: https://premium.wpmudev.org/
* Task: 0/1135022585412927/1164144055767340
* License: GPLv2 or later
*/
@djcowan
djcowan / ajax-search-form.liquid
Created December 14, 2021 02:27 — forked from atikju/ajax-search-form.liquid
Shopify Ajax Search
{% comment %}
This file can be added as a snippet and add it anywhere you want to display
{% endcomment %}
<div id="pageheader">
<div class="util-area">
<div class="search-box">
<form class="search-form" action="/search" method="get" _lpchecked="1">
<i class="icon-mag"></i>
<input type="text" name="q" placeholder="Search" autocomplete="off">
<input type="submit" value="→">
@djcowan
djcowan / font-stacks.css
Created November 10, 2022 03:12 — forked from don1138/font-stacks.css
CSS Modern Font Stacks
/* Modern Font Stacks */
/* System */
font-family: system, -apple-system, ".SFNSText-Regular", "San Francisco", "Roboto", "Segoe UI", "Helvetica Neue", "Lucida Grande", sans-serif;
/* System (Bootstrap 5.2.0) */
font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
/* Times New Roman-based serif */
font-family: Cambria, "Hoefler Text", Utopia, "Liberation Serif", "Nimbus Roman No9 L Regular", Times, "Times New Roman", serif;
@djcowan
djcowan / acc-aa.html
Created November 25, 2022 08:37
Accessiblity
​<!DOCTYPE html>
<html lang="en">
<head>
<title>Title</title>
<meta charset="UTF-8">
<style>
.screen-reader-only {
position: absolute;
left: -10000px;
top: auto;
/*
* @see: <https://blog.coupler.io/importhtml-function-google-sheets/>
*/
// Tables
var index = 1; [].forEach.call(document.getElementsByTagName("table"), function(elements) { console.log("Index: " + index++, elements); });
// Lists
var index = 1; [].forEach.call(document.querySelectorAll("ul,ol"), function(elements) { console.log("Index: " + index++, elements); });
@djcowan
djcowan / gist:b0155009a77b445d7faf0b8d159ae560
Created April 3, 2023 03:06
accordion vanilla javascript
const questions = document.querySelectorAll('#faq dt');
questions.forEach((question) => {
const button = document.createElement('button');
const h3 = document.createElement('h3');
let id = question.getAttribute('id');
if (!id) {
id = encodeURIComponent(question.textContent.trim().toLowerCase());
question.setAttribute('id', id);
@djcowan
djcowan / wp-edit-post-js-after.js
Created May 30, 2023 01:47
wp-edit-post-js-after
<script id="wp-edit-post-js-after">
( function() {
window._wpLoadBlockEditor = new Promise( function( resolve ) {
wp.domReady( function() {
resolve( wp.editPost.initializeEditor( 'editor', "page", 8, {"alignWide":false,"allowedBlockTypes":true,"allowedMimeTypes":{"jpg|jpeg|jpe":"image\/jpeg","png":"image\/png","gif":"image\/gif","webp":"image\/webp","mov|qt":"video\/quicktime","avi":"video\/avi","mpeg|mpg|mpe":"video\/mpeg","3gp|3gpp":"video\/3gpp","3g2|3gp2":"video\/3gpp2","mid|midi":"audio\/midi","pdf":"application\/pdf","doc":"application\/msword","docx":"application\/vnd.openxmlformats-officedocument.wordprocessingml.document","docm":"application\/vnd.ms-word.document.macroEnabled.12","pot|pps|ppt":"application\/vnd.ms-powerpoint","pptx":"application\/vnd.openxmlformats-officedocument.presentationml.presentation","pptm":"application\/vnd.ms-powerpoint.presentation.macroEnabled.12","odt":"application\/vnd.oasis.opendocument.text","ppsx":"application\/vnd.openxmlformats-officedocument.presentationml.s