Open
Description
Description
See base PR: #7249
We need to move the hooks from all class constructors to init_hooks
and then call that method whenever the class is instantiated (or whenever we need the hooks to be attached, separately from instantiation).
The goal of this is to remove the side effects from constructors and allow us to instantiate classes freely.
Acceptance criteria
- Base the PR on Add DisallowHooksInConstructor sniff and migrate some classes to use it #7249 if not merged yet
- Remove the relevant exceptions from
dev/phpcs/ruleset.xml
- Move the hooks to the new method and call them. Update the code and unit tests accordingly
- PHPCS should pass
CC @Automattic/pulsar