Version 2.16 fixes some bugs accidentally introduced in version 2.15. While that version worked in testing with using shortcodes in a page and the widget in a sidebar, some people reported that the icons were missing – the rating stars, the pagination buttons, and the quotes in the Modern template.

I dug deep into the code yesterday to step through the display process. The new slideshow changes in 2.15 were needed so I couldn’t simply back those out. With the help of clues provided by some of you, I found the problem quickly. It was a humbling experience but I also felt energized to solve it. Staying caffeinated helped too. 🙂

When to load stuff

Up to this point, the plugin had duplicate processes for features like pagination and the slideshow. The duplication was the unintended result of a very important feature: the plugin scans the current page for its shortcodes in order to load its stylesheets before the page is rendered instead of after.

Some plugins either load their stylesheets when the shortcode is rendered, which may result in a flash of unstyled content, or load them unconditionally on every page regardless of whether testimonials are being displayed.

Admittedly, either of those less-than-ideal approaches may not affect well-tuned sites running on decent servers, especially when caching too.

But sometimes shortcodes were not being found beforehand so the plugin also needed the ability to load the stylesheets, configure the slideshow, or add pagination after the page was rendered. Thus, duplicated code.

It really is a shortcoming of the shortcode mechanism; nothing can happen until the shortcode is found and processed. So, by default and with no other mechanism available, the only apparent options are loading stylesheets unconditionally or after the page is rendered.

More than I could chew

In the beginning, almost three years ago when I first adopted this plugin to create Strong Testimonials and it offered about the same features as any other, this duplicate approach was simple to maintain and somewhat beneficial (that’s debatable) in that it prevented wholesale changes that may have broken more than they fixed.

And I had a lot to learn about WordPress back then. Still do.

But as features were added and the plugin was used by more people in ways that I had not experienced or could not imagine — page builders, content shortcodes, non-traditional themes — that duplicated code became… unwieldy. And it finally broke in version 2.15.

So, over 12 hours yesterday, I refactored those processes: pagination, slideshow configuration, form validation. If I were starting from scratch (always a fun exercise) this is how it would work. As an added bonus, I learned a few things about how WordPress works.

The result

  • The plugin is faster and somewhat lighter.
  • Future improvements will be both simpler and easier.
  • Better compatibility and stability going forward.

I sincerely apologize for any headache caused by version 2.15. Thank you for your continued support and encouragement. I love working on this plugin and I hope you find it useful.

Chris Dillon

About the author: Chris Dillon is a WordPress developer in Cleveland, Ohio, USA. When not trying to figure out why his plugins aren't working, he walks his rescue dog Gordo, takes a nap in the backyard or makes a mess in the kitchen.