@artemsemkin/wp-headers 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +98 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,6 +8,101 @@ Generate and patch WordPress file headers from `package.json` data.
|
|
|
8
8
|
npm install @artemsemkin/wp-headers
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
## What it does
|
|
12
|
+
|
|
13
|
+
Reads `wp.theme` or `wp.plugin` fields from a `package.json` and writes properly formatted WordPress header comments to the corresponding files (`style.css`, plugin PHP, `readme.txt`). Also patches version strings in TGM-style plugin arrays.
|
|
14
|
+
|
|
15
|
+
## Examples
|
|
16
|
+
|
|
17
|
+
### Theme: `package.json` → `style.css`
|
|
18
|
+
|
|
19
|
+
Given this in your theme's `package.json`:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"name": "@starter/flavor-theme",
|
|
24
|
+
"version": "1.0.0",
|
|
25
|
+
"description": "A starter theme for WordPress",
|
|
26
|
+
"wp": {
|
|
27
|
+
"theme": {
|
|
28
|
+
"uri": "https://example.com/flavor",
|
|
29
|
+
"author": "Dev Studio",
|
|
30
|
+
"authorUri": "https://example.com",
|
|
31
|
+
"requires": "6.0",
|
|
32
|
+
"testedUpTo": "6.7",
|
|
33
|
+
"requiresPHP": "7.4",
|
|
34
|
+
"license": "GPL-2.0-or-later",
|
|
35
|
+
"licenseUri": "https://www.gnu.org/licenses/gpl-2.0.html",
|
|
36
|
+
"textDomain": "flavor",
|
|
37
|
+
"tags": ["blog", "one-column"]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Running `processMapping({ type: 'theme', slug: 'flavor', entityDir: '/path/to/theme' })` generates this `style.css`:
|
|
44
|
+
|
|
45
|
+
```css
|
|
46
|
+
/*
|
|
47
|
+
* Theme Name: Flavor
|
|
48
|
+
* Theme URI: https://example.com/flavor
|
|
49
|
+
* Author: Dev Studio
|
|
50
|
+
* Author URI: https://example.com
|
|
51
|
+
* Description: A starter theme for WordPress
|
|
52
|
+
* Version: 1.0.0
|
|
53
|
+
* Requires at least: 6.0
|
|
54
|
+
* Tested up to: 6.7
|
|
55
|
+
* Requires PHP: 7.4
|
|
56
|
+
* License: GPL-2.0-or-later
|
|
57
|
+
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
|
58
|
+
* Text Domain: flavor
|
|
59
|
+
* Tags: blog, one-column
|
|
60
|
+
*/
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Plugin: `package.json` → PHP header
|
|
64
|
+
|
|
65
|
+
Given this in your plugin's `package.json`:
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"name": "@starter/flavor-core",
|
|
70
|
+
"version": "1.0.0",
|
|
71
|
+
"description": "Core functionality for Flavor theme",
|
|
72
|
+
"wp": {
|
|
73
|
+
"plugin": {
|
|
74
|
+
"name": "Flavor Core",
|
|
75
|
+
"uri": "https://example.com/flavor-core",
|
|
76
|
+
"author": "Dev Studio",
|
|
77
|
+
"authorUri": "https://example.com",
|
|
78
|
+
"requires": "6.0",
|
|
79
|
+
"testedUpTo": "6.7",
|
|
80
|
+
"requiresPHP": "7.4",
|
|
81
|
+
"license": "GPL-2.0-or-later",
|
|
82
|
+
"textDomain": "flavor-core"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Running `processMapping({ type: 'plugin', slug: 'flavor-core', entityDir: '/path/to/plugin' })` generates this at the top of `flavor-core.php`:
|
|
89
|
+
|
|
90
|
+
```php
|
|
91
|
+
/**
|
|
92
|
+
* Plugin Name: Flavor Core
|
|
93
|
+
* Plugin URI: https://example.com/flavor-core
|
|
94
|
+
* Description: Core functionality for Flavor theme
|
|
95
|
+
* Version: 1.0.0
|
|
96
|
+
* Requires at least: 6.0
|
|
97
|
+
* Tested up to: 6.7
|
|
98
|
+
* Requires PHP: 7.4
|
|
99
|
+
* Author: Dev Studio
|
|
100
|
+
* Author URI: https://example.com
|
|
101
|
+
* License: GPL-2.0-or-later
|
|
102
|
+
* Text Domain: flavor-core
|
|
103
|
+
*/
|
|
104
|
+
```
|
|
105
|
+
|
|
11
106
|
## Usage
|
|
12
107
|
|
|
13
108
|
```ts
|
|
@@ -17,10 +112,10 @@ processMapping({
|
|
|
17
112
|
type: 'plugin',
|
|
18
113
|
slug: 'my-plugin',
|
|
19
114
|
entityDir: '/path/to/plugin',
|
|
20
|
-
tgmBasePath: '/path/to/theme/src/php',
|
|
115
|
+
tgmBasePath: '/path/to/theme/src/php', // optional: patches TGM version arrays
|
|
21
116
|
})
|
|
22
117
|
```
|
|
23
118
|
|
|
24
|
-
|
|
119
|
+
## Vite integration
|
|
25
120
|
|
|
26
|
-
|
|
121
|
+
Use [`@artemsemkin/vite-plugin-wp-headers`](https://github.com/artkrsk/vite-plugin-wp-headers) to run header generation during Vite's build lifecycle and watch for changes during dev.
|