Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Block: Allow external templates to customize more fields #68193

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
* Description: {{description}}
{{/description}}
* Version: {{version}}
* Requires at least: 6.6
* Requires PHP: 7.2
{{#requiresAtLeast}}
* Requires at least: {{requiresAtLeast}}
{{/requiresAtLeast}}
{{#requiresPHP}}
* Requires PHP: {{requiresPHP}}
{{/requiresPHP}}
{{#author}}
* Author: {{author}}
{{/author}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
Contributors: {{author}}
{{/author}}
Tags: block
Tested up to: 6.6
{{#testedUpTo}}
Tested up to: {{testedUpTo}}
{{/testedUpTo}}
Stable tag: {{version}}
{{#license}}
License: {{license}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
* Description: {{description}}
{{/description}}
* Version: {{version}}
* Requires at least: 6.6
* Requires PHP: 7.2
{{#requiresAtLeast}}
* Requires at least: {{requiresAtLeast}}
{{/requiresAtLeast}}
{{#requiresPHP}}
* Requires PHP: {{requiresPHP}}
{{/requiresPHP}}
{{#author}}
* Author: {{author}}
{{/author}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
Contributors: {{author}}
{{/author}}
Tags: block
Tested up to: 6.6
{{#testedUpTo}}
Tested up to: {{testedUpTo}}
{{/testedUpTo}}
Stable tag: {{version}}
{{#license}}
License: {{license}}
Expand Down
1 change: 1 addition & 0 deletions packages/create-block/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Enhancement

- Add support for custom `textdomain` property for the scaffolded block ([#57197](https://github.com/WordPress/gutenberg/pull/57197)).
- Allow external templates to customize additional plugin header and readme fields: "Requires at least", "Requires PHP", and "Tested up to" ([#68193](https://github.com/WordPress/gutenberg/pull/68193))

### Internal

Expand Down
6 changes: 5 additions & 1 deletion packages/create-block/docs/external-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,13 @@ The following configurable variables are used with the template files. Template
- `npmDevDependencies` (default: `[]`) – the list of remote npm packages to be installed in the project with [`npm install --save-dev`](https://docs.npmjs.com/cli/v8/commands/npm-install) when `wpScripts` is enabled.
- `customPackageJSON` (no default) - allows definition of additional properties for the generated package.json file.

**Plugin header fields** ([learn more](https://developer.wordpress.org/plugins/plugin-basics/header-requirements/)):
**Plugin header and readme fields** (learn more about [header requirements](https://developer.wordpress.org/plugins/plugin-basics/header-requirements/) and [readmes](https://developer.wordpress.org/plugins/wordpress-org/how-your-readme-txt-works/)):

- `pluginURI` (no default) – the home page of the plugin.
- `version` (default: `'0.1.0'`) – the current version number of the plugin.
- `requiresAtLeast` (default: `'6.7'`) – the lowest WordPress version that the plugin will work on.
- `requiresPHP` (default: `'7.4'`) – the minimum required PHP version for use with this plugin.
- `testedUpTo` (default: `'6.7'`) – the highest WordPress version that the plugin has been tested against.
- `author` (default: `'The WordPress Contributors'`) – the name of the plugin author(s).
- `license` (default: `'GPL-2.0-or-later'`) – the short name of the plugin’s license.
- `licenseURI` (default: `'https://www.gnu.org/licenses/gpl-2.0.html'`) – a link to the full text of the license.
Expand All @@ -97,6 +100,7 @@ The following configurable variables are used with the template files. Template
- `description` (no default) – a short description for your block.
- `dashicon` (no default) – an icon property thats makes it easier to identify a block ([available values](https://developer.wordpress.org/resource/dashicons/)).
- `category` (default: `'widgets'`) – blocks are grouped into categories to help users browse and discover them. The categories provided by core are `text`, `media`, `design`, `widgets`, `theme`, and `embed`.
- `textdomain` (defaults to the `slug` value) – the text domain used to make strings translatable ([more info](https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/#text-domains)).
- `attributes` (no default) – block attributes ([more details](https://developer.wordpress.org/block-editor/developers/block-api/block-attributes/)).
- `supports` (no default) – optional block extended support features ([more details](https://developer.wordpress.org/block-editor/developers/block-api/block-supports/).
- `editorScript` (default: `'file:./index.js'`) – an editor script definition.
Expand Down
6 changes: 6 additions & 0 deletions packages/create-block/lib/scaffold.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ module.exports = async (
domainPath,
updateURI,
version,
requiresAtLeast,
requiresPHP,
testedUpTo,
wpScripts,
wpEnv,
npmDependencies,
Expand Down Expand Up @@ -79,6 +82,9 @@ module.exports = async (
domainPath,
updateURI,
version,
requiresAtLeast,
requiresPHP,
testedUpTo,
wpScripts,
wpEnv,
npmDependencies,
Expand Down
3 changes: 3 additions & 0 deletions packages/create-block/lib/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ const getDefaultValues = ( projectTemplate, variant ) => {
license: 'GPL-2.0-or-later',
licenseURI: 'https://www.gnu.org/licenses/gpl-2.0.html',
version: '0.1.0',
requiresAtLeast: '6.7',
requiresPHP: '7.4',
testedUpTo: '6.7',
wpScripts: true,
customScripts: {},
wpEnv: false,
Expand Down
8 changes: 6 additions & 2 deletions packages/create-block/lib/templates/es5/$slug.php.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
{{#description}}
* Description: {{description}}
{{/description}}
* Requires at least: 6.6
* Requires PHP: 7.2
* Version: {{version}}
{{#requiresAtLeast}}
* Requires at least: {{requiresAtLeast}}
{{/requiresAtLeast}}
{{#requiresPHP}}
* Requires PHP: {{requiresPHP}}
{{/requiresPHP}}
{{#author}}
* Author: {{author}}
{{/author}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
Contributors: {{author}}
{{/author}}
Tags: block
Tested up to: 6.6
{{#testedUpTo}}
Tested up to: {{testedUpTo}}
{{/testedUpTo}}
Stable tag: {{version}}
{{#license}}
License: {{license}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
{{#description}}
* Description: {{description}}
{{/description}}
* Requires at least: 6.6
* Requires PHP: 7.2
* Version: {{version}}
{{#requiresAtLeast}}
* Requires at least: {{requiresAtLeast}}
{{/requiresAtLeast}}
{{#requiresPHP}}
* Requires PHP: {{requiresPHP}}
{{/requiresPHP}}
{{#author}}
* Author: {{author}}
{{/author}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
Contributors: {{author}}
{{/author}}
Tags: block
Tested up to: 6.6
{{#testedUpTo}}
Tested up to: {{testedUpTo}}
{{/testedUpTo}}
Stable tag: {{version}}
{{#license}}
License: {{license}}
Expand Down
Loading