You’re very welcome! I’m glad the explanation helped. Sometimes all it takes is looking at the problem from a slightly different angle before everything clicks into place.
I enjoy breaking down issues step by step, both here and over at Colordraws, so I’m happy the detailed explanation was useful. Best of luck with the project!
You’re running into this issue because the nonce you’re generating doesn’t match the one the plugin expects. In WordPress, nonces are tied to a specific action string, so using 'debloat' in wp_nonce_url() will only work if the plugin also uses that exact same action when creating and verifying the nonce. That’s why you’re getting the “link has expired” error.
The fix is to find the actual nonce action used by the plugin (usually in its source code where wp_nonce_url(), wp_create_nonce(), or check_admin_referer() is called) and use that exact action string in your code. Once you match it, your admin bar link should work correctly.
If you can’t find or match the nonce, another option is to hook into whatever function or action the plugin uses to clear the cache directly instead of relying on the URL.