Repository navigation
Commit f2f6af2
authored
Fix Plugin/Theme header detection in PHP docblocks (#103)
## Summary
`detectPluginHeaderFromPhpFile` and `parsePluginHeader` failed on
standard WordPress plugin headers because the regex required only
leading whitespace before the label:
```js
/^\s*Plugin Name:\s*(.+)\s*$/im
```
A typical header line is ` * Plugin Name: Foo` — the `*` is not
whitespace — so detection returned `null` / `count: 0` for every normal
plugin.
### Before
```js
contents.match(/^\s*Plugin Name:\s*(.+)\s*$/im)
// Theme Name similarly
new RegExp(`^\\s*${label}:\\s*(.+)\\s*$`, "im")
```
### After
```js
contents.match(/^\s*\*?\s*Plugin Name:\s*(.+)\s*$/im)
contents.match(/^\s*\*?\s*Theme Name:\s*(.+)\s*$/im)
new RegExp(`^\\s*\\*?\\s*${label}:\\s*(.+)\\s*$`, "im")
```
Optional docblock star keeps bare `Plugin Name:` / `Theme Name:` lines
working (e.g. theme `style.css`).
## Files
- `skills/wp-project-triage/scripts/detect_wp_project.mjs`
- `skills/wp-plugin-development/scripts/detect_plugins.mjs`
## Verification (local fixtures)
Against a docblock-style plugin (` * Plugin Name: WP Hello Plugin`):
- `detect_wp_project` → `primary: "wp-plugin"`, `detectedPluginName: "WP
Hello Plugin"`
- `detect_plugins` → `count: 1`
Against empty non-WP dir: still `unknown` / `count: 0`.
Against block theme fixture: still `wp-block-theme` with
`detectedThemeName` set.1 parent ad58e37 commit f2f6af2
2 files changed
Lines changed: 3 additions & 3 deletions
File tree
- skills
- wp-plugin-development/scripts
- wp-project-triage/scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
| 135 | + | |
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| |||
0 commit comments