@artemsemkin/wp-headers 1.2.1 → 1.2.2

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.
Files changed (2) hide show
  1. package/README.md +31 -12
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -105,25 +105,44 @@ Running `processMapping({ type: 'plugin', slug: 'flavor-core', entityDir: '/path
105
105
 
106
106
  ### TGM version patching
107
107
 
108
- When a plugin's `package.json` includes `wp.plugin.loadPluginsFile`, the tool also patches version strings inside TGM-style PHP arrays. Given this PHP file registered via `tgmBasePath`:
108
+ WordPress themes commonly use TGMPA to register required plugins with minimum version constraints. When a plugin's `package.json` includes `wp.plugin.loadPluginsFile`, the tool finds the matching slug in the TGM PHP file and patches its version string.
109
+
110
+ Given this TGM registration file in your theme:
109
111
 
110
112
  ```php
111
- $plugins = array(
112
- array(
113
- 'name' => 'Flavor Core',
114
- 'slug' => 'flavor-core',
115
- 'version' => '1.0.0',
116
- ),
117
- );
113
+ <?php
114
+
115
+ add_action( 'tgmpa_register', 'flavor_tgm_register_required_plugins' );
116
+ function flavor_tgm_register_required_plugins() {
117
+ $plugins = array(
118
+ array(
119
+ 'name' => 'Flavor Core',
120
+ 'slug' => 'flavor-core',
121
+ 'source' => esc_url( $core_plugin_url ),
122
+ 'required' => true,
123
+ 'version' => '1.0.0',
124
+ ),
125
+ array(
126
+ 'name' => 'Flavor Elementor',
127
+ 'slug' => 'flavor-elementor',
128
+ 'source' => esc_url( $elementor_plugin_url ),
129
+ 'required' => true,
130
+ 'version' => '1.0.0',
131
+ ),
132
+ );
133
+
134
+ tgmpa( $plugins, $config );
135
+ }
118
136
  ```
119
137
 
120
- After processing with `version: "2.0.0"` in `package.json`, the version field is updated in place:
138
+ When `flavor-core`'s `package.json` has `"version": "2.0.0"`, processing updates only the matching entry:
121
139
 
122
- ```php
123
- 'version' => '2.0.0',
140
+ ```diff
141
+ - 'version' => '1.0.0',
142
+ + 'version' => '2.0.0',
124
143
  ```
125
144
 
126
- Whitespace alignment, quote styles, and other entries are preserved.
145
+ Whitespace alignment, quote styles, nested function calls, and other plugin entries are preserved.
127
146
 
128
147
  ## Usage
129
148
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artemsemkin/wp-headers",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Generate and patch WordPress file headers (style.css, plugin PHP, readme.txt, TGM)",
5
5
  "license": "MIT",
6
6
  "author": "Artem Semkin",