Category: Meta

  • WordPress block theme issue – solved!

    WordPress block theme issue – solved!

    What a difference a day makes! Overnight a very kind person from cyberia/eu answered my Mastodon plea and gave me multiple ways to achieve my goal. They also confirmed that my problem with the custom shortcode approach is a current known bug in WordPress core.

    Since I already had the child theme set up, I followed their advice to use the new Block Bindings API. I made one small change in the callback function to check if the user is logged in before displaying the link. It works perfectly! No need for the Tampermonkey hack anymore. 🙂

    For the sake of posterity, here’s what I put in functions.php:

    <?php
    add_action( 'init', function() {
      register_block_bindings_source( 'webgoddess/edit-link', array(
        'label' => __( '[Edit]', 'webgoddess' ),
        'get_value_callback' => 'webgoddess_editlink_binding'
      ));
    });
    
    function webgoddess_editlink_binding() {
      if (is_user_logged_in () ) {
        return '<a href="' . get_edit_post_link($post->ID) . '">[Edit]</a>';
      } else {
        return;
    }
    ?>

    And here’s what I put in my template where I wanted the link to appear:

    <!-- wp:paragraph {"metadata":{"bindings":{"content":{"source":"webgoddess/edit-link"}}}} -->
    <p>[Edit]</p>
    <!-- /wp:paragraph -->
  • Editing the WordPress Twenty Twenty-Five Theme

    Editing the WordPress Twenty Twenty-Five Theme

    Edited 11/05/2025: Solved thanks to a very kind person on Mastodon! Head here if you want to see the answer to my frustrations below.

    Or rather, trying to edit the theme and tearing my hair out for multiple hours… but I’m getting ahead of myself.

    I’ve been using WordPress for ten years now. I use it to run two sites with thousands and thousands of pages and posts. I’ve customised child themes. I’ve written my own functionality with PHP and WordPress shortcodes. What I’m trying to say is: I’ve got some experience. It’s not my day job, but I’m not an idiot.

    In 2018 WordPress introduced a new default editor called Gutenberg that was a much more visual, drag-and-drop interface. I hated it. Pretty much everybody hated it. I installed the Classic Editor plugin and never looked back.

    Last year after I quit my job I decided to devote a bit more time to my sites, especially this blog. I started with a visual refresh, and I decided to bite the bullet and use the very latest default theme – Twenty Twenty-Five. It’s a “block theme,” and it took me a while to get my head around making changes in the Site Editor rather than in a child theme. But making changes was fast, and I got the site mostly looking the way I wanted it. I was reasonably happy.

    This year I started a project to clean up my archives, which I call “tending my digital garden.” Every day I go to this page, which shows me all the posts for that calendar day going back 25 years. I scroll through them and look for stuff like broken links, missing tags and categories, malformed HTML. When I find one of them, I open it in the editor to fix it. This requires two clicks: 1) on the post title to open it in a new tab, and then 2) the “Edit Post” link in the admin toolbar. While this doesn’t seem like a lot, I’ve been doing it for hundreds of posts, every day since February. It adds up.

    On my previous theme (Twenty Sixteen), each post had a little “Edit” link that would appear if you were logged in. You can see an example on my Roald Dahl site, which still uses that theme. So why doesn’t Twenty Twenty-Five?!

    A screenshot from a post on RoaldDahlFans.com, showing an Edit link beneath a post

    Today I decided I’d had enough, and it was time to figure out how to add it in. Very quickly I found this page: How to Add an Edit Post Link to WordPress Posts and Pages. It’s clear that there’s an existing WordPress core function that does exactly what I need: edit_post_link. All I needed to do was figure out how to get that into my template, and it should just work, right? Except not.

    1. I’ve worked with child themes before, so I started by creating a child theme for Twenty Twenty-Five. To my surprise, when I switched over to it, I lost all formatting and styles on the site. All of those changes I made in the Site Editor are saved in the database and only apply to the parent theme, not the child. WTF THAT SUCKS. There was no way I was going to recreate all that work, and I didn’t fancy the idea of trying to edit the database directly to reassign the saved configuration to a new theme. Let’s try the other option.
    2. I installed the WP Code plugin and found that it already has a built-in snippet that consists solely of edit_post_link. Perfect. You have two options of how to insert it: you can have it automatically appear at designated spots (like before or after a post excerpt), or you can use it as a shortcode.
      1. I started with the automatic locations. No matter which option I selected, the Edit link would either not appear or appear at the very top of the site (i.e. not attached to the post). It seems like however the plugin is determining the location just doesn’t work with the Twenty Twenty-Five theme.
      2. I switched over to the shortcode approach and added the shortcode to my template (using the Site Editor and the Shortcode block) below each post in the loop on the Archive page. When I viewed it, it looked like it worked! Every post had an Edit link at the bottom. However, I noticed quickly that all of them had the same postID, the very first one in the loop. It was clear that the context of the current post was not being picked up. That’s fine; I saw in the documentation that that you can supply a post ID to edit_post_link. Folks, I tried multiple different ways of getting the post ID in there and nothing worked. So this method was a bust.
    3. I went back to the child theme. I found a plugin called Create Block Theme that would clone your current theme AND all your Site Editor changes into a new child theme. I tried it out and it worked perfectly! I now had a child theme of Twenty Twenty-Five and could make changes directly to the templates in the code. Great. I connected to my host and started looking at the files… and for the life of me, I could not figure out where the hell to actually make my change. Block themes seem to use HTML files as well as PHP. I tried editing template PHP files; I tried adding things to functions.php. I just could not get it to work.

    I asked Mastodon for help. I mostly got replies from people who misunderstood what I was trying to do or thought I was an idiot who couldn’t see the “Edit post” link in the toolbar. 🙄

    Time for the nuclear option – I got Rodd and walked him through the problem, which meant painstakingly taking him through every bit of research I’d done and which options I’d tried and showing him how they didn’t work. He had some more ideas that we tried – including making a custom block type – but every approach either didn’t work or was way complicated for something that should be EASY. In fact, it should be BUILT-IN. Why the hell isn’t it included in this theme?!

    In desperation I thought about doing it on the frontend. Maybe I could write some Javascript that would scrape the links on the post and… DUH, TAMPERMONKEY. I installed it and got it set up, and then pulled in Rodd for his superior DOM manipulation skills. Here’s our quick and dirty solution:

    (function() {
       'use strict';
    
       document.querySelectorAll('.wp-block-post-date').forEach((el)=>{
          const a = document.createElement('a')
          a.href = '/wp-admin/post.php?action=edit&classic-editor&post=' + /archive[/](\d+)/.exec(el.querySelector('a').getAttribute('href'))[1]
          a.appendChild(document.createTextNode(' [Edit]'))
          el.appendChild(a)
       })
    })();
    

    Rodd thinks there are probably more elegant ways to do this, but it works. We look for posts with dates that contain a link, pull out the post ID with a regular expression, and add in a new appropriate “[Edit]” link. It works great, and it’s going to make my daily blog cleanup a lot faster!

    A screenshot of web-goddess.org showing an [Edit] link next to the post date

    If you know of how to edit the Twenty Twenty-Five child theme to include this, please let me know as I’d love to know how it’s actually meant to be done…

  • Highlights from the w-g archives

    On this day

    • in 2015 I went to a tech meetup that Dropbox were holding in a Sydney laneway, and I learned about an Aussie startup called Canva. I introduced myself to founder Cliff, did some research over the next week, and decided to talk him into hiring me. Two months later I was working there. It may well have been the most significant meetup of the hundreds I’ve been to over the years!
    • in 2009 the Sydney CBD experienced a major power outage. It was a turning point in my relationship with Twitter, as the locals were having a lot of fun positing that zombies were running amok in the city. I jumped in and never looked back. (Well, until the end of 2022.)
    • in 2007 Kim and Kelley Deal came into the knitting shop where I worked, and I didn’t even recognise them at first! Thank goodness my crappy mobile phone had a camera on it.
    • in 2003 I knitted a bikini. No, I never wore it. Knitted bikinis look flattering on approximately 0.2% of the population.
  • Facebook Import

    As I did with Instagram and Twitter, I’ve spent the last couple of days importing all of my posts from Facebook to this blog. Similar to those projects, I requested my archive in JSON format and then used an Apple Shortcut to parse it and upload via the WordPress API. The Shortcut is very similar to the one I used for Instagram, but with a few more edge cases and IF statements since FB allows for more post types than just images. (I’m not going to bother sharing it. If you were clever enough to follow the other two Shortcuts, you can figure it out.)

    My earliest post was from 2007, and all together I had 4,083 days worth of posts to import. I only synced images to WordPress; I haven’t touched any videos yet (but I never really uploaded many of those to FB). It took me just short of 29 hours spaced out over the course of a week, not counting the time I spent manually reviewing and cleaning things up. (I deliberately slow down the API requests to avoid DDoSing my own site.)

    And it bears repeating: Facebook’s data archive sucks. A brief list of problems I encountered:

    • Blank status updates. This happened a lot more in the older data.
    • Missing data when I “shared a Page/post/photo/link/video/event” from Facebook itself. This happened a lot more in the older data.
    • Missing data when posting from other sites/apps, like Eventbrite, Foursquare, Tweetdeck, Spotify, Meetup, Runkeeper, etc. This happened a lot more in the older data.
    • Duplicated content – there would be a “Kris Howard shared a link” item with a URL, and then a matching status update where I actually shared the URL. This happened a lot more with the data in recent years.
    • URLs that I’m fairly certain I shared in comments on posts, but included as top-level items with zero context. This happened exclusively with data from the past couple years.
    • Inconsistent links to FB users – most of the time when I tagged someone, their name would appear like this in the data: “Hey @[1108218380:2048:Rodd Snook]”. But then in recent years, that format disappeared.
    • Dead links – not Facebook’s fault, but there are so, so many.

    As soon as these errors started cropping up, I had to make the call whether to stop and adjust my Shortcut to handle them, or to clean them up manually. In most cases, I decided that I’d just manually review and fix. After every couple months’ worth of import, I’d pause and page through them on the site to see if any looked weird. I’d then manually edit and tidy up any issues.

    There were other oddities I noticed in the data that aren’t really errors. For example, my earliest status updates are all sentence fragments that start with a verb. This is because back in the aughts Facebook had an explicit “What are you doing right now?” prompt. Kinda funny.

    The archive also included posts that I made on other people’s profiles, mostly just “Happy birthday” wishes. The data does include the name of the person I was writing to, but I couldn’t be arsed creating a special case in my Shortcut to handle that. I ended up deleting most of those and just keeping the ones that amused me or where it was a family member.

    The archive didn’t include posts that I made in Groups. That may have been an option when I downloaded my archive, but I decided it wasn’t worth the effort. I’ve never been a big Group user. It also doesn’t include the comments on any of my posts. Again, that may have been an option, but I figure discussions should be ephemeral. I’m okay with not having those.

    Ultimately you could argue that this import had minimal value. Most of the content is actually already on this blog, either posted natively or included already in the Twitter or Instagram imports. But there are occasional gems in there that I didn’t post anywhere else, and I’m happy I preserved those. I don’t expect anyone to ever read them, but it’s an important part of my personal data archive and I’m glad I have it.

    And now I just need to finish deleting all the content over on FB…

  • Scrobbling and it feels so good

    I was cleaning up old blog posts today when I saw a mention of the widget I used to have (decades ago) that showed what I was listening to. “That would be fun to recreate,” I thought. How hard could it be?

    Folks, I could find no way to easily embed my last played Apple Music song. The desktop app allows you to get iframe embed code for playlists, but there’s no playlist for your Recently Played. You can create a Smart Playlist of songs you’ve recently played, but this will only include songs in your library and not songs you’ve streamed. Also, you can’t embed a Smart Playlist anyway. There are no WordPress plugins that do this, and no third party apps that I could find. There is a Developer API for Apple Music, but to register as a developer you have to pay $99 a year. Yeah, no.

    For a second I thought about switching back to Spotify. Double-plus no.

    Then I remembered… scrobbling. That was a thing, right? Turns out it’s still a thing. But how to scrobble Apple Music? I mostly listen on my iPhone, and the consensus seems to be that Marvis Pro is the way to go. This app is basically a wrapper for Apple Music, but it has a massively customisable UI (the Redditors love it), it scrobbles to last.fm out of the box, and it’s only $15 AUD. I figured it was worth a shot. Installed the app, signed up for last.fm, and verified that scrobbling was happening. Now to hook it up to WordPress…

    This post from RxBrad has a handy Javascript snippet that can be used in a WordPress Custom HTML widget. Too easy! I signed up for an API key and set up the script… but it wouldn’t work. In the Block Editor preview it would show the album, but when I published the widget, it would just show a broken image on the site. I noticed in the console that there were some errors about the ampersands, and I could see that WordPress was actually converting them to HTML entities. I banged my head on a wall for 10 minutes until the Snook woke up from his nap and I patiently explained the problem. Less than 2 minutes later he had solved it. Oh right! We used to always put HTML comment tags around our Javascript, back in the day. (Insert “Do not cite the Deep Magic to me, Witch” meme.) Once I added those, everything just worked!

    So yeah, there it is over in the sidebar on the homepage.

    Currently Listening widget that shows Wild Wild Life by the Talking Heads

    Limitations:

    • Marvis Pro only scrobbles while the app is open. So if my iPhone screen goes to sleep, it won’t sync again until I wake it up. It does sync the whole history then, but it does mean the sidebar isn’t really necessarily “live.” Do I care? Not at this point. If I do, I can apparently pay $10 to unlock background scrobbling via last.fm Pro.
    • Marvis Pro doesn’t have a desktop app. If I want to scrobble from my Mac Mini, I’ll need to setup the last.fm desktop app. Can’t be arsed right now, but it’s an option.
  • Facebook Import frustrations

    Yesterday I kicked off the long gestating project to import all my old Facebook content to this website. I requested my archive several months ago, and since then I’ve been working on deleting all my content there. (It’s such a pain to delete your content without deleting the account. I’ll write up a post about that later.) Anyway, the import is now happening and you can see the posts appearing here.

    The exported data is a mess though, which has made the import script a real pain. You can post to Facebook from lots of other apps (and I did, over the years), and not all of the data is in there in the same ways. There are so many cases where data is just missing from the JSON. Like, you can post to Facebook from Eventbrite, and all that’s in the export is me saying “Booked in!” and “Kris Howard posted something via Eventbrite.” but the actual event isn’t linked or listed at all. It’s just gone. I’ve found other examples too, like Instagram. (Fortunately I already imported all my Instagram posts, so I’m just skipping over those.) But I’m only 10% of the way through, and I’m doing a lot of manual cleanup work.

    On the upside, this project (as well as my Instagram and Twitter import) have taught me so much about archiving and data portability. I’m happy that I will have some sort of record of this data, even if it’s not 100% complete. I’ll never end up in this situation again, and hopefully I can help a few others realise the pitfalls of entrusting your data to corporations.

  • Nine years ago…

    I was doubtful whether my project to import all my old tweets to my blog had any real value. But through them I just remembered that 9 years ago today, I got to meet and teach knitting to women and children in Manila who had been rescued from human trafficking. Canva supported the organisation and a whole group of employees went. It was one of the most worthwhile things I did in my whole tech career, and it had nothing to do with computers. 😭🩷

  • Of Blog Rolls and RSS

    Today I added a Blog Roll to the site, down there in the right-hand column. It’s been a long time since I had one of those! I’ve started with just a baker’s dozen of links for the sites whose posts I always read first when they appear in my RSS reader. I actually subscribe to a lot more than that, including a bunch that I just discovered via Wölfblag and Sky Hulk’s blog rolls. I’m sure some of those will make it onto the list in the coming months.

    Relatedly, I moved from Feedly to NetNewsWire earlier this year on both my Mac and my iPhone. Feedly was increasingly feeling like LinkedIn, and I resented that they kept trying to cram AI into an RSS Reader. It was very easy to click on the wrong link and end up on a Company Profile Market Intelligence page, which annoyed me. No, thank you! NetNewsWire is just what I need, and it was super easy to export and import all my subscriptions over to it.

    That reminds me – as part of this Blog Renaissance™️ – I’ve noticed a lot of sites don’t have RSS feeds. People… don’t you want us to read your stuff? You have to have an RSS feed. It’s table stakes.

  • A challenge of blog questions

    Blogging is back, baby! We’re even doing the thing where we write a post and then tag other people to answer the same questions. I haven’t done one of these in decades. (Link courtesy of Ethan Marcotte.)

    Why did you start blogging in the first place?

    Because it was 2000 and I was working as a web developer, and clearly everything we were doing was CREATING THE FUTURE. I initially started a group blog with a couple college friends (but really it was 99% me) writing about stuff happening back at our university dorm, because I was in that phase of life right after leaving college where you still think it was the most important thing ever. (I’ve since imported all those old posts over here.) A few months later I started my personal blog, which has been running continuously for 24 years. I was living overseas in London and it became a way to share my life with my family and friends back in the States. The blog quickly became the nexus of my social life, and there was a core group of early bloggers that I exchanged links and comments and mix CDs with for several years. I really miss those days.

    What platform are you using to manage your blog and why did you choose it? Have you blogged on other platforms before?

    I started with Blogger.com, which back then was basically a static site templating engine where it would actually compile HTML and FTP it to your hosting provider. It suffered from constant outages though, and within a year I was writing my own simple PHP+MySQL blogging CMS. I switched over to that in May 2001, and I released the code a couple weeks later. I used that system for fourteen years, adding lots of little features here and there. Eventually I got tired of constantly being hacked – and not having the skills to prevent it – and my friend John Allsopp made a radical suggestion: move to WordPress. I imported over 13K+ posts and 25K+ comments, and set to work learning everything I could about how to lock it down. I’ve been using WP ever since, on various hosting providers (most recently Amazon Lightsail).

    Every now and then I get annoyed with WordPress – it’s taken me years to come around to using the block editor, which I will still only do under great duress – and Rodd grumbles every time I need him to help me debug something. But mostly it just works, and it does everything I need it to.

    How do you write your posts? For example, in a local editing tool, or in a panel/dashboard that’s part of your blog?

    Mostly just in the WordPress (classic) editor, in a browser window. I’ve tried using the WordPress app on my phone, but I find it annoying. (Again: block editor.) A few months ago I had the idea to create some iOS Shortcuts that allow me to create photo posts straight from the Photos app on my iPhone. That’s been super useful and fun.

    When do you feel most inspired to write?

    In the early days, I shared multiple times a day – every little thought that came into my head. Hey, we didn’t have social media back then, all right? Links I’d found, news that was interesting, even dreams that I’d had. And then in 2009 I got into Twitter and blog posting dropped off accordingly. For like a good decade there the blog was mostly just automated posts that collated what I was sharing on other social networks.

    I started making an effort to blog more when we moved to Munich, Germany during the pandemic in August 2020. It was partly getting back to one of my original blog motivations – sharing my life overseas with friends and family – and partly just not having any other social outlets when we were in lockdown. I also knew that we weren’t going to be there for more than a couple years, so the blog became my journal documenting an experience that I knew I would never want to forget. (Oh and also a Nazi bought Twitter, so I killed my account there and thus to redirect all that tweeting energy.)

    And then last year I retired from full-time work, and suddenly I had more time to think about how I interact with technology. I’ve been incensed to see how Big Tech leaders that I formerly semi-respected have turned into craven bootlickers for the new administration. It’s galvanised me to take control of my data, and to focus on my website as the center for my online presence. I’ve been importing my content from elsewhere, and I’m experimenting with ways to syndicate my content outwards. (Discussions with my friend David Edgar have been super helpful, as he’s built his own system for doing just that.)

    I feel like I’m getting away from the original question though. Nowadays I mostly feel inspired to write in the morning. For the past couple weeks I’ve been making time after breakfast to “tend my digital garden,” going back through all the posts written on this date and fixing broken links, adding tags, and cleaning up dodgy HTML. I find it very soothing and therapeutic, and it often gives me ideas for things I should write about. I also usually have a couple links saved up from my evening browsing that I want to share too.

    Do you publish immediately after writing, or do you let it simmer a bit as a draft?

    Unless it’s a very long post that takes me a long time to write, I pretty much always publishing immediately after writing.

    What’s your favorite post on your blog?

    Oh good grief, there are far too many. As I said, I’ve been doing this for 24 years. I can tell you what the Internet’s favourite post(s) are though: the Jamie’s 30 Minute Meals posts. More than a decade ago Rodd and I cooked and blogged 37 meals from that book, and they are still by far the most trafficked posts on the site. 🤷‍♀️

    Any future plans for your blog? Maybe a redesign, a move to another platform, or adding a new feature?

    I literally changed my theme like two days ago! I’m pretty happy with it. I just want a clean, responsive blogging theme with a sidebar, like in the old days. I’m still doing tweaks here and there, but mostly I’m happy.

    Another thing that changed recently – I turned comments back on. I turned them off a few years ago because very few people used them anymore, and I was tired of dealing with spam. But now that I’m not using Instagram or Facebook or Twitter, I want there to be a way for people to respond to what I’m writing. And I also know that I find it very frustrating to see a great post on someone else’s blog and not be able to start a conversation about it. Let’s all bring back comments!

    And lastly, Rodd and I have talked a lot in recent years about whether I should turn this into a static site. The idea is that I’d still use WordPress as the CMS for convenience – probably running locally on our home server – and then generate static HTML that I host elsewhere. It would be more secure, faster for users, and cheaper for me to host. I’ve played around a bit with WP2Static, and Rodd’s experimented with writing his own site generator in Golang. BUT there’s a big drawback – I’d lose the interactive elements of the site, like searching and commenting. I’d have to find replacements for those, and I’m not a huge fan of my options there. Still thinking about it…

    Who’s next?

    Most of my old blogging friends have closed up shop a long time ago. I’ll go with some IRL friends that are blogging these days: David, Sathyajith, VirtualWolf.

  • Tending to my digital garden

    I’ve been thinking a lot about link rot lately, and how many of the links I have shared on my blog over the years are now dead. I also have a lot of old posts that are missing titles, categories, and tags. Therefore I’ve taken a cue from Terence Eden and I’ve started a project to “tend to my digital garden” every day. I installed the On This Day plugin, and now I have an archive page that shows all the posts from this day across all the years of this site. Every day I’m going to do my best to click through those posts, checking for broken links and updating them as best I can. I’ve already had to resort to the Internet Archive several times, but here’s one bit of good news –  the Sydney Morning Herald still maintains links going back 20+ years! That was a happy surprise.