10up / wp-scaffold

10up WordPress project scaffold.
MIT License
194 stars 46 forks source link

Simplify scaffold #207

Open tobeycodes opened 8 months ago

tobeycodes commented 8 months ago

I am starting this issue as a discussion. This scaffold has been used on several client projects and I feel like there is a lot of confusion from engineers on how to use it best. A few things I have noticed using wp-scaffold:

These are obviously just my opinions and others might not share these thoughts but I wanted to open up this discussion to see what others think.

fabiankaegy commented 7 months ago

Strong agree from my end on the duplication between the plugin and theme.

I run into so manny projects where the empty JS / CSS files that get loaded in the plugin and theme aren't even getting removed

darylldoyle commented 6 months ago

I also 100% agree with this, but, I don't think it's an easy solve.

My feeling on assets is that if it renders on the front-end it should live within the theme whereas if it only affects the admin, then it should be in the mu-plugin. I also feel that the crux of the issue is highlighted in your message

... engineers also do not have strong reasoning for placing PHP code in either the mu-plugin or the theme ... In my opinion unless it's rendering logic the code shouldn't be in the theme and we should discourage this ...

Whilst I completely agree with this, I don't think it's possible to enforce it. I think this has to be something that's documented and taught, rather than rules that we can set up within the codebase. Perhaps we should put some docs together around how to structure a site setup?

Finally, R.E. the mix of functional and OOP code, I'm with you - we should put together a PR to move this all to OOP code IMO. Then we can get rid of that dreaded $n() function at the same time.

tobeycodes commented 6 months ago

@darylldoyle I agree that it is not an easy solve but I think part of the problem comes from analysis paralysis with so much code duplicated across the scaffold. If we give too many options to solve the same problem they will never be solved in the same way. I don't think documentation is something that can solve this. I think being more opinionated + documentation will help to solve this problem. I think CPT/Taxonomies are a good example here, where we need to be opinionated with a CLI command that will do everything for us

My feeling on assets is that if it renders on the front-end it should live within the theme whereas if it only affects the admin, then it should be in the mu-plugin.

Agreed. Just deleting the frontend folders in the mu-plugin is a small start to moving in the right direction.