Register Widgets with a Static Method

Registering widgets in WordPress is annoying.

All of the functionality is bundled up nicely in the WP_Widget class, but you can’t use an object method for the registration. Most PHP classes I see used in the WordPress space are pseudo namespace singletons. They have a helper for registering methods to hooks, and then the object is instantiated and the helper called. The various class methods are hooked in with something like add_action( 'init', array( $this, 'method_name' ) );. There is nothing inherently wrong with this approach. It provides a nice pseudo namespace for code that is PHP 5.2 compatible. When it comes to widget registration, though, that pattern just doesn’t work.
Continue reading

NPM Inception: using NPM to update Node and NPM

I had some fun yesterday setting up a new Gruntfile. I copied over the package.json files and wanted to update the versions of the packages. Unfortunately I started hitting errors because my versions of NPM and Node were out of date. I knew I could just go download the node package, but I decided to find another way.

Continue reading

Installing Bluehost PHP extensions with a non-default PHP version

I’m still hosting this site on Bluehost currently. I have considered a number of times moving to something like Digital Ocean, but for now, I’m here. Until then, I’ve worked to make the best of what Bluehost has to offer. As part of that, I wanted to set up a legitimate object cache for the site. Furthermore, I much prefer something like batcache to act as a full page caching system which requires some kind of persistent caching.

Continue reading

© 2022 Luke on Everything

Theme by Anders NorénUp ↑