When you’re developing a WordPress plugin, there are certain patterns and practices that are extremely useful to know and apply in order to get a better fit with the platform as a whole.
One of these things it’s what’s the better way to initialize a class on a plugin, which this answer on the WordPress StackExchange covers in great detail, while also explaining other interesting topics and recommendations such as using an autoloader and global access, registry and service locator patterns.
While you’re at it, you might also want to check these posts from Tom McFarlin:
- Properly writing WordPress plugin constructors, which basically explains why it’s better not to set action or filter hooks on a plugin constructor
- The right hook to initialize a WordPress plugin, about finding the correct hook (not too early, not too late) to initialize a plugin