WordPress themes and software decay

I have discovered a few broken things with my WordPress site. This post, as much of this blog, is mostly description of events, so I won’t forget what exactly happened. To avoid boring details, feel free to read the summary and jump to “conclusions” at the end.

  • My theme “rotted” over time: the “menu” button stopped showing on mobile and on smaller windows on desktop.
  • Changing/upgrading theme caused a critical error, permanently disabling the web site.
  • I had a really hard time finding a suitable theme.

I haven’t touched WordPress configuration for several years, I was just doing ordinary upgrades. At some point, it fell victim of software rot.

Escape from WordPress: enter Ghost

All of the above was frustrating enough that I made an attempt to escape from WordPress and try a different blogging platform. Various forums recommended Ghost, so I created a Ghost droplet on Digital Ocean and gave it a go. First thing, it lied to me about my email: it said it would only be needed for an SSL certificate, but then I received an email titled “Your New Ghost Site” and signed “Team Ghost”. Not cool.

More importantly, I was not able to transfer my blog content to Ghost. I installed their export plugin, and it created a zipped file, which contained some JSON. It didn’t contain the uploaded media as it should have, but whatever, I was ready to move the media manually. Anyway, any attempt to import the file into Ghost resulted in an error box sayin “, cannot fetch db“. Yes, it started with a comma. I tried the same with raw JSON, but no success. Other people reported the same error (https://forum.ghost.org/t/migrating-from-wordpress-not-working/44422/7), but I was unable to find a fix. So, back to WordPress I went.

Can’t Change Themes

Attempt to change theme made mye site permanently unusable. Investigation showed that it is related to the content of the database. The $sitebars_widgets map contained a key that is mapped to NULL:

(
    [wp_inactive_widgets] => Array(...)
    [primary] => Array(...)
    [subsidiary] => NULL
)

This causes an exception when WordPress tries to merge all values into one big array. The site then becomes permanently unusable, it is not possible to change the theme back via the GUI, the only way to do it is to restore the original database from backup.

The actual exception text is in Apache log.

Fatal error: Uncaught Error: array_merge(): Argument #3 must be of type array, null given in wp-includes/widgets.php on line 1342

This problem was reported by multiple people: https://core.trac.wordpress.org/ticket/57469. Since $sitebar_widgets is a global variable, it is difficult to tell how exactly it is set. The problem can be fixed by adding the following code to retrieve_widgets() in wp-incudes/widgets.php just before the call to _wp_remove_unregistered_widgets():

// remove any NULL elements
$sidebars_widgets = array_filter($sidebars_widgets);

It suffices to change theme once with this code present, after which the database is fixed, and the patch can be removed.

Once I was able to change themes again, I was hoping to find a new theme I can switch to.

Choosing a New Theme

There are literally thousands of themes for WordPress, and it is not easy to find a good one.

  • Most theme previews are dominated by cover image, which does reflect actual look of the theme.
  • Most themes show posts in multiple columns and/or limit the screen width.
  • Many themes are broken in interesting ways: e.g. they can’t display site logo, title, and tagline at the same time, or they don’t support sidebars, etc.
  • Lots of themes contain unnecessary repetitive elements, like giant red “CONTINUE READING” button after every post header.
  • Many themes refer to some additional “builder” plugins.
  • Lots of themes are commercial, i.e. extra features need to be unlocked for a fee. This is alright, but there is no way to filter for actually free themes.
  • Many themes introduced changes to global styles of element such as <li> or <a>, which broke other pages on my web site.

Out of thousands of themes available, it proved to be impossible to find a theme that answers to my rather simple requirements:

  • Continuous flow of blog posts, no multi-column.
  • No artificial width restrictions.
  • Site logo, name, and tagline all displayed on top.
  • Sidebar support.
  • Mobile support.
  • No atrocious repeatable elements such as “learn more” or “press here to continue” after every post.
  • Ability to customize colors.

I am sure such theme exists, but I was not able to find it. A few themes came close to what I needed: Asteroid, Blogstream, Zarka. However, the amount of work needed to get them to look “right” seemed to be greater than fixing my old theme.

Living on an old Theme

My current theme is Stargazer, which I selected a few years ago. Stargazer theme was created by Justin Tadlock (https://justintadlock.com/), with the latest version dating back to 2018 (https://github.com/justintadlock/stargazer).

I invested quite a few hours into customizing it via a child theme, so it looked like I wanted. The customization involved touching a number of theme specific styles, and even modifying small pieces of PHP code. All customizations live in “stargazer_child” folder, so they could be re-applied when the main theme is upgraded.

Stargazer worked great for me, but at some point handling of the “hamburger” menu got broken.

No menu button

I have “secondary menu” on my blog page (“Articles”, “Code”, …) that is supposed to collapse into a “hamburger” button on smaller screens.

It used to work when I adopted the “Stargazer” theme a few years ago, but not anymore. The culprit turned out to be “screen-reader-text” style, which makes objects invisible. So, the menu was there, but it was not displayed.

With some amount of patience and with great help from Chrome developer tools, I was able to update my child theme to fix the problem and make the menu look exactly like I wanted. I am a little concerned about running a 8 year old theme, but I guess if it works, don’t fix it.

Conclusion

All software, including WordPress themes, decays over time, unless it operates in a completely self-contained jar. Protocols change, things get moved around, external services come and go, minor details get updated quietly. So, having a few things broken after 8 years is expected.

What was not expected is (a) fragility of WordPress, and (b) difficulty of finding a decent theme that answers to my taste.

I was unable to rescue my side without diving rather deep into WordPress code and debugging PHP. I haven’t done anything outrageous. The error message displayed is rather generic and gives zero direction on what to do. It does not even say how to find the actual exception text. I can only imagine how scary it must be for non-technical WordPress users who don’t know how to code.

I was also unable to find a “good” theme out of several thousand available on WordPress web site. Generally, finding a theme was a rather frustrating and slow experience. Fixing my 8 year old theme proved to be easier than customizing a new theme. I’d say this is rather sad state of affairs.

Leave a Reply

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