stellarwp / admin-notices

A handy package for easily displaying admin notices in WordPress with simple to complex visibility conditions
MIT License
8 stars 0 forks source link

Refactor: use namespacing in JS and persistence #1

Closed JasonTheAdams closed 2 days ago

JasonTheAdams commented 4 days ago

Prior to this PR, the JS was open to collisions with other plugins. It wasn't namespacing the functions and such properly, so it would've caused issues if multiple plugins were using different versions of this package. It also was only kind of namespsacing things within persistence, in a more complicated way.

In this PR, namespacing is added to the JS and attributes used to identify the notice. This way the plugin using the package will only ever affect it's own notices.

It also updated the way persistence worked. Now, within the user preferences meta, the root key is stellarwp/admin-notices-$namespace. This means that the stored notification ids no longer need to be namespaced (saving a bit of room), and the user's notices can be reset simply by removing the array as a whole.

All in all, this makes the package better at avoiding plugin conflict and simplifies the persistence of dismissed notices.