Skip to content

Instantly share code, notes, and snippets.

@helgatheviking
helgatheviking / kia-local-dev.php
Created Sep 9, 2020
Snippet for local WordPress development
View kia-local-dev.php
<?php
/**
* Plugin Name: Local Dev modifications
* Plugin URI: https://kathyisawesome.com/
* Description: Custom snippets for local development
* Version: 1.0.0
* Author: Kathy Darling
* Author URI: https://kathyisawesome.com
*/
@helgatheviking
helgatheviking / wc-mnm-ups-bridge.php
Last active Sep 4, 2020
Add support for Mix and Match products to PluginHive UPS
View wc-mnm-ups-bridge.php
<?php
/**
* Plugin Name: WooCommerce Mix and Match - PluginHive UPS Bridge
* Plugin URI: http://www.woocommerce.com/products/woocommerce-mix-and-match-products/
* Description: Add support for Mix and Match products to UPS shipping.
* Version: 1.0.0
* Author: Kathy Darling
* Author URI: http://kathyisawesome.com/
* WC requires at least: 4.0.0
* WC tested up to: 4.4.0
@helgatheviking
helgatheviking / wc-mnm-external-grouping.php
Created Aug 12, 2020
Fix add to cart URL/text for external products that don't have an external URL
View wc-mnm-external-grouping.php
<?php
/**
* Plugin Name: Mix and Match external product parents
* Plugin URI: https://gist.github.com/helgatheviking/af72435b3cf729886b852c61c0f2d38c
* Description: Fix add to cart URL/text for external products that don't have an external URL. Like when using a product table to group products together.
* Version: 1.0.0
* Author: Kathy Darling
* Author URI: https://kathyisawesome.com
* Text Domain: mnm-external-parent
* Domain Path: /i18n/languages/
@helgatheviking
helgatheviking / wc-sub-prevent-switching-before-renewal.php
Created Aug 4, 2020
Disable Mix and Match contents switching for timer window prior to renewal
View wc-sub-prevent-switching-before-renewal.php
/**
* Disable contents switching for window prior to renewal
*
* @param boolean $can
* @param WC_Order_Item $item
* @param WC_Subscription $subscription
* @return boolean
*/
public static function kia_prevent_modification_of_subscription( $can, $item, $subscription ) {
@helgatheviking
helgatheviking / mnm-rest-api-create-mix-and-match-product.txt
Created Jul 25, 2020
Create a WooCommerce Mix and Match product with it's settings
View mnm-rest-api-create-mix-and-match-product.txt
curl -X POST https://example.com/wp-json/wc/v3/products \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"name": "Sample Six Pack",
"type": "mix-and-match",
"regular_price": "0",
"description": "So many products to choose from.",
"short_description": "Pick 6.",
"categories": [
@helgatheviking
helgatheviking / display-attributes-as-table.php
Created May 21, 2020
Display the WooCommerce product attributes as a table element via shortcode [display_attributes]
View display-attributes-as-table.php
<?php
/**
* Attributes shortcode callback.
*/
function so_39394127_attributes_shortcode( $atts ) {
global $product;
if( ! is_object( $product ) || ! $product->has_attributes() ){
@helgatheviking
helgatheviking / xdebug-var-dump.css
Created May 12, 2020
Style rules to make var_dump a hell of a lot more readable
View xdebug-var-dump.css
.xdebug-var-dump {
/* These are technically the same, but use both */
overflow-wrap: break-word;
word-wrap: break-word;
-ms-word-break: break-all;
/* This is the dangerous one in WebKit, as it breaks things wherever */
word-break: break-all;
/* Instead use this non-standard one: */
View class-kia-subtitle-bb.php
<?php
/**
* @package KIA Subtitle
* @category Compatibility Class
* @version 3.1.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
@helgatheviking
helgatheviking / add-win-terminal-ubuntu-profile-to-context-menus.reg
Last active Jul 2, 2020
Add "Open Ubuntu Terminal Here" to context menus - Launches Windows Terminal's Ubuntu profile.
View add-win-terminal-ubuntu-profile-to-context-menus.reg
Windows Registry Editor Version 5.00
Replace <<Username>> with your user name!
[HKEY_CLASSES_ROOT\Directory\Background\shell\ubuntu]
@="Open Ubuntu Terminal here"
"Icon"="%USERPROFILE%/AppData/Local/WindowsTerminal/ubuntu.ico"
[HKEY_CLASSES_ROOT\Directory\Background\shell\ubuntu\command]
@="C:\\Users\\<<Username>>\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe -d . --profile=\"Ubuntu-18.04\""
@helgatheviking
helgatheviking / class-wc-kia-class-email.php
Last active May 19, 2020
Send a WooCommerce Customer email from the Order Admin Actions
View class-wc-kia-class-email.php
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! class_exists( 'WC_KIA_Class_Email', false ) ) :
/**
* A custom Order WooCommerce Email class
*
* @since 0.1
* @extends \WC_Email
You can’t perform that action at this time.