Skip to content

Instantly share code, notes, and snippets.


Ross McKay webaware

View GitHub Profile
webaware / gist:6260468
Last active Jan 12, 2023
WooCommerce purchase page add-to-cart with quantity and AJAX, without customising any templates. See blog post for details:
View gist:6260468
* start the customisation
function custom_woo_before_shop_link() {
add_filter('woocommerce_loop_add_to_cart_link', 'custom_woo_loop_add_to_cart_link', 10, 2);
add_action('woocommerce_after_shop_loop', 'custom_woo_after_shop_loop');
add_action('woocommerce_before_shop_loop', 'custom_woo_before_shop_link');
View gf-countries-woo.php
Plugin Name: GF Countries for WooCommerce
Plugin URI:
Update URI: gf-countries-woo
Description: restrict Gravity Forms addresses to WooCommerce-allowed countries
Version: 2
Author: WebAware
Author URI:
webaware / video.twig
Last active Nov 30, 2022
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
View video.twig
<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 / force-ssl-url-scheme.php
Last active Nov 9, 2022
For WordPress, force the protocol scheme to be HTTPS when is_ssl() doesn't work, e.g. on a load-balanced server where _SERVER['HTTPS'] and _SERVER['SERVER_PORT'] don't indicate that SSL is being used. NB: may not be needed now, see SSL Insecure Content Fixer and HTTP Detection:
View force-ssl-url-scheme.php
Plugin Name: Force SSL URL Scheme
Plugin URI:
Description: Force the protocol scheme to be HTTPS when is_ssl() doesn't work
Version: 1.0.0
Author: WebAware
Author URI:
webaware / bitbucket.js
Created Sep 2, 2014
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.
View bitbucket.js
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 / gist:4048580
Created Nov 9, 2012
basic example of populating a form from a database using AJAX and JSON, jQuery version
View gist:4048580
// jQuery version of
-- the SQL database table
create table form_ajax (
ID varchar(5) not null,
Name varchar(100),
Address varchar(100),
webaware / gist:d1b51f68977d32603491
Last active Aug 5, 2022
Clean up the mess left in WordPress users tables by WP e-Commerce, after you've removed that plugin from WordPress.
View gist:d1b51f68977d32603491
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 / gf-country-usa.php
Last active Jul 12, 2022
change United States to USA in Gravity Forms addresses, with support for Gravity Forms Address Enhanced
View gf-country-usa.php
Plugin Name: GF Country USA
Plugin URI:
Description: change United States to USA in Gravity Forms addresses
Version: 2
Author: WebAware
Author URI:
webaware / register-link-remover.php
Last active Jun 27, 2022
Remove the register link from the WordPress wp-login.php script. See blog post:
View register-link-remover.php
webaware / Makefile
Created Jun 9, 2022
Build web-ready videos from .mov and .mp4 sources
View Makefile
SRC := FUNK-instagram-mockup.mp4
SRC_MOV := $(filter,$(SRC))
SRC_MP4 := $(filter %.mp4,$(SRC))
JPG := $(patsubst, out/%-vid.jpg, $(SRC_MOV)) $(patsubst %.mp4, out/%-vid.jpg, $(SRC_MP4))
MP4 := $(patsubst, out/%.mp4, $(SRC_MOV)) $(patsubst %.mp4, out/%.mp4, $(SRC_MP4))
VP9 := $(patsubst, out/%.webm, $(SRC_MOV)) $(patsubst %.mp4, out/%.webm, $(SRC_MP4))
.PHONY: all jpg mp4 vp9