Blog

WordPress

Posted on — Last updated on October 11, 2019

Recently 2.0 is out!

PHP 7+ compatibility, improved Customizer support and a new codebase are some of the highlights of this version.

At long last, Recently has received some development love!

What’s New

For the past couple of weeks I have been working hard on bringing Recently up to date.

There were some long overdue issues that have been finally addressed and of course a couple of new features were baked in while I was at it.

PHP 7+ Support

In PHP, method names prefixed with double underscores are called Magic Methods. Basically, these so called Magic Methods allows us developers to perform a few neat tricks in OOP (Tuts+ has a nice article on Magic Methods in PHP, so if you’re not familiar with it go check it out).

While PHP discourages the use of double underscores in method names, it became a widespread practice among developers to prefix special methods within our classes with a double underscore to distinguish them from the regular ones. Then, PHP 7 happened.

With the release of PHP 7, PHP reserved the use of this notation (the double underscore) to itself for “future use”, triggering a visible warning message from every PHP script out there that used it. It didn’t actually break anything and scripts continued to work as usual – except of course for the annoying warning message.

I guess at this point it’s pointless to say that both of my plugins, Recently and WordPress Popular Posts, were also using the double underscore prefix. WordPress Popular Posts 4.0 addressed this issue, and now Recently 2.0 does as well.

Recently now gets along nicely with the Customizer

One of the features I like the most about Recently is its ability to update its options on-the-fly as the user sets it up on the Widgets screen.

Being able to configure the widget without having to constantly click on the Save button to access new options is quite nice in terms of user experience. Something it’s older brother WordPress Popular Posts unfortunately can’t do (yet).

WordPress' Customize Screen
WordPress’ Customize Screen

However, on the Customizer the experience was quite different. There were some noticeable usability issues that became apparent after a couple of users reported about them since I honestly rarely had used the Customizer before (yeah I know, shame on me).

Luckily the issues were easily fixable and the changes didn’t have an impact on how the widget behaves on the Widgets screen. Yay! Recently is now Customizer-friendly! (Is that actually a thing?)

A New Hope Codebase

WordPress Popular Posts saw a major code refactoring last year, seeking to improve code readability and re-usability. 5 months later, I can say that it really paid off: it’s so much easier to find / change / extend plugin’s code now than it ever was (it’s not like it was a total mess before though, I’ve always tried my best to keep things organized.)

Seeing how WordPress Popular Posts benefited from its code refactorization, now Recently gets the same treatment.

jQuery dependency dropped!

… well, not entirely.

jQuery is great, I totally love it. But it also is a render-blocking resource that increases the loading times of your site. If you’re not building a really complex web app with jQuery at its core, chances are you don’t really need jQuery. In fact, you can do anything JS without jQuery.

Recently relied on jQuery to ajaxify the widget, thus preventing caching plugins from caching it. And that was it. Besides that, it really didn’t use jQuery at all which seemed like a waste of resources.

I wrote a small JS library (less than 500 bytes when gzipped!) that does everything the Recently widget needs to work on your site. Even the AJAX thingy.

So, from now on Recently will stop requiring jQuery on your site. What this means for you is that your posts and pages will load a bit faster since jQuery won’t be loaded anymore – and if it is, it won’t be because of Recently.

But wait, there’s more!

At the beginning of this post I mentioned that there were a couple of new features that were added while I was refactoring Recently’s code. Nothing major nor life changing though, but I won’t spoil you. Make sure to check the changelog to see the new goodies.