Last active
August 22, 2025 15:53
-
-
Save jb510/c6899d3b9e33c4cbf53988efcb3a15ea to your computer and use it in GitHub Desktop.
nuke-jwt-auth-notices.php
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 | |
/** | |
* Plugin Name: Disable JWT Auth Admin Notices | |
* Description: Disables persistent admin notices from the JWT Authentication plugin v1.4.0 | |
* Version: 0.1 | |
* Author: Jon Brown | |
*/ | |
// Prevent direct access | |
if (!defined('ABSPATH')) { | |
exit; | |
} | |
/** | |
* Completely disable JWT Auth admin notices by removing the display action | |
*/ | |
function disable_jwt_auth_admin_notices() { | |
// Remove the admin notice display action from JWT Auth | |
remove_action('admin_notices', array('Jwt_Auth_Admin', 'display_all_notices')); | |
} | |
// Run early to ensure notices are disabled | |
add_action('init', 'disable_jwt_auth_admin_notices', 20); | |
/** | |
* Alternative approach: Force all JWT Auth notices to be considered dismissed | |
*/ | |
add_action('admin_init', function() { | |
// Get currently dismissed notices | |
$dismissed = get_option('jwt_auth_dismissed_notices', array()); | |
// Add common JWT Auth notice IDs to dismissed list | |
$jwt_notices = array( | |
'jwt_auth_welcome', | |
'jwt_auth_survey', | |
'jwt_auth_pro_promo' | |
); | |
// Merge and update dismissed notices | |
$updated_dismissed = array_unique(array_merge($dismissed, $jwt_notices)); | |
update_option('jwt_auth_dismissed_notices', $updated_dismissed); | |
}); | |
/** | |
* Filter to ensure no notices are registered | |
*/ | |
add_filter('jwt_auth_admin_notices', function($notices) { | |
return array(); | |
}); | |
/** | |
* Override the notice registration to prevent any notices from being added | |
*/ | |
add_action('admin_menu', function() { | |
// If the Jwt_Auth_Admin class exists, override its notice system | |
if (class_exists('Jwt_Auth_Admin')) { | |
// We can't directly modify the class, but we can filter its behavior | |
add_filter('jwt_auth_should_display_notice', '__return_false', 999); | |
} | |
}, 999); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment