Skip to content

Instantly share code, notes, and snippets.

@Asikur22
Created May 7, 2023 18:25
Show Gist options
  • Save Asikur22/30b70bc5cc8ed22f21d42f4d42d3538b to your computer and use it in GitHub Desktop.
Save Asikur22/30b70bc5cc8ed22f21d42f4d42d3538b to your computer and use it in GitHub Desktop.
Remove Filter Hook Forcefully
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