Skip to content

Instantly share code, notes, and snippets.

View tomgreenhill's full-sized avatar
😶‍🌫️
🫠

Tom Greenhill tomgreenhill

😶‍🌫️
🫠
View GitHub Profile
@stracker-phil
stracker-phil / forminator-via-ajax-script.js
Last active April 18, 2024 18:12
Load Forminator Form via Ajax
// This JS file is loaded by the theme:
(function() {
// The button with the CSS class "get-support" loads the form.
jQuery('.get-support').on('click', load_support_form);
// The form is displayed in a div tag with the CSS class "support-form".
function load_support_form() {
jQuery.get('/wp-admin/admin-ajax.php?action=my_get_support')
.then(function(response) {
<!DOCTYPE html>
<html>
<head>
<title>Vanilla Fitvids.js</title>
<style type="text/css">
body {
margin: 0 auto;
max-width: 40em;
width: 88%;
@courtneymyers
courtneymyers / acf_modifications.php
Created February 28, 2018 18:36
Reduces initial height of Advanced Custom Fields WYSIWYG fields to 100px, and enables autoresizing of WYSIWYG field, as text is entered. Best practice would be to include this function in a site-specific plugin.
<?php
/*
* -----------------------------------------------------------------------------
* Advanced Custom Fields Modifications
* -----------------------------------------------------------------------------
*/
function PREFIX_apply_acf_modifications() {
?>
<style>
@ridem
ridem / Download-Shopify-CDN-Assets.md
Last active October 28, 2023 12:15
Download all Shopify CDN assets from a store

Instructions

  1. Go to your Shopify admin/settings/files page
  2. Open your browser Dev tools, go to the console

Then, depending on the option you choose:

Option 1 - Download all the files directly (might crash you browser)

  1. Make sure your browser is set to download files automatically and doesn't ask for the download location every time
// Handles all the things ajax cart related,
// based around the timber ajax cart, minus the jquery
import serialize from 'form-serialize'
import fetch from 'unfetch'
const RicherAPI = {}
// tacos
RicherAPI.onCartUpdate = (cart) => {
console.log('items in the cart?', cart.item_count)
@michaelpumo
michaelpumo / underline.scss
Last active December 6, 2016 11:00
Smarter Underline Mixin SCSS
@function em($pixels, $context: 16) {
@return #{$pixels/$context}em;
}
@mixin underline($color: black, $hover: black, $background: white, $position: 16.5, $thickness: 0.08em) {
$underline-position: em($position);
$underline-color: $color;
$underline-color-hover: $hover;
$underline-color-shadow: $background;
@andreasvirkus
andreasvirkus / jump.js
Last active April 19, 2021 14:33
A vanilla scrollTop implementation (includes throttle and scrollTo utility functions)
/**
* Vanilla scrollTo implementation (smoothly scroll/"jump" to an element)
* @author github.com/andreasvirkus
*
* Default easing is:
* Robert Penner's easeInOutQuad - http://robertpenner.com/easing/
*
* @param {String} target selector to scroll to
* @param {Object} options Optionally defined duration, offset, callback and easing
*
@Razenbull
Razenbull / google_place_autocomplete.js
Last active May 9, 2024 13:42
google place autocomplete && select first option on enter if !$(".pac-item-selected")
var $addressInput = $('#locationAddressInput');
var setKeyDownListener = selectFirstOptionOnEnter($addressInput[0]);
window.autocomplete = new google.maps.places.Autocomplete($addressInput[0], {
type: ['geocode'],
componentRestrictions: {country: 'be'}
});
google.maps.event.addListener(window.autocomplete, 'place_changed', function () {
var address = window.autocomplete.getPlace();
@magicznyleszek
magicznyleszek / regex.md
Last active March 4, 2022 20:57
RegEx Cheatsheet
@tomazzaman
tomazzaman / functions.php
Created February 18, 2015 23:57
Insert image in WordPress with HTML5 <figure> tag and caption
<?php
// Don't include the opening tag
function html5_insert_image( $html, $id, $caption, $title, $align, $url, $size, $alt ) {
$src = wp_get_attachment_image_src( $id, $size, false );
$html5 = "<figure id=\"post-$id media-$id\" class=\"align-$align\">";
if ( $url ) {
$html5 .= "<a href=\"$url\" class=\"image-link\"><img src=\"$src[0]\" alt=\"$alt\" /></a>";
} else {