Skip to content

Instantly share code, notes, and snippets.

View webaware's full-sized avatar

Ross McKay webaware

View GitHub Profile
@webaware
webaware / force-ssl-url-scheme.php
Last active December 3, 2025 18:13
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 / gist:4964078
Last active December 13, 2015 19:38
Extend WP e-Commerce customer emails to add shipping and billing details. Just drop this into a plugin, or add to your theme's functions.php. Some discussion over at my blog post about extending notification emails in wp-e-commerce -- http://snippets.webaware.com.au/snippets/extend-notification-emails-in-wp-e-commerce/
<?php
/**
* extend WP e-Commerce customer emails to add shipping and billing details
* drop this into a plugin, or add to your theme's functions.php
*/
class WpscExtendCustEmail {
/**
* add filter hooks
*/
public function __construct() {
@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 / gist:5349924
Last active May 10, 2019 21:25
Example of using the gform_pre_render filter hook to perform calculations, returning results in dynamically populated fields. See documentation links for more info. http://www.gravityhelp.com/documentation/page/Gform_pre_render http://www.gravityhelp.com/documentation/page/Using_Dynamic_Population
<?php
/**
* excerpt from compound classroom field, for example purposes only
* the real class is over 700 lines
*/
class OlpcGfClassroomField {
/**
* hook into Gravity Forms
@webaware
webaware / gist:5882259
Last active December 19, 2015 02:19
replace icons in Social Media Feather plugin with custom icons; see http://wordpress.org/plugins/social-media-feather/
<?php
/*
* replace icons in Social Media Feather with custom icons
* @ref: http://wordpress.org/plugins/social-media-feather/
*/
add_filter('synved_social_skin_image_list', 'custom_social_feather_icons');
function custom_social_feather_icons($image_list) {
@webaware
webaware / add-to-cart.php
Last active October 9, 2024 00:33 — 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 / gist:6260468
Last active August 5, 2025 09:31
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 / debug-log-not-strict.php
Last active December 23, 2024 02:31
Turn on WordPress' WP_DEBUG_LOG but without E_STRICT. Accompanying blog post: http://snippets.webaware.com.au/snippets/wordpress-wp_debug_log-without-e_strict/
<?php
/*
Plugin Name: Debug Log Not Strict
Plugin URI: https://gist.github.com/webaware/6520892
Description: Turn on WP_DEBUG_LOG but without E_STRICT
Version: 1.4.0
Author: WebAware
Author URI: https://shop.webaware.com.au/
*/
@webaware
webaware / wp-migrate-db-fix-options.php
Last active November 7, 2018 00:25
Preserve some WordPress test/dev environment settings when pulling data from a production server with WP Migrate DB Pro
<?php
/*
Plugin Name: WP Migrate DB Fix Options
Plugin URI: https://gist.github.com/webaware/6959279
Description: Fix some options after a WP Migrate DB Pro migration, back to dev/test mode
Version: 1.0.0
Author: WebAware
Author URI: http://www.webaware.com.au/
@ref: http://snippets.webaware.com.au/snippets/use-wp-migrate-db-pro-and-keep-your-development-environment-settings
@webaware
webaware / gist:7689334
Created November 28, 2013 09:27
quick WordPress snippet for showing what classes have been added to the HTML and BODY elements -- useful for seeing what a tablet or phone gets without messing around with debuggers.
<?php
add_action('wp_print_footer_scripts', function() {
?>
<script>
(function() {
var p = document.createElement("p");