joeguilmette / wp-local-toolbox

A simple plugin to set different defaults for local, staging and production servers.
GNU General Public License v3.0
78 stars 13 forks source link

Admin bar colors and Welcome message for admins only #24

Open jb510 opened 8 years ago

jb510 commented 8 years ago

Not sure about you, but I keep WPLT on the repo across local/dev/staging/live.

We've got a few multi-author and membership sites....

Just updated to the latest version of WPLT and realized ALL users were seeing a "Welcome to WP Local Toolbox message" and then when I defined WPLT_SERVER, they all got a red admin bar and "LIVE" in the bar.

Seems like we should either:

  1. Only show the bar change and welcome message to admins
  2. Have a configurable user role level that sees the bar change & welcome message.

I've never needed anyone but an admin to see it, so I lean toward #1. However I could see wanting editors or some other role to know which server they were on.

thoughts?

joeguilmette commented 8 years ago

Oh, gross. #1 is definitely simpler, so I prefer that. If I remember correctly the welcome message sucked, feel free to gut it. On Sat, Jul 16, 2016 at 10:11 AM Jon Brown notifications@github.com wrote:

Not sure about you, but I keep WPLT on the repo across local/dev/staging/live.

We've got a few multi-author and membership sites....

Just updated to the latest version of WPLT and realized ALL users were seeing a "Welcome to WP Local Toolbox message" and then when I defined WPLT_SERVER, they all got a red admin bar and "LIVE" in the bar.

Seems like we should either:

  1. Only show the bar change and welcome message to admins
  2. Have a configurable user role level that sees the bar change & welcome message.

I've never needed anyone but an admin to see it, so I lean toward #1 https://github.com/joeguilmette/wp-local-toolbox/issues/1. However I could see wanting editors or some other role to know which server they were on.

thoughts?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/joeguilmette/wp-local-toolbox/issues/24, or mute the thread https://github.com/notifications/unsubscribe-auth/AGRsRF-fa1b3_y7iJ7SO6VAKTCRE22ZAks5qWRDVgaJpZM4JODZV .

jb510 commented 8 years ago

I tried doing iis_super_admin(), but from mu-plugins wp_get_current_user() isn't defined yet so fatal for undefined function. I'm not sure it's possible to check a user role in mu...

but I also found a "workaround"

define('WPLT_SERVER', ' '); define('WPLT_COLOR', 'null');

That'll have WPLT_SERVER defined but doesn't put anything in the bar, and it still removes 'Howdy'. 'null' is an invalid color, so CSS just reverts to the parent (interestingly, 'inherit' didn't work there if you're wondering why I didn't do that).

The latter also means user selected color schemes work.

joeguilmette commented 8 years ago

25 is relevant to this discussion...

when I defined WPLT_SERVER, they all got a red admin bar and "LIVE" in the bar.

Maybe the solution is to add a flag, like WPLT_ROLE, where if defined bar changes and admin notices will only be shown to that role? We could make it take an array or something so that you can add multiple roles if desired.

But... now that I think about it, if this is running as an mu-plugin we can't detect the role anyway, right?