This post is sort of a recap of a talk I gave a couple years ago.
Whenever you get a WordPress code snippet, where do you put it? It’s not uncommon all those bits of code to end up cluttering up the functions.php file of your theme, whether out of habit or suggested by tutorials.
But wouldn’t it be better if all those non-theme snippets were plugins instead? Yes!
As plugins, you can switch/upgrade themes without losing that functionality and toggle the funtionality without editing the theme.
And great news! It’s really easy to turn a snippet into a plugin.
Some times a client will complain that their site doesn’t look right or something equally as vague. Inevitable we ask “What browser are you using?” but getting the answer can be tricky. So, let’s just automatically get their user-agent and save it where we can access it.
Granted, this isn’t perfect. The client could have just logged in from someone else’s computer, and it is possible to fake the user-agent… but I’m counting on this being rare.
In WordPress 3.1, the network-wide options being moved to their own area in WordPress to make it easier on network administrators.
To take a just a bit further, I put together this script that will switch color schemes when you’re in the Network Admin.
If you’re running a WordPress network, and depending on how you’re using it, you may need to get users to confirm or update their email address.
In my situation, I build a lot of sites for clients, and during development I use an email address of my own so they don’t get bombarded with emails they don’t need. But I don’t always change it back when I’m done, or maybe there’s a typo. Or maybe it’s the client that has changed their email address.
Whatever the cause, sometimes these things just need to be double-checked and confirmed. So here’s a small plugin that can be dropped in your mu-plugins folder:
Grabs the site ID and puts it by the “Howdy” greeting in the upper right hand corner of your WordPress dashboard.
For super admins it’s a link, for regular admins it’s plain text. (more…)
I’ve got nothing against the “Howdy” greeting in WordPress, but in case you do, this little snippet might just help you out.
It’s currently set to change “Howdy” to “Yo.” Just drop this in your functions.php file. I’ll turn it into a spiffy plugin later… (more…)
If you’re trying to style nested items in
wp_list_pages() the task can be daunting. You’ll apply a style to an
<li> then have to unapply those styles for the nested
<li>s, and if you’re dropdowns get any deeper, you CSS can become overwhelming. It’s a little better if you don’t care about IE, because then you can use those fancy CSS selectors like
ul > li, or
ul li > li to target certain depths. But if you’re stuck fighting with IE, maybe this will help.
Earlier I shared my empty plugin code. Great for a quick test or maybe even as a starting point for an awesome new plugin. I’ve decided that I also need one for a widget, so here’s that: (more…)
Just a shell of a plugin for quick testing. Doesn’t do anything out of the box except create a page under Settings called “Empty Plugin”.