Skip to content

Instantly share code, notes, and snippets.

View lukecav's full-sized avatar
🎅
The best way to spread Christmas cheer is singing loud for all to hear.

Luke Cavanagh lukecav

🎅
The best way to spread Christmas cheer is singing loud for all to hear.
View GitHub Profile
@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.
[{"id":"1","options":"a:403:{s:4:\"type\";s:4:\"post\";s:21:\"is_override_post_type\";i:0;s:15:\"post_type_xpath\";s:0:\"\";s:8:\"deligate\";s:0:\"\";s:11:\"wizard_type\";s:3:\"new\";s:11:\"custom_type\";s:7:\"product\";s:14:\"featured_delim\";s:1:\",\";s:10:\"atch_delim\";s:1:\",\";s:25:\"is_search_existing_attach\";s:1:\"0\";s:15:\"post_taxonomies\";a:1:{s:11:\"product_cat\";s:154:\"[{\"item_id\":\"1\",\"left\":2,\"right\":5,\"parent_id\":null,\"xpath\":\"\",\"assign\":true},{\"item_id\":\"2\",\"left\":3,\"right\":4,\"parent_id\":\"1\",\"xpath\":\"\",\"assign\":true}]\";}s:6:\"parent\";i:0;s:23:\"is_multiple_page_parent\";s:3:\"yes\";s:18:\"single_page_parent\";s:0:\"\";s:5:\"order\";s:1:\"0\";s:6:\"status\";s:7:\"publish\";s:13:\"page_template\";s:7:\"default\";s:25:\"is_multiple_page_template\";s:3:\"yes\";s:20:\"single_page_template\";s:0:\"\";s:15:\"page_taxonomies\";a:0:{}s:9:\"date_type\";s:8:\"specific\";s:4:\"date\";s:3:\"now\";s:10:\"date_start\";s:3:\"now\";s:8:\"date_end\";s:3:\"now\";s:11:\"cust
@danielbachhuber
danielbachhuber / wpnps-auto-clear-sessions.php
Created September 15, 2020 12:11
Automatically clear WP Native PHP Sessions older than 24 hours
<?php
add_action(
'init',
function() {
if ( ! wp_next_scheduled( 'pantheonx_clear_sessions' ) ) {
wp_schedule_event( time(), 'twicedaily', 'pantheonx_clear_sessions' );
}
}
);
<?php
/**
* Plugin Name: WooCommerce Remove Admin Version Option
* Plugin URI: https://woocommerce.com
* Description: Adds a tool to the WooCommerce > Status > Tools page to remove the woocommerce_admin_version option
* Author: WooCommerce
* Domain Path: /languages
* Version: 0.1
*/
@jchristopher
jchristopher / searchwp-customizations.php
Created July 7, 2020 11:46
Add support for WooCommerce Admin filters when searching Orders with SearchWP
<?php
// Add support for WooCommerce Admin filters when searching Orders with SearchWP.
add_filter( 'searchwp\query\mods', function( $mods, $query ) {
global $wpdb;
if ( isset( $_GET['_customer_user'] ) && ! empty( $_GET['_customer_user'] ) ) {
$mod = new \SearchWP\Mod( \SearchWP\Utils::get_post_type_source_name( 'shop_order' ) );
$mod->set_local_table( $wpdb->postmeta );
$mod->on( 'post_id', [ 'column' => 'id' ] );
@stevegrunwell
stevegrunwell / limit-orders-forever.php
Created June 19, 2020 14:48
Add a "Forever" option to Limit Orders for WooCommerce - https://wordpress.org/support/topic/all-time-interval/
<?php
/**
* Plugin Name: Limit Orders for WooCommerce - Never-ending Interval
* Description: Add a "Forever" option to Limit Orders for WooCommerce.
* Author: Nexcess
* Author URI: https://nexcess.net
*/
/**
* Add "Forever" to the list of intervals.