Background I recently commented on Tom McFarlin’s blog post entitled “Updating a WordPress Post in the Save Post Action” and suggested the use of a simple static variable rather than go through the hassle of removing and re-adding the save post hook. Tom’s response was he hadn’t thought of it but that he avoids recursion… Continue reading
Category Archives: Coding Techniques
Initializing Singleton Classes used in WordPress Plugins
After one of our earlier posts Eric Mann whose opinion we highly respect initiated a conversation with me over Twitter’s DM where he expressed a dislike for the HardcoreWP approach and stated a preference for using ::get_instance() instead: While this approach is perfectly workable and truth be told it’s mostly just personal preference we still… Continue reading
Using Singleton Classes for WordPress Plugins
In our last post "Enabling Action and Filter Hook Removal from Class-based WordPress Plugins" we offered the following as a suggested template for coding WordPress plugins:
Enabling Action and Filter Hook Removal from Class-based WordPress Plugins
In our tutorial “Using Classes as Code Wrappers for WordPress Plugins” we took a plugin that used a global function for its filter hook and converted it to using a PHP class as a code wrapper. Unfortunately the approach we showed didn’t allow other plugins and/or themes to remove or chain the actions and/or filters… Continue reading
Using Classes as Code Wrappers for WordPress Plugins
Many tutorials that explain how to write a WordPress plugin (including ours) show the use of global functions for implementing action and filter hooks. In our case we used global functions so we had less to explain. But now that we’ve gotten past that first tutorial we think once you understand using classes you’ll find no… Continue reading