• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Deeper Scenery

Further up and further in

  • Home
  • Blog
  • Code
  • Tutorials
  • Privacy Policy
You are here: Home / Ideas / Conditionally Instantiating Classes in WordPress

Ideas · Published: November 14, 2018 · Modified: November 14, 2018

Conditionally Instantiating Classes in WordPress

This is just a small idea. For more information, see this blog post.

When writing code for WordPress plugins, one of the things that you need to do is to hook everything into the appropriate WordPress hooks. When working with OOP code, this typically means that each class is responsible for its own hooks. The result of this is that each class needs to be instantiated so that it can attach its hooks, regardless of whether those hooks will be loaded in the current request.

The result is a bunch of objects instantiated in memory, but they’re never used. I’d like to look into a good solution to this problem.

Filed Under: Ideas

Previous Post: « Git Commit Signing with Keybase.io
Next Post: Create Local WordPress site with Valet+ »

Primary Sidebar

Subscribe to jeremypry.com

Enter your email address to subscribe to this site and receive notifications of new posts by email.

  • Home
  • Blog
  • Code
  • Ideas
  • Tutorial
  • Gifts
  • Privacy Policy

Copyright © 2025 · JPry Showcase Pro on Genesis Framework · WordPress · Log in