10up / wp-scaffold

10up WordPress project scaffold.
MIT License
205 stars 48 forks source link

Replace function files with module classes #247

Open tobeycodes opened 3 weeks ago

tobeycodes commented 3 weeks ago

https://github.com/10up/wp-scaffold/tree/trunk/themes/10up-theme/includes

We should be consistent with how we use actions/filters. Either we should use functions everywhere or classes everywhere.

darylldoyle commented 2 weeks ago

Thanks, @tobeycodes. I've added this to the Internal Tools working group agenda to be discussed. If you have any additional context/information that would be useful for those reviewing this, I'd greatly appreciate it if you could add it.

From my perspective, the issue here is that we have classes containing actions/filters, but then we also have functional PHP files containing actions/filters. The issue with mixing them is that:

  1. We end up with poorly organised code because engineers disagree about where the best place to put them is.
  2. Mixing functional and OOP code can be confusing when we could use OOP for everything.
  3. Having one or the other would make it easier to implement tests across projects/the scaffold as we'd need less manual loading.

Is there anything there you think I've missed?

tobeycodes commented 2 weeks ago

@darylldoyle Summed up perfectly