@@ -286,6 +286,10 @@ function generateEnvSetup(string $opVaultId, string $opItemId, array $toggles):
286286 $ lines [] = '' ;
287287 $ lines [] = 'WP_THEMES="webentor-theme-v2" ' ;
288288 $ lines [] = '' ;
289+ $ lines [] = '# Relative path from project root to the themes directory. ' ;
290+ $ lines [] = '# Default: web/app/themes (Bedrock). Use wp-content/themes for traditional WP. ' ;
291+ $ lines [] = 'WP_THEMES_DIR=web/app/themes ' ;
292+ $ lines [] = '' ;
289293 $ lines [] = '# Setup runtime feature toggles. ' ;
290294 $ lines [] = '# These values are project-owned and intentionally outside setup subtree updates. ' ;
291295
@@ -676,12 +680,40 @@ function detectConfigsVersion(string $cwd): ?string
676680}
677681
678682/**
679- * Iterate theme directories under web/app/themes and apply $extractor to parsed JSON.
683+ * Read WP_THEMES_DIR from scripts/.env.setup with fallback to web/app/themes.
684+ */
685+ function resolveThemesDir (string $ cwd ): string
686+ {
687+ $ envSetupPath = "{$ cwd }/scripts/.env.setup " ;
688+ if (file_exists ($ envSetupPath )) {
689+ $ lines = file ($ envSetupPath , FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES );
690+ if ($ lines !== false ) {
691+ foreach ($ lines as $ line ) {
692+ $ line = trim ($ line );
693+ if ($ line === '' || str_starts_with ($ line , '# ' )) {
694+ continue ;
695+ }
696+ if (str_starts_with ($ line , 'WP_THEMES_DIR= ' )) {
697+ $ value = substr ($ line , strlen ('WP_THEMES_DIR= ' ));
698+ $ value = trim ($ value , "\"' \t" );
699+ if ($ value !== '' ) {
700+ return $ value ;
701+ }
702+ }
703+ }
704+ }
705+ }
706+
707+ return 'web/app/themes ' ;
708+ }
709+
710+ /**
711+ * Iterate theme directories and apply $extractor to parsed JSON.
680712 * Returns the first non-null result.
681713 */
682714function scanThemeFiles (string $ cwd , string $ filename , callable $ extractor ): ?string
683715{
684- $ themesPath = "{$ cwd }/web/app/themes " ;
716+ $ themesPath = "{$ cwd }/ " . resolveThemesDir ( $ cwd ) ;
685717 if (!is_dir ($ themesPath )) {
686718 return null ;
687719 }
0 commit comments