Updates for parallel.cymru

Updating outdated WordPress themes and plugins to help keep Welsh language resources alive (originally posted on catspawstudios.wales)

Listening to

Intro

Having used parallel.cymru off and on for the 5 years since I first discovered its existence, it's proved to be an excellent source of knowledge. Its Ask Dr Gramadeg section has been indispensable to me as an active learning tool, and the accompanying wealth of information (which includes a lot of interesting aspects of the language that we just don't get taught) really cemented it in my mind as one of the go-to resources, especially for learners.

After a period of not having visited the site (work having finally caught up all at once), I was surprised to find PHP errors displaying. Emailing Neil, manager of the Parallel project and site, I was again surprised to learn that it was an entirely self-funded endeavour! An incredibly impressve feat given its scope.

After a bit of messaging back and forth, I offered to spend a couple of days troubleshooting and updating the site where possible, to remove the errors and return it to its former glory.

qtranslate-x and the call for open source funding models

A fact known to near-every WordPress user, keeping installed plugins updated is almost like having a second job. Having multiple plugins update on a near weekly basis - while good for security - isn't great when your site has a reliance on a plugin that all of a sudden works in an entirely different way! That in and of itself is a separate issue, on which other people have written far more eloquently already.

What doesn't seem to be talked about enough, however, are the plugins whose maintenance falls by the wayside.

Such is the case with qtranslate-x. For a WordPress plugin with a codebase not updated in over a decade it's still surprisingly functional overall and likely faster than newer alternatives given how it handles its translations. It is, however, reliant on a number of now-deprecated PHP practices, meaning sites running it couldn't be updated past PHP 7.4 - a rather unfortunate security risk!

While an awful lot more would need to be done in order to bring it in-line with "how WordPress does plugins now" and make sure all features were working fully, realistically speaking only a few small changes need to be made to have it running without error on a PHP 8+ setup.

So... Why weren't those changes made?

qtranslate-x's apparent fate is the same we see befalling many of its open source kin; without sources of funding, projects largely rely on the ability and availability of their communities and creators (though even FOSS projects backed by companies often find themselves abandoned). For, say, a relatively popular code library, this can lead to quite a long life since a lot of the users are also able to help maintain the project. For something like qtranslate-x, the core demographic for which being "non-technical" users, it seems the common pattern is one of a slow, quiet death once the core maintainers no longer work on the project.

One solution for this - one we're thankfully seeing gain more traction in recent years - is to have centralised funding sources for open source projects. Combined with volunteer code contribution and donations by users / sponsors, open source development could really flourish.

I look at BookStack as an example where - even without centralised funding - the original creator is able to work on their FOSS project full-time, delivering value and benefit to thousands of others (individuals and companies alike). I've used (and sponsored) BookStack for the better part of the last decade as my documentation / knowledge base platform of choice.

I've definitely had my money's worth. Heck, if every BookStack GitHub star equated to a £3 subscription per year, the developer could live relatively comfortably without the need to take on service contracts to bridge gaps. What if part of our taxes went towards ushering in the next major piece of FOSS software, rather than towards things decidedly less palatable?

Hmm. At this point I feel like I might be rambling and about to veer hard into cloud-shouting territory.

Dear everyone: use open source projects.

Dear governments: fund open source projects.

qtranslate-x update fixes

Anyhow.

As anyone who's worked on or with multilingual setups knows, a good translation engine is incredibly important for sites like Parallel. With the amount of content the site holds, switching to a different translation setup wasn't a feasible option; updating qtranslate-x to remove errors was the only real option available.

Here are the fixes put in place for making qtranslate-x PHP-8-friendly.

Please note that this doesn't necessarily guarantee all its functions work. The state of the site as an archive was the main priority and while spot checks were done for more obvious uses (page create / edit / display), there are bound to be bits I didn't get to.

All the below are in /wp-content/plugins/qtranslate-x/

admin/qtx_admin.php

replace line 781 with

if(!empty($args['name']) && gettype($args['name']) != "array"){

qtranslate_core.php

replace line 750 with

return $before.date($format, $date).$after;

replace line 713 with

$day = intval(ltrim(date("d",$date),'0'));

add at line 710

return $default;

replace line 685 with

$vals = preg_split('/[\s,]+/', strtolower($ignore_file_types), -1, PREG_SPLIT_NO_EMPTY);

qtranslate_frontend.php

replace line 497 with

continue 2;

replace line 523 with

function qtranxf_postsFilter($posts,$query) {//WP_Query

replace line 597 with

function qtranxf_excludeUntranslatedPosts($where,$query) {//WP_Query

replace line 629 with

function qtranxf_excludeUntranslatedPostComments($clauses, $q/*WP_Comment_Query*/) {

qtranslate_utils.php

add at line 443

if($str == null) $str = "";


And that's it!

( As a minor tangent to the core topic of this page, I have to give props to WP engine's Local which, despite its baffling choice of name, made setting up and switching around the local WordPress environment far easier than it had any right to, even though I wasn't going to be using the WP engine hosting offerings. It also didn't bork my existing local dev setup like Laravel's Herd did on MacOS, or act like Malware like DevKinsta did on Windows. Always a plus! )

Previous Post