arrow-left arrow-right brightness-2 chevron-left chevron-right facebook-box facebook loader magnify menu-down rss-box star twitter-box twitter white-balance-sunny window-close
Smart Archives v2.0 (now with caching)
1 min read

Smart Archives v2.0 (now with caching)

I’ve finally gotten around to updating Smart Archives, and have added a pretty significant feature, namely caching.

I could find no way of working the plugin into the already-available caching subsystems and so I decided to go it alone. I had a hunch it was going to go down like this, which is probably why I waited so long to whip up a solution. At the end of the day, the changes actually were quite simple, but getting there was anything but.

Essentially, the plugin now writes to a file the contents it generates, instead of pushing the contents directly to the screen, and makes sure that these contents are modified only when a new post is published. This ensures that the rather expensive smartArchives function is called only once for every new post, instead of once for every external request of the archives page.

Annoyingly, WordPress will not let you use pass variables through the add_action function; trying to get this to work was making me crazy until I finally decided that it just couldn’t be done and began thinking of a workaround. If you’ve been able to get this to work, I’d love to hear from you (I could find nothing on the Net).

I note that currently the plugin does nothing when you delete a post. Ideally, it would update the archives file, but I can find no trigger that will call a function after a post has been deleted. The one action that I thought might work, delete_post, actually triggers too early: Note that at this time, the post has not yet been deleted.

Localization

For the past couple of years I’ve been relying on users to correctly set their WPLANG variable in the wp-config.php file, but it seems many do not, and even those that do sometimes still see language-based errors. Also, WP’s built-in language tools seem to break SA for some users, which kind of rules out a universal setup for this sort of thing.

In light of these issues, I’ve added some new, and very simple instructions regarding localization, which instructions should take care of 99% of the use cases.

You've successfully subscribed to Justin Blanton.
Success! Your account is fully activated, you now have access to all content.