Fixed Admin Menus — The Plugin Expanded

   Posted by: BJ Johnson in plugin, WordPress

Short time between initial plugin release and the first update but it had to be done... and quick. Downloads of the first Admin Menus Fixed version were chugging along nicely for a number of days, with no reports of bugs, etc. Then, while researching why Popular Posts was suddenly returning no results by deactivating recently updated plugins, one-by-one, to try to sort out if there were a conflict, I found one myself. Always better that way than a user in trouble.

I got down the list to Ozh' Admin Drop Down Menu and almost skipped over it, thinking that it surely wouldn't interact with Popular Posts, but decided to be thorough. Bam! As soon as his plugin deactivated it left mine running and locked me out of the Plugins page. I was testing for the existence of one of his functions in the running code and if it was not found, my plugin would not start; outputting an error message stating that Ozh's plugin had to be activated. That works great for the activation part but the deactivation part was disastrous, well, not all that disastrous but disconcerting, nonetheless. If they are deactivated in the correct order, dependent then parent, everything goes smoothly. Reverse the order and you are met with a nice blank screen with my error message and that's it. Refreshing the page returns the same blank screen. Rats! Renamed the directory it lives in, so that WordPress would auto-deactivate because it couldn't find the plugin, and I was quickly back in business looking for ways to prevent this happening. Started to approach the problem from a dependency angle to auto-deactivate if it doesn't find the correct environment but soon came up empty, at least as far as getting an update quickly pushed to the Plugin Directory. Along the way, I looked at it from a different angle, took a different approach and proved that there are silver linings and lemonade. Instead of limiting the plugin to only work within a tight set of constraints, I explored expanding its range to embrace the entire WordPress 3.1 Admin Menu structure; no matter what combinations of menus and bars a user may prefer. This then eliminated the test for an existing function to be able to start and, thus, eliminated the deactivation sequence problem altogether. It's not Rocket Surgery. Four nested IF's and I'm outtathere.

As the WordPress tagline goes: Code is Poetry and I say: Lean Code is Poetry in Motion. I believe I still hold the record at RIT for the fewest statements required to run a test problem in Fortran.

Now, the plugin does this: All Three Menus Stacked, Compressed and Fixed All Three Menus Stacked, Compressed and Fixed
Admin Bar On Ozh' Admin Drop Down Menu On
Admin Bar Off, Menus Stacked, Compressed and Fixed Admin Bar Off, Menus Stacked, Compressed and Fixed
Admin Bar Off Ozh' Admin Drop Down Menu On
Admin Bar On, Admin Menu Stacked, Compressed and Fixed Admin Bar On, Admin Menu Stacked, Compressed and Fixed
Admin Bar On Ozh' Admin Drop Down Menu Off Main Navigation On
Admin Menu Compressed and Fixed Admin Menu Compressed and Fixed
Admin Bar Off Ozh' Admin Drop Down Menu Off Main Navigation On
I love it when a plan comes together. Solved a natty problem and made it more functional. Sequence or combination matters no longer. It's actually fun to watch it work. Well, it is for me, anyway. Check it out. Let me know how it works for you and if there's anything I could improve upon.

Download the latest version at The Plugin Directory.

I hope you enjoy it. And, as always, Thanks to Ozh for encouraging me to jump in and write this. I've got a lot to learn to even approach where he is in PHP but, ya gotta start somewhere. May as well be something fun (and small). If you have feedback, a support request or just wish to ask a question about this plugin, please enter a comment. And, if you'd like to help a real starving artist, please buy us some cat food for our Bengal and Maine Coon rescues. Thank You.

Tags: , , , ,

Short URL for this post: //
More from “The Art & Engineering of B.E.Johnson”right-filler-bar

Post Your Response:

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright © 1976-2024 The Art & Engineering of B.E.Johnson