Freelancers panel this Thursday

I’m going to be on a panel about freelancing on Thursday, an event put on by UXUp. You can see the details and get a ticket here.

If you know someone interested in freelancing or quite new to it, or indeed if you are that person, come along! Especially if you work in User Experience.

It’s in the Pull and Pump events room, 6:30pm on Thursday 30th Jan. Tickets are £3 to cover UXUp’s expenses.

Thanks to UXUp for inviting me along!

WordUp Brighton – WordPress Gems for Devs by Milana Cap

Last Tuesday I attended the WordUp Brighton WordPress meet up in Freedom Works Brighton. They had a talk from Milana Cap, a very active WordPress developer, covering recent additions to WordPress that developers may not know about. Milana streamed the talk from her home in Serbia and a copy of the talk is up on the Silicon Brighton YouTube channel.

WP HTML Tag Processor

First we were shown an example of using WP HTML Tag Processor, which lets you easily parse HTML within WordPress.

Milana used an example of spotting and removing “nofollow” from internal links which were to versions of the domain that didn’t match the set domain of the WordPress site. This was quite useful as it allowed her to show us a way the code could help in quickly parsing and changing some of the content of blog posts, but it was also a bit distracting as it’s the sort of problem I’d personally fix via updates to the database once, rather than having to run a fix every time a page loads, and that kept tripping me up while I was trying to think of ways I’d actually use HTML Tag Processor within the projects I do.

WP HTML Tag Processor looks like it could be useful and reminds me of Simple HTML DOM, a more general PHP HTML parser that I’ve used in a few projects in the past.

Interactivity API

The bulk of the talk was showing us ways to use the WordPress Interactivity API.

As I now understand it, this allows you to write PHP code within the WordPress block system and the API then builds/accesses various Preact Javascript code to do the interactivity part that you want. So, it sets up AJAX calls, shares data around, and live updates the page, all for you from quite a small amount of PHP. Milana built a simple example of this for us, and kindly linked out to some other examples from the documentation she’d put together for the talk.

I think this is potentially going to be very, very helpful for when I’m building interactive elements within a WordPress project as it’ll save me the time of writing Javascript code to handle AJAX, and API endpoints, by having all that code created by WordPress itself. It’s going to be very interesting to explore what the Interactivity API can do to help add small things to a project, e.g. search autocomplete, something I put in quite often but can be a bit of a faff to add.

Hopefully, the Interactivity API will catch on, which will make long term maintenance of sites and plugins more straightforward as they can use this within WordPress, rather than a site having multiple versions of jQuery, Vue or whatever.

Learning from learning

For me, watching live coding after a long day working on client projects was difficult. It did show us how little code needs to be written to get useful activity on the page, but I’d honestly have been fine with being shown a pre-built version and talked through what it was doing. By the end of the talk I was a bit torpid as I tried to process what we’d seen and come up with uses for it, and couldn’t think of any questions to ask, even though this is a really interesting feature that I hadn’t heard about.

I don’t mean this as a criticism of Milana, she was giving up her evening to present the talk to us and that was fantastic of her. This is a note to myself that if I’m going to an evening talk, I need to balance out what I’m doing during the day so I’ve enough mental energy to really process what I’m watching. I’ve got notes, but being able to understand more about what was going on with the code as I was watching would have been helpful.

Thanks

Big thanks to Milana for showing us these features, both of which I knew nothing about and could have missed out on using, and thanks to Paul Bunkham and Sim Brody for organising WordUp Brighton.

My UK freelancer forum on Reddit hits 6,000 members

I run a small “sub-Reddit,” a community within the site Reddit, for UK freelancers. Today I noticed it had hit 6,000 subscribers, which is a nice big, round number.

When I agreed to help moderate the community, there were 53 subscribers. That was back in September 2013, so growth hasn’t been massive or quick, but I also haven’t put a great deal of effort into it, so I think that’s absolutely fine.

Screenshot of Reddit showing the old interface and the area freelanceuk, which is at 6,000 subscribers

History

Originally, I responded to the previous moderator who was asking for help as I didn’t want the “sub” (subsection of Reddit, basically a forum) to die off. It turned out he wanted to leave moderation of it entirely, but the tasks were not onerous so I kept it up. I thought it would be a useful place to get inspiration for help pages for the Farm’s website. I haven’t done too much of that, but writing this did prompt me to request a file of all of my Reddit contributions so I can extract the useful bits more easily than trawling through my comments on Reddit itself.

Reddit as a place to be

To be honest, I don’t like Reddit much any more. Like any very large forum-style site on the web, it has a large share of absolute bellends difficult people with offensive views, which in the past the site management did very little to control, but it also had pockets of loveliness and the sub-section for talking about written science fiction particularly filled a hole for me left when Usenet became harder to access, and has managed to stay decent for many years. But the Reddit management has been making choices I’d rather they didn’t for a long time, most recently stopping free API access for mobile apps and making that access extremely expensive to force everyone to use their own apps, and now selling everything people contribute to Google for their use training their LLM (AI) project.

Long term I’d like to move off Reddit, but I haven’t had time to set up an alternative, and I know it will get less use. FreelanceUK has added about 2,000 members in the last year and a half. That’s because Reddit is a very popular site. Moving off to my own space will not get that sort of traction without a hell of a lot of effort, I’ve got it on Reddit just by removing some junk posts and answering questions that I can answer.

Running and growing a small sub-Reddit

The running part is quite easy as this is a niche interest so there isn’t a lot of spam or heated arguments, it comes down to:

  • Have some clear rules about what can be submitted
  • Check all submissions, ban people who submit spam the first time they submit it. Warn people who post borderline stuff but are probably a bit clueless in a comment, and remove their post which takes it out of view
  • If people end up arguing with each other, step in and suggest they just leave it as they’re not convincing each other, mark your own post as a moderator so they take the advice seriously. Almost always, they’ll stop. Sometimes, they even apologise to each other (this may be a British trait.)
  • Don’t get angry when people don’t like what you post yourself

On this last point – I occasionally submit links to what I think is an interesting article or tool. Often these get downvoted. It really doesn’t matter. People’s reasons for downvoting are myriad, don’t let it get to you.

I use an RSS Reader on my phone to check for new submissions to FreelanceUK. That lets me catch and remove spam pretty early, and that helps keep the forum professional looking. Spam breeds spam, so it’s best to get rid early. I find it very difficult to use the mobile version of Reddit to ban spammers, so often it’s a case where I’ll remove their post, then ban them when I’m next on my computer. Banning only stops them posting to my little area of Reddit, they’re free to use the rest of the site as usual.

Growth is harder. I have found people respond best to posts on Reddit itself. They don’t want to follow a link to somewhere else, they want to consume right where they are, and I think social media is the same way – people would rather read a screenshot of something within the site/app they’re using rather than click through to somewhere else where it would be easier to read.

I’ve made some posts on Reddit of content I’ve written for this blog or the Farm website, but mainly what I’ve done is answer questions. If someone has a question about freelancing that I can answer, I do so. Now the forum is bigger, if I’m busy I’ll leave it for a while and often a member will give a good answer and I won’t have to, but if it’s been a long time, like a day or two, and no one has answered, I will find the time.

I will upvote people’s questions and the good answers, even if it means Reddit will boost their answer over mine. The “karma” system of points within Reddit doesn’t really mean anything, but we are all distractible chimps at heart and it doesn’t cost anything for me to give people a little boost in their day by seeing someone appreciated their comment.

That’s basically it – keep things civil and on topic, be helpful. It means growth is slow, but I can keep it going without much effort and it can be a helpful place to people. I don’t need it to be more than that. A small, low maintenance project that helps people doesn’t need to become something bigger or “better,” it can just be what it is.

Whitelisting an email or domain in Mailgun

Recently a client who uses Mailgun to send email from their website had a problem where one of the clients own email addresses had been “suppressed” in Mailgun, meaning Mailgun would no longer send email to that address. It was caused by the client’s mail server having a problem for long enough that Mailgun decided they couldn’t send email to the particular address.

Mailgun have the ability to “whitelist” individual email addresses or whole domains so they will not stop sending to them. That’s exactly what I needed to put in a long term fix for this problem. It’s not available through their website, but you can do it through their API. That was fine, we’re using the API for other things so I can adapt some code to use it for this.

Unfortunately, the docs for whitelisting an email address are currently incorrect. I had some back and forth with their support people and they gave me the following curl example for how to whitelist an email address:

curl -i -X POST  -u api:[your api key] https://api.eu.mailgun.net/v3/[your mailgun domain]/whitelists -F address=[your email address]

Where [your api key] and [your mailgun domain] and [your email address] get replaced by your details.

Remember that if you’re in Europe, you’re probably using the EU API, not the one in the docs, so you’ll need to change the API domain to https://api.eu.mailgun.net

To whitelist a whole domain, use:

curl -i -X POST  -u api:[your api key] https://api.mailgun.net/v3/[your mailgun domain]/whitelists -F domain=[your email domain]

Finally, to check the whitelist, use this:

curl -i -X GET  -u api:[your api key]  https://api.mailgun.net/v3/[your mailgun domain]/whitelists

This was a frustrating situation as it took a while for their support to understand that giving me back the incorrect examples from the docs wasn’t helping, but they did come through for us in the end and were polite and trying to be helpful throughout. Hopefully they’ll get their docs updated soon.

Using ACF Blocks by default in a new post in WordPress

One of my clients has a website using Advanced Custom Fields (ACF) Blocks to style everything in the site, including their News section.

To make a new post in News, they had to load a Pattern of the relevant Blocks. This being a multi-step process, and a bit annoying if you just want to get on with posting your article, I looked for a way to load the blocks into the new post by default.

You can do this by putting this code in your functions.php (with amends explained below)

function site_post_register_template() {
    $post_type_object = get_post_type_object( 'post' );
    $post_type_object->template = array(
        array( 'my-blocks/news-header' ),
        array( 'my-blocks/news-article' ),
        array( 'my-blocks/news-article-related' ),
    );
}
add_action( 'init', 'site_post_register_template' );

In this case, I have three Blocks loading – the specific header, the article, and a strip of related articles. I can load in as many Blocks as I want.

To make this work for you, find where you have saved your blocks and list them out in the same way, in an array for each.

You will have to change ‘my-blocks’ to the prefix of your ACF Blocks. To find that prefix, go to the directory where you store the code for the relevant Block and open the block.json file. Copy the details from the “name” line to be inside the array( '' ), above.

Now, when a new Post is started, it automatically loads in the ACF Blocks and my client can get on with posting their news, not thinking about how they load in the Pattern and where they left my instructions for doing so.