Created
May 7, 2023 18:25
-
-
Save Asikur22/30b70bc5cc8ed22f21d42f4d42d3538b to your computer and use it in GitHub Desktop.
Remove Filter Hook Forcefully
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function remove_obj_filter_forcefully( $tag, $callback, $priority = 10 ) { | |
global $wp_filter; | |
$my_filter = $wp_filter[ $tag ]; | |
if ( isset( $my_filter ) ) { | |
$callbacks = $my_filter->callbacks; | |
if ( ! empty( $callbacks ) ) { | |
foreach ( (array) $callbacks[ $priority ] as $filter_callback ) { | |
if ( in_array( $callback, $filter_callback['function'] ) ) { | |
$my_filter->remove_filter( $tag, $filter_callback['function'], $priority ); | |
} | |
} | |
} | |
} | |
} | |
// uses | |
remove_obj_filter_forcefully( 'woocommerce_get_item_data', 'prefix_get_item_data' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment