Created
November 1, 2017 23:25
-
-
Save ann71727/013aaca722f141edf1c86c1598fcac41 to your computer and use it in GitHub Desktop.
WordPress remove all notice and warning with user role editor
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 | |
/** | |
* WordPress remove all notice and warning with user role editor | |
* https://v123.tw | |
*/ | |
add_filter('ure_role_additional_options', 'ure_add_block_admin_notices_option', 10, 1); | |
function ure_add_block_admin_notices_option($items) { | |
$item = URE_Role_Additional_Options::create_item('block_admin_notices', esc_html__('Block admin notices', 'user-role-editor'), 'admin_init', 'ure_block_admin_notices'); | |
$items[$item->id] = $item; | |
return $items; | |
} | |
function ure_block_admin_notices() { | |
add_action('admin_print_scripts', 'ure_remove_admin_notices'); | |
} | |
add_action('admin_print_scripts', 'ure_remove_admin_notices'); | |
function ure_remove_admin_notices() { | |
global $wp_filter; | |
if (is_user_admin()) { | |
if (isset($wp_filter['user_admin_notices'])) { | |
unset($wp_filter['user_admin_notices']); | |
} | |
} elseif (isset($wp_filter['admin_notices'])) { | |
unset($wp_filter['admin_notices']); | |
} | |
if (isset($wp_filter['all_admin_notices'])) { | |
unset($wp_filter['all_admin_notices']); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment