Skip to content

Instantly share code, notes, and snippets.

View lukecav's full-sized avatar
🙏
If we're kind and polite, the world will be right.

Luke Cavanagh lukecav

🙏
If we're kind and polite, the world will be right.
View GitHub Profile
@mkkeck
mkkeck / class-editor-social-link.php
Last active October 15, 2024 13:41
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
@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
*/
@stevegrunwell
stevegrunwell / limit-orders-custom-daily-interval.php
Last active November 17, 2022 21:57
Set a custom start time for the "daily" interval when using Limit Orders for WooCommerce.
<?php
/**
* Plugin Name: Limit Orders for WooCommerce - Custom Daily Interval
* Description: Restart daily order limiting at a time other than midnight.
* Author: Nexcess
* Author URI: https://nexcess.net
*/
/**
* Get a DateTime object representing the start of the daily interval.