Created
January 28, 2019 11:23
-
-
Save cameronjonesweb/d82aa96684455814d06e8e4ee866bf67 to your computer and use it in GitHub Desktop.
Removes buttons from WooCommerce notices
This file contains 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
<?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