Skip to content

Instantly share code, notes, and snippets.

View carazo's full-sized avatar

Francisco Javier Carazo Gil carazo

View GitHub Profile
@hellofromtonya
hellofromtonya / hard-unregister.php
Last active June 7, 2019 21:40
Hard Unregister for an Object's callback where you do not have access to the instance itself.
/**
* Do a hard unregister of an object's callback for the specified event name
* and priority level.
*
* In WordPress, the callback key (or unique ID) is generated using the hash ID of
* the object concatenated with the method name. In the event that you do not have
* the object itself, then we use this hard approach to first first the callback
* function and then do the remove.
*
* This process works for both filter and action events.
@tripflex
tripflex / functions.php
Last active February 13, 2024 19:03
WordPress Remove Filter (remove_filter converted to remove_class_filter) to remove Filter/Action without Class Object access. Works with WordPress 1.2+ (4.7+ support added 9-19-2016)
<?php
/**
* Make sure the function does not exist before defining it
*/
if( ! function_exists( 'remove_class_filter' ) ){
/**
* Remove Class Filter Without Access to Class Object
*
* In order to use the core WordPress remove_filter() on a filter added with the callback
@RadGH
RadGH / woocommerce-custom-cart-item-data.php
Last active November 16, 2023 15:16
Get and set custom cart item/product information prior to WooCommerce checkout, and carry those valus 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: