Skip to content

Instantly share code, notes, and snippets.

View lukecav's full-sized avatar
Infinite data generation engine

Luke Cavanagh lukecav

Infinite data generation engine
View GitHub Profile
@mkkeck
mkkeck / class-editor-social-link.php
Last active January 14, 2024 13:48
Patched WordPress block `core/social-link` to allow theme developers to register own social services
@NickGreen
NickGreen / cart_total_notice.php
Last active November 2, 2021 16:33
Add cart and checkout notices if total less than $25
<?php
add_action( 'woocommerce_before_cart_table', 'free_shipping_notice' );
add_action( 'woocommerce_checkout_before_customer_details', 'free_shipping_notice' );
function free_shipping_notice() {
if ( 25 > WC()->cart->get_total() ) {
echo '<div style="color: #e08e79;">All orders over $25 ship free</div>';
}
}
<?php
/**
* Plugin Name: Fix woocommerce admin analytics performance issue
* Plugin URI:
* Description:
* Version: 1.0.0
* Author:
* Author URI:
* License: MIT
<?php
/*
Migrate from WP User Avatar to Simple Local Avatars
Allows sites to easily move away from the WP User Avatar plugin and switch to Simple Local Avatars instead.
Run by invoking with WP CLI like so:
`wp eval-file migrate-wp-user-avatar.php`
Author: Philip John
@roykho
roykho / gist:14c57ab320b2f999e86bb0b531b2e55a
Last active April 17, 2023 12:58
WooCommerce: Delete old lingering admin notices
// Use these instructions at your own risk. Make sure you have full site/database backup prior to proceeding.
//
// Install this plugin to add custom PHP code https://wordpress.org/plugins/code-snippets/
// Activate the plugin.
// Go to Snippets->Add New
// Paste the following code into the provided "Code" field.
// Choose to Run Only Once.
// Click Save changes and activate button at the bottom.
// After running it once, I would suggest to remove this snippet otherwise you may miss out on important updates in the future.
// After running this, you may get a fresh copy of the notices once more. This is normal and this time when you dismiss them, they should stay gone..
@NickGreen
NickGreen / prod_cat_email.php
Last active November 2, 2021 16:32
Add Product Category to email subject WooCommerce
<?php
add_filter( 'woocommerce_email_subject_new_order', 'customizing_new_order_subject', 10, 2 );
function customizing_new_order_subject( $formated_subject, $order ) {
$email = WC()->mailer->get_emails()['WC_Email_New_Order'];
$subject = $email->get_option( 'subject', $email->get_default_subject() );
$product_categories = array();
foreach ( $order->get_items() as $item ) {
$product_categories[] = implode( ', ', wp_get_post_terms( $item->get_product_id(), 'product_cat', array( 'fields' => 'names' ) ) );
@justintadlock
justintadlock / functions.php
Created April 29, 2021 14:23
Remove block-templates support from Gutenberg.
<?php
// Drop the below in theme functions.php.
add_action( 'after_setup_theme', function() {
remove_theme_support( 'block-templates' );
} );
@stevegrunwell
stevegrunwell / limit-orders-shortcode.php
Created March 26, 2021 15:55
Limit Orders for WooCommerce - Custom Shortcodes
<?php
/**
* Plugin Name: Limit Orders for WooCommerce - Shortcode
* Description: Custom shortcode for displaying information from the Order Limiter.
* Author: Nexcess
* Author URI: https://nexcess.net
*/
use Nexcess\LimitOrders\OrderLimiter;
@stevegrunwell
stevegrunwell / limit-orders-do-not-empty-cart.php
Created February 4, 2021 19:34
Prevent WooCommerce from emptying carts after the order limit has been reached — https://wordpress.org/support/topic/cart-empties-when-limit-is-hit/
<?php
/**
* Plugin Name: Limit Orders for WooCommerce - Prevent Empty Carts
* Description: Prevent WooCommerce from emptying carts after the order limit has been reached.
* Author: Nexcess
* Author URI: https://nexcess.net
*/
/**
* Prevent WooCommerce from removing non-purchasable items from the cart.
@NickGreen
NickGreen / auto_update_specific_times.php
Last active April 15, 2021 13:16
Allow plugins to be autoupdated only during specific days and times
<?php
/*
Plugin Name: Plugin Autoupdate Filter
Plugin URI: https://gist.github.com/NickGreen/a66d349575cf9e78c6dafd92efa5288a/edit
Description: Plugin which sets plugin autoupdates to always on, but only happen during specific times.
Version: 1.0
Author: Nick Green
Author URI:
License: GPLv3
*/