Skip to content

Instantly share code, notes, and snippets.

Avatar

Ross McKay webaware

View GitHub Profile
@webaware
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: http://snippets.webaware.com.au/snippets/woocommerce-add-to-cart-with-quantity-and-ajax/
View gist:6260468
<?php
/**
* 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
<?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 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 https://snippets.webaware.com.au/howto/wordpress-video-in-the-block-editor/
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
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: https://ssl.webaware.net.au/https-detection/
View force-ssl-url-scheme.php
<?php
/*
Plugin Name: Force SSL URL Scheme
Plugin URI: https://gist.github.com/webaware/4688802
Description: Force the protocol scheme to be HTTPS when is_ssl() doesn't work
Version: 1.0.0
Author: WebAware
Author URI: http://webaware.com.au/
@ref: http://wordpress.org/support/topic/ssl-insecure-needs-35-compatibility
@webaware
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
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
<?php
// jQuery version of https://gist.github.com/3110728
/*
-- the SQL database table
create table form_ajax (
ID varchar(5) not null,
Name varchar(100),
Address varchar(100),
@webaware
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
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
<?php
/*
Plugin Name: GF Country USA
Plugin URI: https://gist.github.com/webaware/edba921af11f06bdfd5147bab806f591
Description: change United States to USA in Gravity Forms addresses
Version: 2
Author: WebAware
Author URI: https://shop.webaware.com.au/
*/
@webaware
webaware / register-link-remover.php
Last active Jun 27, 2022
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/
View register-link-remover.php
@webaware
webaware / Makefile
Created Jun 9, 2022
Build web-ready videos from .mov and .mp4 sources
View Makefile
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