Skip to content

Instantly share code, notes, and snippets.

@sanzeeb3
Last active July 22, 2019 06:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sanzeeb3/83660150780bc80f4457e1afd99fd611 to your computer and use it in GitHub Desktop.
Save sanzeeb3/83660150780bc80f4457e1afd99fd611 to your computer and use it in GitHub Desktop.
Hides all admin notices in WooCommerce settings page.
<?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