Skip to content

Instantly share code, notes, and snippets.

View boswall's full-sized avatar

Matt Rose boswall

View GitHub Profile
### Keybase proof
I hereby claim:
* I am boswall on github.
* I am matt_goodlife (https://keybase.io/matt_goodlife) on keybase.
* I have a public key ASAbVBLD2c5Y5_ei_eE9d_El7ooDCaHNCX_bM0npHjpUyAo
To claim this, I am signing this object:
@boswall
boswall / wati.php
Created July 19, 2022 14:03
WooCommerce WATI Integration
<?php
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
add_action( 'woocommerce_order_status_completed', 'boswall_wati_woocommerce_order_status_completed', 20, 2 );
function boswall_wati_woocommerce_order_status_completed( $order_id, $order ) {
$logger = wc_get_logger();
$context = array( 'source' => 'woocommece-wati' );
@boswall
boswall / boswall_option_woocommerce_sagepaydirect_settings.php
Last active February 24, 2021 14:31
Stop WooCommerce SagePay / Opayo taking Credit Cards based on country
<?php
add_filter( 'option_woocommerce_sagepaydirect_settings', 'boswall_option_woocommerce_sagepaydirect_settings', 100 );
function boswall_option_woocommerce_sagepaydirect_settings ( $value ) {
if ( is_admin() ) {
return $value;
}
if ( ! is_checkout() ) {
return $value;
}
@boswall
boswall / boswall-staging-notify.php
Last active September 17, 2020 12:27
Add a notification to the admin top bar to show users if they are on the live / staging / test / dev version of a WordPress site
<?php
/*
Plugin Name: Site Environment Notification
Plugin URI: https://gist.github.com/boswall/c50836f73088ffc46fbd0922fd37e412
Description: Add a notification to the admin top bar to show users if they are on the ‘local’, ‘development’, ‘staging’ or ‘production’ version of the site. Use <code>define( 'WP_ENVIRONMENT_TYPE', 'local' );</code> to define this in the wp-config.php file.
Author: Matt Rose
Author URI: https://glaikit.co.uk/
*/
@boswall
boswall / add_coupons_to_thankyou_url.php
Last active January 7, 2020 14:11
Add used Coupon codes to the URL of the Order Confirmation page in WooCommerce. Useful for tracking.
add_filter( 'woocommerce_get_endpoint_url', 'boswall_woocommerce_get_endpoint_url', 10, 4 );
function boswall_woocommerce_get_endpoint_url( $url, $endpoint, $value, $permalink ) {
// only on the thank you page
if ( 'order-received' !== $endpoint ) {
return $url;
}
return add_query_arg( 'coupons_used', implode( ',', wc_get_order( $value ) ), $url );
};
@boswall
boswall / boswall-theme-mod-hestia-general-credits.php
Last active September 22, 2022 17:46
Change footer copyright credits in Hestia theme in WordPress. Put this in a plugin or theme functions file.
<?php
/**
* Plugin Name: Boswall's Credits Mod for Hestia
* Plugin URI: https://gist.github.com/boswall/f263f77b3e4cb2349e7c94518834b5e5
* Description: Change the default credits text in the Hestia Theme
* Version: 2.0
* Author: Matt Rose
* Author URI: https://glaikit.co.uk/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
@boswall
boswall / boswall_cctm_export.php
Last active February 27, 2018 11:43
Export from the old CCTM plugin to use WP native custom post types and CMB2
<?php
/**
* Plugin Name: Boswall's CCTM exporter
* Plugin URI: https://glaikit.co.uk/
* Description: Export from the old CCTM plugin to use WP native custom post types and CMB2
* Version: 1.0
* Author: Matt Rose
* Author URI: https://glaikit.co.uk/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
@boswall
boswall / plugin-info-dump.php
Created February 6, 2018 12:08
WordPress Plugin Info Dumper
<?php
/*
Plugin Name: Plugin Info dumper
Plugin URI: http://drivedigital.co.uk/
Description: Dump the plugin info.
Author: Matt Rose
Version: 1.0
Author URI: http://drivedigital.co.uk/
*/
<?php
/*
Plugin Name: Boswall's Checkout Clearer
Plugin URI: #
Description: Fixing the checkout privacy error in Loushou: ACF to WooCommerce plugin. http://wordpress.org/support/topic/previous-form-entry-visible-on-next-form-view/
Version: 1
Author: Boswall
Author URI: https://glaikit.co.uk/
*/
@boswall
boswall / grey-text-widgets.php
Created September 15, 2016 15:57
WordPress Text Widget extend - to give it a different class for styling reasons
<?php
/**
*
* CSS code was colouring text boxes based on their ID, breaking if you added a new one or rearranged them. This adds a new text widget with different classes that can be styled properly.
* MR 2016
*
* Style with
* .widget_grey_text {}
*
**/