@artemsemkin/wp-headers 1.2.1 → 1.2.5
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 +63 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -58,6 +58,16 @@ Running `processMapping({ type: 'theme', slug: 'flavor', entityDir: '/path/to/th
|
|
|
58
58
|
* Text Domain: flavor
|
|
59
59
|
* Tags: blog, one-column
|
|
60
60
|
*/
|
|
61
|
+
|
|
62
|
+
html {
|
|
63
|
+
margin-top: 0 !important;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
img,
|
|
67
|
+
video {
|
|
68
|
+
max-width: 100%;
|
|
69
|
+
height: auto;
|
|
70
|
+
}
|
|
61
71
|
```
|
|
62
72
|
|
|
63
73
|
### Plugin: `package.json` → PHP header
|
|
@@ -88,6 +98,7 @@ Given this in your plugin's `package.json`:
|
|
|
88
98
|
Running `processMapping({ type: 'plugin', slug: 'flavor-core', entityDir: '/path/to/plugin' })` generates or updates the header at the top of `flavor-core.php`:
|
|
89
99
|
|
|
90
100
|
```php
|
|
101
|
+
<?php
|
|
91
102
|
/**
|
|
92
103
|
* Plugin Name: Flavor Core
|
|
93
104
|
* Plugin URI: https://example.com/flavor-core
|
|
@@ -101,29 +112,69 @@ Running `processMapping({ type: 'plugin', slug: 'flavor-core', entityDir: '/path
|
|
|
101
112
|
* License: GPL-2.0-or-later
|
|
102
113
|
* Text Domain: flavor-core
|
|
103
114
|
*/
|
|
115
|
+
|
|
116
|
+
defined( 'ABSPATH' ) || exit;
|
|
117
|
+
|
|
118
|
+
define( 'FLAVOR_CORE_VERSION', '1.0.0' );
|
|
119
|
+
define( 'FLAVOR_CORE_PATH', plugin_dir_path( __FILE__ ) );
|
|
120
|
+
|
|
121
|
+
require_once FLAVOR_CORE_PATH . 'inc/class-flavor-core.php';
|
|
122
|
+
|
|
123
|
+
load_plugin_textdomain( 'flavor-core', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
|
|
104
124
|
```
|
|
105
125
|
|
|
106
126
|
### TGM version patching
|
|
107
127
|
|
|
108
|
-
When a plugin's `package.json` includes `wp.plugin.loadPluginsFile`, the tool
|
|
128
|
+
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.
|
|
129
|
+
|
|
130
|
+
Given this TGM registration file in your theme:
|
|
109
131
|
|
|
110
132
|
```php
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
133
|
+
<?php
|
|
134
|
+
|
|
135
|
+
add_action( 'tgmpa_register', 'flavor_tgm_register_required_plugins' );
|
|
136
|
+
function flavor_tgm_register_required_plugins() {
|
|
137
|
+
$plugins = array(
|
|
138
|
+
// Bundled plugins — have a version constraint
|
|
139
|
+
array(
|
|
140
|
+
'name' => 'Flavor Core',
|
|
141
|
+
'slug' => 'flavor-core',
|
|
142
|
+
'source' => esc_url( $core_plugin_url ),
|
|
143
|
+
'required' => true,
|
|
144
|
+
'version' => '1.0.0',
|
|
145
|
+
),
|
|
146
|
+
array(
|
|
147
|
+
'name' => 'Flavor Elementor Extension',
|
|
148
|
+
'slug' => 'flavor-elementor-extension',
|
|
149
|
+
'source' => esc_url( $elementor_plugin_url ),
|
|
150
|
+
'required' => true,
|
|
151
|
+
'version' => '1.0.0',
|
|
152
|
+
),
|
|
153
|
+
// Third-party plugins — no version field, pulled from wp.org
|
|
154
|
+
array(
|
|
155
|
+
'name' => 'Elementor',
|
|
156
|
+
'slug' => 'elementor',
|
|
157
|
+
'required' => true,
|
|
158
|
+
),
|
|
159
|
+
array(
|
|
160
|
+
'name' => 'Contact Form 7',
|
|
161
|
+
'slug' => 'contact-form-7',
|
|
162
|
+
'required' => false,
|
|
163
|
+
),
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
tgmpa( $plugins, $config );
|
|
167
|
+
}
|
|
118
168
|
```
|
|
119
169
|
|
|
120
|
-
|
|
170
|
+
When `flavor-core`'s `package.json` has `"version": "2.0.0"`, processing updates only the matching entry — the Elementor and Contact Form 7 entries are left untouched because they don't have a `version` field and their slugs don't match:
|
|
121
171
|
|
|
122
|
-
```
|
|
123
|
-
|
|
172
|
+
```diff
|
|
173
|
+
- 'version' => '1.0.0',
|
|
174
|
+
+ 'version' => '2.0.0',
|
|
124
175
|
```
|
|
125
176
|
|
|
126
|
-
Whitespace alignment, quote styles, and other entries are preserved.
|
|
177
|
+
Whitespace alignment, quote styles, nested function calls, and other plugin entries are preserved.
|
|
127
178
|
|
|
128
179
|
## Usage
|
|
129
180
|
|