xwp / site-monorepo-example

1 stars 3 forks source link

Keep theme code in a subdirectory #3

Open szepeviktor opened 2 years ago

szepeviktor commented 2 years ago

e.g. theme like in https://github.com/timber/starter-theme/tree/2.x

Again: separation of config files, documents -------------- and -------------- application code.

πŸ¦ΈπŸ»β€β™‚οΈ This is a secret WordPress core feature, needs no configuration at all.

kasparsd commented 2 years ago

Can you please elaborate on this one? This already has the theme in a sub-directory.

The prototype is specifically attempting to design a system where some themes, plugins and other dependencies would be developed as part of the same repo. The reason for that is to avoid the composer version update dance whenever a set of dependencies are updated.

Do you know any projects that do this?

szepeviktor commented 2 years ago

Do you know any projects that do this?

Yes. Timber: https://github.com/timber/starter-theme/tree/2.x

Currently two kind of files are mixed.

  1. config files, for example package-lock.json
  2. and theme code, for example functions.php

Simply create a subdirectory inside the theme and move theme code into that directory: https://github.com/timber/starter-theme/tree/2.x/theme

So clean, @kasparsd. So clean!

szepeviktor commented 2 years ago

🀫 WP core's code that finds this subdirectory automatically: https://github.com/WordPress/WordPress/blob/89e99f57a2a175ccb75282d1a7eefb0bfce94bcb/wp-includes/theme.php#L515