I have grand SPLOT plans for the holidays.
Huh?
I hope to spend some time cleaning up a number of relatively minor issues with existing SPLOTs, maybe add a new one or two (I did say grand), update the Instant SPLOT recipes (and test them out more to troubleshoot some reported issues). It’s not too late to phone in some requests.
But there’s been two problem areas I’ve wanted to get to, certainly not deal breakers that have to do with recommended plugins which are causing some problems.
One is The Customizer Social Iconz plugin used on the WP-Dimension and WP-Big Picture calling card themes. Any site using that plugin will continue to work, but a bug in the plugin is causing the WordPress Customizer to not load. The developer is not responding to my bug report but I have an idea for a different plugin. That issue will go on the lift later.
A simpler one to fix (and has been done) is the one I use in the TRU Writer SPLOT to add estimated reading times to archives and single published items.
The plugin I recommended and built a connection in the theme was the Estimated Reading Time plugin which is no longer available for installation.
For a while I kept the last working version I had as a download link, but that’s a bit short sighted. So I spent a few clicks of time integrating the newer and available Reading Time WP plugin.
Functionally they are not all that different; they generate a string of the estimate based on a setting of words per minute an can be called as I do, from my templates via a shortcode. My code will just skip this feature if the right plugin is not installed.
If you have a site with the older plugin running with the latest version of TRU writer, the reading times will not appear, and in the options, it will notify you (as it will in a new site where the plugin is not available).
I thought my code was pretty clever, it searches for the shortcode this plugin should enable:
1 2 3 4 5 6 7 8 9 10 11 12 |
function reading_time_check() { // checks for installation of Reading Time WP plugin // https://wordpress.org/plugins/reading-time-wp/ if ( shortcode_exists( 'rt_reading_time' ) ) { // yep, golden return ('The Reading Time WP plugin is installed. No further action necessary.'); } else { // nope, send them off to set it up return ('The <a href="https://wordpress.org/plugins/reading-time-wp/" target="_blank">The Reading Time WP plugin</a> is NOT installed. You might want it-- it\'s not needed, but it\'s nifty. <a href="' . admin_url( 'plugins.php') . '">Do it now!</a>'); } } |
Once you install the The Reading Time WP plugin there is one setting to change, under Settings -> Reading Time WP.
All you need to do is uncheck the options at the bottom:
This prevents the plugin from inserting it into the content of post (the TRU Writer theme takes care of putting the output in the right place).
The only other setting you might change is if you want to change the calculation from 300 words per minute (the first three settings are ignored on this theme).
I realized I had set this up well, because the way the plugin is referenced in the template (in three places) is via a helper function, so I did not have to edit them at all. For example, the two places it is used in the single post template is for the header:
1 |
echo truwriter_get_reading_time('<span class="sep">|</span> Reading Time:', ''); |
and in the info at the bottom:
1 2 |
// output estimate reading time echo truwriter_get_reading_time('<p class="author-description"><strong>Reading time:</strong>','</p>'); |
The first parameter is what comes before the reading time number; the second parameter is what comes after.
So to change the plugin, I just needed to rewrite the helper function, from calling the shortcode for the previously used plugin:
1 2 3 4 5 6 |
function truwriter_get_reading_time( $prefix_string, $suffix_string ) { // return the estimated reading time only if the short code (aka plugin) exists. // Start with the prefix string add an approximation symbol and append suffix if ( shortcode_exists( 'est_time' ) ) return ( $prefix_string . ' ~' . do_shortcode( '[est_time]' ) . $suffix_string ); } |
and now using the shortcode for the newer plugin:
1 2 3 4 5 6 7 8 |
function truwriter_get_reading_time( $prefix_string, $suffix_string ) { // return the estimated reading time only if the short code (aka plugin) exists. // Start with the prefix string add an approximation symbol and append suffix if ( shortcode_exists( 'rt_reading_time' ) ) { return ( $prefix_string . ' ~' . do_shortcode( '[rt_reading_time postfix="minutes" postfix_singular="minute"]' ) . $suffix_string ); } } |
I was rather impressed with my approach here, it made implementing a new shortcode pretty easy.
To most people this is obscure noodling but this is the under the hood stuff I love doing (well, when it works). The next plugin swap will take a bit more work, but it’s on the list.
FYI these are new SPLOTs I am considering, mostly extensions or riffs of existing ones:
- Expanding the function of the Sound Collector to also include video (via embeds of YouTube, vimeo links). This might get a new name, like Jukeboxer (or please if you have a better idea, let me know)
- The HTML5 UP Highlights theme would make for another nice calling card.
It’s gonna be SPLOTTY around my house.
Featured Image: Pixabay Image by geraldoswald62 shared into the public domain using Creative Commons CC0
Comments