Skip to content

Instantly share code, notes, and snippets.

Radley Sustaire RadGH

Block or report user

Report or block RadGH

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
RadGH / ups-self-packed-products.php
Last active Dec 10, 2019
[WooCommerce UPS Shipping] This script allows you to specify products as "already packed". They will not be added to separate boxes, and will not be combined with other products.
View ups-self-packed-products.php
// This script allows you to specify products as "already packed". They will not be added to separate boxes, and will not be combined with other products.
// This is useful if you have products that are already packed and ready to ship that should not be put into another box.
// The plugin 'WooCommerce UPS Shipping' does not currently support the filter "woocommerce_shipping_ups_skip_packing".
// For now, you must manually edit the UPS plugin directly. The two edits are located below (for version 3.2.18):
// 1.
// 2.
RadGH / class-wc-shipping-ups.php
Last active Dec 10, 2019
Modified version of "class-wc-shipping-ups.php" version "3.2.18". See:
View class-wc-shipping-ups.php
* Shipping method class.
* @package WC_Shipping_UPS
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
RadGH / class-wc-boxpack.php
Last active Dec 10, 2019
Modified version of "class-wc-boxpack.php" version "3.2.18". See:
View class-wc-boxpack.php
* WooCommerce Box Packer
* @version 2.0.1
* @author WooThemes / Mike Jolley
class WC_Boxpack {
RadGH / js-local-storage.js
Last active Jan 7, 2020
JavaScript storage using localstorage with Get, Set, Delete. Falls back to 30-day cookies if LocalStorage is not supported.
View js-local-storage.js
// Usage:
cache.set('name', 'Radley');
alert( cache.get('name') ); // Displays "Radley"
alert( cache.get('name') ); // Displays ""
// End of usage. Note that this code must go below the actual cache definition (below)
RadGH / gf-get-field-value.php
Created Oct 20, 2019
Gets a field value from a Gravity Form field, formatted to be compatible with the "gform_field_value" filter (particularly for checkboxes)
View gf-get-field-value.php
* Get the values for a field, compatible with the filter "gform_field_value" particularly for checkbox fields.
* Uses the native "get_post_field_value" function which is sadly private (for no good reason).
* @see
RadGH / wp-remote-request-wrapper.php
Last active Sep 6, 2019
WP Remote Get/Post/Put/Patch/Del wrapper for apis with json decoded body and consistent result data
View wp-remote-request-wrapper.php
// sample usage
$url = '';
$url_args = array( 'id' => 47, 'name' => 'radley' );
$body_fields = array( 'nonce' => 12345 );
$headers = array( 'Authorization' => 'api 123456' ); // Mailchimp-style api key using basic authorization
$result = rs_remote_request( $url, 'GET', $url_args, $body_fields, $headers );
RadGH / wp-settings-api-text-fields.php
Created Aug 23, 2019
WordPress settings api for simple settings fields
View wp-settings-api-text-fields.php
add_action( 'admin_menu', 'myplugin_register_settings_menu_page' );
add_action( 'admin_init', 'myplugin_register_settings_fields' );
function myplugin_register_settings_menu_page() {
add_options_page( 'My plugin', 'My plugin', 'manage_options', 'myplugin-settings', 'myplugin_display_settings_menu' );
function myplugin_register_settings_fields() {
RadGH / wp-process-post-type.php
Created Aug 5, 2019
Process/iterate through all posts in a post type
View wp-process-post-type.php
This function will loop through all posts matching a filter, allowing you to make some edits to them with PHP.
To begin just visit your site ending with /?FojVDY83
Important: To avoid re-processing the same post infinitely, you need to make sure the meta_query will not match the same post after it has been processed. This is done below by checking if the meta key "status" exists or not.
RadGH / wp-show-screen-id-in-admin-footer.php
Created Aug 2, 2019
WordPress: Show current screen ID and Base in the admin footer, visible only on hover
View wp-show-screen-id-in-admin-footer.php
RadGH / wp-search-custom-db.php
Last active Jun 24, 2019
How to add a custom table in WordPress to collect search results
View wp-search-custom-db.php
1. Modify the table and logging function if needed. You probably want to remove "groups" which for my case, represented
which group your user account belonged to. We needed to be able to isolate search requests based on group.
2. After your search term has been performed, log the search using rad_log_search_term().
3. Build some fancy dashboard to show the data, or be a nerd and do your own mysql queries every time.
4. IMPORTANT: The activation hook for "rad_activate_plugin" MUST go in your plugin main directory. If the plugin is active
when you add this code, just call rad_activate_plugin() manually once, refresh a page, then remove the manual call.
You can’t perform that action at this time.