WordPress is a long running machine, and in most of my 11 year experience using it, have found it rather forgiving with old code and themes.
With the 4.7 WordPress update, I have been seeing a problem with the Feed WordPress plugin, and despite a fix I found that cleared the error, tonight I found the fix broke other related plugins.
Sadly the developer of this plugin much of my syndicated blogging work has revolved around is a bit absent on issues with his code.
If anybody knows where the developer of the FeedWordPress plugin lives, please ring his doorbell and yell CHECK YOUR REPO ISSUES, MAN!
— Alan Levine (@cogdog) December 10, 2016
That has to wait for another day.
I ran into another problem with a plugin, it’s one that presents code I put into my blog post into a more readable format. Syntax Highlighter Plus has worked without problem on my site for several years, but tonight, it’s borking. The problem has to do with some new way WordPress has coded global filters. I could not untangle the code enough to find a remedy.
The first recourse is disabling the plugin. The problem this presents is that the way it worked is I wrapped all my code with a pair of shortcodes like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
[sourcecode lang="javascript"] <script type='text/javascript'> // The results should contain just 1 item with a description value function output_latest_co2_stats(o) { // grab a date object so we can put a time stamp on output var d = new Date(); // call the YQL statement to fetch latest data document.getElementById('results').innerHTML = o.query.results.item.description + ' <p class="stamp">last updated: ' + d.toLocaleString() + '</p>' ; } // reload the page daily delay = 86400000 milliseconds setTimeout(function() { window.location=window.location;}, 86400000); </script> [/sourcecode] |
Nearly all my stuff has an attribute for lang= of php
or javascript
. This is the hitch of using shortcodes; when I disable the plugin, my posts are going to be littered with bits of [sourcecode lang="php"] ... mumbo jumbo .... [/sourcecode]
.
My strategy was to find another syntax formatting plugin (there are quite a few), and Crayon looked like a good pick. It’s recent, has a fair number of installs and reviews.
I installed the plugin and tested it. Yup, it formats code. The thing is that uses a different (and better IMHO) construct than shortcodes; it wraps code in [crayon-6568615ce2c97289625448/]
tags with a class attribute that defines the display language, e.g.[crayon-6568615ce2c9b783138109/]
I started thinking about a function I could add to hook into the_content to do a search and replace on the shortcodes. I even got as far as getting a grep search to work.
The I thought of an easier plan. I just need to do a one time search and replace on all posts that used these tags. And I remembered you can do this on the database in phpMyAdmin. I fired up mine via my lovely Reclaim Hosting cpanel.
I fund the wp_posts table in my blog, that’s where all the content for blog posts live and breathe. Actually I first duplicated the table in case I messed up.
I clicked the SQL tab so I could run direct queries (not for the feint of heart), and ran this one to replace all the closing [/sourcecode]
shortcodes with </pre>
ones:
Bam! I got like an update to 38 posts. I checked one. Sure enough the search and replace worked. I then ran a few more like:
or in phpMyAdmin:
Note: I spent way too much time getting [crayon-6568615ce2c9d232282463/]
tags, so I set it’s default to use the Plain White theme and to never show the toolbar for those boxes where I did not want code formatting.
THEN I ran my mySQL updates to modify the ones where code was used, to replace with tags that include a darker Crayon theme and to show the toolbar.
I better stop now….
Top / Featured Image: flickr photo by waferboard https://flickr.com/photos/waferboard/30182796173 shared under a Creative Commons (BY) license
bitrot like change is a constant 🙂 good luck on the bitrot in the Feed Press WordPress plugin; i feel your pain and like you I have felt the pain of plugin-in/add-on breakage on many pieces of software over the 3 decades I’ve been in the software industry.
This is why I try to avoid using plugins and add-ons in any software (emacs, firefox thunderbird, heck even jekyll where I am using the default theme); eventually they all stop working without some sort of change usually non-trivial
Looks like FWP was updated today…haven’t tried it yet, though.