I don’t write technical blog posts super often these days – it’s usually things about coworking, communities building, culture development, or bootstrapping product businesses. But what the hell – this is my blog and I’ll do what I want.
Since the end of last year I’ve been happily using Barley for almost all of my WordPress-powered sites. It’s awesome.
But there’s one thing that wasn’t awesome: the guys at Barley decided that by default, the Barley editor should be “on”. And I get why: the whole idea is that you can just click on the page and boom, you’re editing.
But sometimes – and I found increasingly often while browsing one of my own sites for a link or a reference – the Barley editor got in the way when doing non-composing things. Most recently, as we moved Indy Hall’s members-only site into a WordPress-powered site, this problem surfaced once again.
I mentioned to Colin that having a toggle in the WordPress admin would be handy, but I also know that they have many things going on besides supporting me and my $12/year purchase of the Barley plugin.
Unfortunately, one of the functions that I needed to edit was this one:
The real problem, though, was that code wasn’t wrapped in the statement that ties a function into WordPress’s hook system. Editing the plugin directly meant losing my change every time Barley is updated and to the team’s credit (and in this scenario, my dismay)…that’s pretty often.
So, with the help of a longtime buddy and Indy Hall member Chris Morrell, I was able to override Barley’s defaults without directly editing the plugin.
The answer is to add the following code into your active theme’s functions.php file (and, if it doesn’t have one…create one).
Lines 3 and 4 were Chris’s clever contribution, essentially grabbing the querystring params and inverting them before Barley tries to consume them.
Line 6 un-hooks Barley’s built in override of the edit post link, which usually gives a logged-in user the ability to quickly jump to the edit screen in the WordPress admin. Normally, this Barley override adds a link to let you turn Barley OFF (like this)…but remember I wanted it off by default.
Lines 7-21 are a near-copy of the same code in Barley that I just unhooked, but with a couple of small edits that take the new default into consideration.
With those 21 lines of code dropped into your theme’s functions.php file, Barley’s default state is inverted just like I wanted: off by default, but ready for handy in-place editing with a single click.
Whatever you do, don't build your coworking community alone.
Join the 3000+ community builders who get my newest posts, lessons, stories, and tips like "How to fund your coworking space" and "Why I hate the title Community Manager"