I’m trying to understand how WordPress works with actions, classes, and methods.
If there is a class “TestClass” and it has a public method ‘method1’
The method can be hooked to any action as “
add_action('theHook', ['TestClass', 'method1']);“
From my understanding. If you don’t initialize the class, you can not access its public methods and objects.
Now, I would assume that WordPress has to follow this, and it must initialize my “TestClass”, which will cause for public __construct() to fire.
However, after testing this, it does not fire __construct()..
Why is this?. I know a fix would be to self initialize inside ‘method1’, but I’m trying to figure out why WordPress behaves this way.