Skip to content

Instantly share code, notes, and snippets.

View webaware's full-sized avatar

Ross McKay webaware

View GitHub Profile
<?php
/*
Plugin Name: GF Countries for WooCommerce
Plugin URI: https://gist.github.com/webaware/985156c48d8fea3cc77d9a9c624aad18
Update URI: gf-countries-woo
Description: restrict Gravity Forms addresses to WooCommerce-allowed countries
Version: 2
Author: WebAware
Author URI: https://shop.webaware.com.au/
*/
@webaware
webaware / video.twig
Last active November 30, 2022 02:14
Replace the HTML for the standard WordPress video shortcode, simplifying it to just a video element without extra wrapping divs, buttons, etc. See blog post https://snippets.webaware.com.au/howto/wordpress-video-in-the-block-editor/
<video class="project-video" controls controlslist="nodownload" playsinline disablePictureInPicture
{%- if video.autoplay %} autoplay muted {%- endif -%}
{%- if video.preload %} preload="{{ video.preload }}" {%- endif -%}
{%- if video.loop %} loop {%- endif -%}
{%- if video.width %} width="{{ video.width }}" {%- endif -%}
{%- if video.height %} height="{{ video.height }}" {%- endif -%}
{%- if video.poster %} poster="{{ video.poster }}" {%- endif -%}
>
{%- for source in video.sources -%}
@webaware
webaware / bitbucket.js
Created September 2, 2014 22:01
Some bookmarklets for setting tab-size to 4 on GitHub, Gist, and Bitbucket. NB: they all work in Chrome, but the GitHub and Gist ones don't work in Firefox (as at v31) because of its implementation for honouring CSP headers.
javascript:(function(){var style=document.createElement('style'),css=document.createTextNode('.refract-container .source{-moz-tab-size:4;tab-size:4;}');style.appendChild(css);document.getElementsByTagName('head')[0].appendChild(style);})();
@webaware
webaware / gist:d1b51f68977d32603491
Last active August 5, 2022 10:41
Clean up the mess left in WordPress users tables by WP e-Commerce, after you've removed that plugin from WordPress.
delete from u, um
using wp_users u
left join wp_usermeta um on um.user_id = u.ID
where u.user_login like '\_%'
@webaware
webaware / register-link-remover.php
Last active June 27, 2022 08:55
Remove the register link from the WordPress wp-login.php script. See blog post: http://snippets.webaware.com.au/snippets/remove-register-link-wordpress-wp-login-php/
@webaware
webaware / Makefile
Created June 9, 2022 08:37
Build web-ready videos from .mov and .mp4 sources
SRC := Brightscape.mov FUNK-instagram-mockup.mp4
SRC_MOV := $(filter %.mov,$(SRC))
SRC_MP4 := $(filter %.mp4,$(SRC))
JPG := $(patsubst %.mov, out/%-vid.jpg, $(SRC_MOV)) $(patsubst %.mp4, out/%-vid.jpg, $(SRC_MP4))
MP4 := $(patsubst %.mov, out/%.mp4, $(SRC_MOV)) $(patsubst %.mp4, out/%.mp4, $(SRC_MP4))
VP9 := $(patsubst %.mov, out/%.webm, $(SRC_MOV)) $(patsubst %.mp4, out/%.webm, $(SRC_MP4))
.PHONY: all jpg mp4 vp9
@webaware
webaware / Makefile
Created May 20, 2022 10:21
how an old fart builds JS, JSX, SCSS, and lints them plus PHP for a WP theme
.PHONY: all favicons lint lint-js lint-php lint-twig lint-css css-compile css-postcss
all:
@echo please see Makefile for available builds / commands
# optimise branding tiles and build the favicon
FAVICON_DIR := images/favicons
favicons: $(FAVICON_DIR)/favicon.ico
@webaware
webaware / gf-email-route-by-country.php
Created April 21, 2022 04:27
adapt Gravity Forms notification rules based on country in an Address field
<?php
if (!defined('ABSPATH')) {
exit;
}
/**
* adapt notification rules based on country in Address field
* - set Send To email address to a trigger value
* - set Value to the address field ID
@webaware
webaware / woocommerce-notices-shortcode.php
Last active March 17, 2022 17:45
display WooCommerce notices in any page by shortcode [woocommerce_notices]
<?php
/*
Plugin Name: WooCommerce Notices Shortcode
Plugin URI: https://gist.github.com/webaware/c6a6286026eb6a89e5a3
Description: display WooCommerce notices in any page by shortcode [woocommerce_notices]
Author: WebAware
Author URI: https://shop.webaware.com.au/
*/
if (!defined('ABSPATH')) {
@webaware
webaware / gf-countries-restrict.php
Last active January 23, 2022 06:44
restrict Gravity Forms addresses to USA, Canada; with support for GF Address Enhanced
<?php
/*
Plugin Name: GF Countries Restrict
Plugin URI: https://gist.github.com/webaware/2a9e72a94290fa8a9c7d6d60c9ae052a
Update URI: gf-countries-restrict
Description: restrict Gravity Forms addresses to USA, Canada
Version: 1
Author: WebAware
Author URI: https://shop.webaware.com.au/
*/