Last active
July 22, 2019 06:51
-
-
Save sanzeeb3/83660150780bc80f4457e1afd99fd611 to your computer and use it in GitHub Desktop.
Hides all admin notices in WooCommerce settings page.
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
<?php | |
add_action( 'admin_print_scripts', 'hide_admin_notices' ); | |
function hide_admin_notices() { | |
global $wp_filter; | |
if ( empty( $_REQUEST['page'] ) || 'wc-settings' !== $_REQUEST['page'] ) { | |
return; | |
} | |
foreach ( array( 'user_admin_notices', 'admin_notices', 'all_admin_notices' ) as $wp_notice ) { | |
if ( ! empty( $wp_filter[ $wp_notice ]->callbacks ) && is_array( $wp_filter[ $wp_notice ]->callbacks ) ) { | |
foreach ( $wp_filter[ $wp_notice ]->callbacks as $priority => $hooks ) { | |
foreach ( $hooks as $name => $arr ) { | |
unset( $wp_filter[ $wp_notice ]->callbacks[ $priority ][ $name ] ); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment