Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Removes buttons from WooCommerce notices
<?php
add_action( 'init', 'cameronjonesweb_remove_button_from_notice_setup' );
function cameronjonesweb_remove_button_from_notice( $message ) {
$message = preg_replace('#<(a)(?:[^>]+)?>.*?</\1>#s', '', $message );
return $message;
}
function cameronjonesweb_remove_button_from_notice_setup() {
$notice_types = apply_filters( 'woocommerce_notice_types', [ 'error', 'success', 'notice' ] );
if ( ! empty( $notice_types ) ) {
foreach ( $notice_types as $notice_type ) {
add_action( 'woocommerce_add_' . $notice_type, 'cameronjonesweb_remove_button_from_notice' );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.