npx @wordpress/create-block - text-domain should match block slug not internal namespace #24362
Labels
[Status] In Progress
Tracking issues with work in progress
[Tool] Create Block
/packages/create-block
Describe the bug
While the output produced by running
npx @wordpress/create-block
does successfully create a WordPress plugin and a block that is expected to work, there are several problems with the generated code.The biggest one is that the generated code doesn't conform to WordPress guidelines.
From https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/#text-domains
The text domain must match the slug of the plugin. If your plugin is a single file called my-plugin.php or it is contained in a folder called my-plugin the domain name must be my-plugin. If your plugin is hosted on wordpress.org it must be the slug portion of your plugin URL (wordpress.org/plugins/).
In the generated code the text-domain is set to the same value as the prefix for the block, the internal namespace.
It should be set to the block slug used for identification, the plugin slug.
To reproduce
Steps to reproduce the behavior:
npx @wordpress/create-block
from the plugins directory.Step 2. Responses to create the 'on-this-day' plugin
Expected behavior
oik-sb
. It should beon-this-day
, the same name as the plugin.Other errant/missing behavior that could be improved
The single quotes in the short description came out as
'
See screenshot.additional work is needed to enable internationalization and localization
wp_set_script_translations
.load_plugin_textdomain
npm run makepot
andnpm run makejson
.there's a reasonable chance that the generated plugin doesn't coexist peacefully with any other plugins, generated then subsequently modified and built with
npm run build
. see @wordpress/scripts: React.createElement type is invalid when two single block plugins are built usingnpm run build
#24321Question: Should
package.log.json
be listed in.gitignore
?The throw new error logic, invoked when
index.asset.php
is not present, is a very poor user experience. A Fatal error from which an end user may have great difficulty recovering.Screenshots
Desktop (please complete the following information):
Additional context
node version: v10.13.0
npm version: 6.14.5
from
package.json
The text was updated successfully, but these errors were encountered: