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
@lukecav
lukecav / functions.php
Last active November 15, 2023 18:36 — forked from eteubert/wordpress-passwort-reset-unmultisite.php
WordPress Multisite: Password Reset on a Subsite.
/**
* Password reset on sub site (1 of 4)
* Replace login page "Lost Password?" urls.
*
* @param string $lostpassword_url The URL for retrieving a lost password.
* @param string $redirect The path to redirect to.
*
* @return string
*
* @since 1.0.0
@lukecav
lukecav / wc_auto_complete_virtual.php
Created August 4, 2023 13:51 — forked from jessepearson/wc_auto_complete_virtual.php
Auto Complete all WooCommerce virtual orders
<?php // only copy this line if needed
/**
* Auto Complete all WooCommerce virtual orders.
*
* @param int $order_id The order ID to check
* @return void
*/
function custom_woocommerce_auto_complete_virtual_orders( $order_id ) {
@lukecav
lukecav / gw-gravity-forms-prevent-duplicate-submissions.php
Created February 13, 2017 20:44 — forked from spivurno/gw-gravity-forms-prevent-duplicate-submissions.php
Gravity Wiz // Gravity Forms // Prevent Duplicate Submissions from Double Clicks
</php
/**
* Gravity Wiz // Gravity Forms // Prevent Duplicate Submissions from Double Clicks
* http://gravitywiz.com/
*/
add_filter( 'gform_pre_render', 'gw_disable_submit' );
function gw_disable_submit( $form ) {
if( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
return $form;
@lukecav
lukecav / functions.php
Created November 16, 2022 18:14 — forked from SiR-DanieL/functions.php
functions.php
/**
* Schedule the daily event if necessary.
*/
function schedule_delete_expired_coupons() {
if ( ! wp_next_scheduled( 'delete_expired_coupons' ) ) {
wp_schedule_event( time(), 'daily', 'delete_expired_coupons' );
}
}
add_action( 'init', 'schedule_delete_expired_coupons' );
@lukecav
lukecav / woocommerce-custom-cart-item-data.php
Created September 8, 2017 21:13 — forked from RadGH/woocommerce-custom-cart-item-data.php
Get and set custom cart item/product information prior to WooCommerce checkout, and carry those values over to Order Item Metadata.
<?php
// UPDATE: Stefan from Stack Overflow has explained a better way to handle cart item data.
// See http://stackoverflow.com/a/32327810/470480
// ----------------------
/*
Instructions:
@lukecav
lukecav / functions.php
Created June 22, 2017 16:01 — forked from corsonr/functions.php
Display WooCommerce product variations dropdown select on the shop page
<?php
// Display variations dropdowns on shop page for variable products
add_filter( 'woocommerce_loop_add_to_cart_link', 'woo_display_variation_dropdown_on_shop_page' );
function woo_display_variation_dropdown_on_shop_page() {
global $product;
if( $product->is_type( 'variable' )) {
@lukecav
lukecav / Command
Last active January 22, 2021 13:07 — forked from BronsonQuick/gist:5185918001f4df5c5d15
Delete ActionScheduler comments and scheduled-action post types in WooCommerce using WP-CLI
wp comment list --field=comment_ID --'comment_author'='ActionScheduler' --number=1000 | xargs wp comment delete --force
wp post list --field=ID --post_type=scheduled-action --posts_per_page=1000 | xargs wp post delete --force
wp post list --field=ID --post_type=scheduled-action --posts_per_page=1000 --post_status=trash | xargs wp post delete --force
wp post list --field=ID --post_type=scheduled-action --posts_per_page=1000 --post_status=cancel | xargs wp post delete --force
@lukecav
lukecav / woocommerce-remove-db-update-notice.php
Last active December 24, 2020 18:53 — forked from timmyc/woocommerce-remove-db-update-notice.php
Set WooCommerce database update notice as actioned
<?php
/**
* Plugin Name: Remove WooCommerce DB Notice
* Plugin URI: https://woocommerce.com
* Description: Clears out any pending WooCommerce DB Update notices
* Author: WooCommerce
* Domain Path: /languages
* Version: 0.1
*/
@lukecav
lukecav / custom-woocommerce-status.php
Last active December 15, 2020 17:54 — forked from faiyazalam/custom-woocommerce-status.php
This is a custom plugin for woocommerce. This will add some custom bulk action in order listing.
<?php
/**
* @package Custom_WC_Status
* @version 1.6
*/
/*
Plugin Name: Custom WooCommerce Status
Description: This is a custom plugin for woocommerce. This will add some custom bulk action in order listing.
Author: Luke Cavanagh
Version: 1.0
@lukecav
lukecav / functions.php
Created June 5, 2020 18:19 — forked from ChromeOrange/gist:0853adfb17f8c0e02a58ee8eb0d5fbaf
Add button to clear the WooCommerce logs in System Status Tools
// Uses apply_filters( 'woocommerce_debug_tools', $tools )
add_filter( 'woocommerce_debug_tools', 'woocommerce_debug_tools_remove_logs' );
function woocommerce_debug_tools_remove_logs( $tools ) {
// Disbale Remove Logs button
$disable_remove_logs = apply_filters( 'woocommerce_disable_woocommerce_debug_tools_remove_logs', FALSE );
if( !$disable_remove_logs ) {
$tools['remove_logs'] = array(