Skip to content

Instantly share code, notes, and snippets.

@wpmudev-sls
Last active April 25, 2024 07:50
Show Gist options
  • Save wpmudev-sls/577541a2dc1c150735f0a87136b9aca0 to your computer and use it in GitHub Desktop.
Save wpmudev-sls/577541a2dc1c150735f0a87136b9aca0 to your computer and use it in GitHub Desktop.
[Branda Pro] - Disable Email Template for WooCommerce Emails
<?php
/**
* Plugin Name: [Branda Pro] Disable Email Template for WooCommerce Emails
* Description: Disable Email Template for WooCommerce Emails.
* Author: Prashant @ WPMUDEV
* Task: SLS-6060
* Author URI: https://premium.wpmudev.org
* License: GPLv2 or later
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
add_action( 'woocommerce_email_header', 'wpmudev_remove_branda_email_template', 10, 2 );
function wpmudev_remove_branda_email_template( $email_heading, $email ) {
global $wp_filter;
$tag = 'wp_mail';
$hook_method = 'wp_mail';
$hook_class = 'Branda_Email_Template';
if ( ! isset( $wp_filter[$tag] ) ) {
return;
}
foreach ( $wp_filter[$tag]->callbacks as $key => $callback_array ) {
foreach ( $callback_array as $c_key => $callback ) {
if ( substr_compare( $c_key, $hook_method, strlen( $c_key ) - strlen( $hook_method ), strlen( $hook_method ) ) === 0 ) {
if ( $callback['function'][0] instanceof $hook_class ){
unset( $wp_filter[$tag]->callbacks[$key][$c_key] );
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment