Skip to content

Instantly share code, notes, and snippets.

View webaware's full-sized avatar

Ross McKay webaware

View GitHub Profile
@webaware
webaware / contiguous-usa.php
Created January 19, 2024 21:41
GF Address Enhanced: Filter USA states to only have the Lower 48 + DC. Add this to a plugin, or functions.php in your theme.
<?php
/**
* Filter USA states to only have the Lower 48 + DC
*/
add_filter('gf_address_enhanced_smart_states_script_data', function(array $script_data) : array {
if (isset($script_data['states']['United States'])) {
// Alaska, Hawaii, and the Armed Forces codes
$remove = ['AK', 'HI', 'AA', 'AE', 'AP'];
@webaware
webaware / private-debug-log.php
Created February 17, 2013 02:17
Enable WordPress debug log to a private folder not accessible from the web. See http://wordpress.stackexchange.com/q/84132/24260 for details and motivations. NB: currently needs to be manually edited to specify the private folder path;
<?php
/*
Plugin Name: Private Debug Log
Description: Enable debug log to a private folder not accessible from the web
Version: 0.0.1
Author: WebAware
Author URI: http://www.webaware.com.au/
*/
/*
@webaware
webaware / add-to-cart.php
Last active October 22, 2023 05:55 — forked from mikejolley/functions.php
WooCommerce purchase page add-to-cart with quantity and AJAX, by customising the add-to-cart template in the WooCommerce loop. See blog post for details: http://snippets.webaware.com.au/snippets/woocommerce-add-to-cart-with-quantity-and-ajax/
<?php
/**
* Loop Add to Cart -- with quantity and AJAX
* requires associated JavaScript file qty-add-to-cart.js
*
* @link http://snippets.webaware.com.au/snippets/woocommerce-add-to-cart-with-quantity-and-ajax/
* @link https://gist.github.com/mikejolley/2793710/
*/
// add this file to folder "woocommerce/loop" inside theme
@webaware
webaware / gf-country-usa.php
Last active September 30, 2023 02:38
change United States to USA in Gravity Forms addresses, with support for Gravity Forms Address Enhanced
<?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 / force-ssl-url-scheme.php
Last active September 3, 2023 00:05
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/
<?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 / plugin-download.php
Created June 18, 2023 04:38
Add download links to WordPress plugins with updates available
<?php
/*
Plugin Name: Plugin Download
Plugin URI: https://gist.github.com/webaware/4a4f2dca44b1c10fb9a8fe85a5f90f40
Update URI: plugin-download
Description: add download links to plugins with updates available
Version: 0.0.1
Author: WebAware
Author URI: https://shop.webaware.com.au/
*/
@webaware
webaware / gist:6260468
Last active June 6, 2023 18:00
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/
<?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');
@webaware
webaware / network-lister.php
Last active May 14, 2023 03:56
Simple dashboard widget for listing WordPress multisite sites, and accompanying shortcode for the front end.
<?php
/*
Plugin Name: Network Lister
Plugin URI: https://gist.github.com/webaware/b914967f0ce8110c775cd12ddc546283
Update URI: network-lister
Description: simple dashboard widget for listing network sites
Version: 0.0.5
Author: WebAware
Author URI: https://shop.webaware.com.au/
*/
@webaware
webaware / chequerboard.css
Last active April 17, 2023 23:23
Give something a grey / white chequerboard background, in two lines of CSS. Stolen from somewhere on Stack Overflow IIRC.
.my-element {
background-image: conic-gradient(#ddd 25%, #fff 25%, #fff 50%, #ddd 50%, #ddd 75%, #fff 75%);
background-size: 40px 40px;
}
@webaware
webaware / gist:4048580
Created November 9, 2012 22:02
basic example of populating a form from a database using AJAX and JSON, jQuery version
<?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),