moderntribe / square1-generators
Code generators for Square One
Installs: 1 354
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 19
Forks: 0
Open Issues: 0
pkg:composer/moderntribe/square1-generators
Requires
- php: >=7.4
- moderntribe/square1-cli: ^4.2
- moderntribe/square1-container: ^4.2
- 4.x-dev
- 4.2.0
- dev-master / 4.1.x-dev
- 4.1.0
- 4.0.16
- 4.0.15
- 4.0.13
- 4.0.12
- 4.0.8
- 4.0.7
- 4.0.5
- 4.0.4
- 4.0.3
- 3.6.0
- 3.5.1
- 3.5.0
- 3.4.18
- 3.4.17
- 3.4.16
- 3.4.15
- 3.4.14
- 3.4.13
- 3.4.12
- 3.4.11
- 3.4.10
- 3.4.9
- 3.4.8
- 3.4.7
- 3.4.6
- v3.4.4
- v3.4.2
- v3.4.1
- v3.4.0
- v3.3.0
- v3.2.0
- v3.1.2
- v3.1.1
- v3.1.0
- v3.0.0
- 2.1.2
- v2.1.1
- v2.0.0
- 0.0.2
- 0.0.1
- dev-bugfix/taxonomy-cs-fix
- dev-bugfix/post-type-cs-fix
- dev-feature/monorepo
This package is auto-updated.
Last update: 2025-10-25 23:21:46 UTC
README
A code generator utility to automate some of the repetitive tasks of building out a project with Square One. The WP CLI commands provided by this package will create stub files to set you on the right path for your custom work.
Component Generator
wp s1 generate component <component>
Generates the assorted files required for a theme component.
Example usage:
wp s1 generate component link
This will create six files for you in the theme:
components/link/link.phpcomponents/link/Link_Controller.phpcomponents/link/index.pcsscomponents/link/css/link.pcsscomponents/link/index.jscomponents/link/js/link.js
The template (link.php) and the Controller class (Link_Controller.php) will be stubbed out with
common properties.
Use --no-template to skip the template.
Use --no-controller to skip the Controller class.
Use --no-css to skip the CSS files.
Use --no-js to skip the JS files.
The --dry-run flag will show you the files the command would create, without writing to the file system.
You can use this command to generate components in nested directories. For example,
wp s1 generate component content/event ... would create the component in components/content/event.
All PHP classes will have their namespaces adjusted to reflect their position in the hierarchy.
Post Type Generator
wp s1 generate cpt <cpt> [--single=<single>] [--plural=<plural>]
Generates the files required for a custom post type.
Example usage:
wp s1 generate cpt document --single="Document" --plural="Documents"
This will create three files for you in the core plugin:
src/Post_Types/Document/Document.phpsrc/Post_Types/Document/Config.phpsrc/Post_Types/Document/Subscriber.php
And it will add a reference to the subscriber in Tribe\Project\Core.
Taxonomy Generator
wp s1 generate tax <taxonomy> [--post-types=<post-types>] [--single=<single>] [--plural=<plural>]
Generates the files required for a custom taxonomy.
Example usage:
wp s1 generate tax classification --post-types="page,post" --single="Classification" --plural="Classifications"
This will create three files for you in the core plugin:
src/Taxonomies/Classification/Classification.phpsrc/Taxonomies/Classification/Config.phpsrc/Taxonomies/Classification/Subscriber.php
And it will add a reference to the subscriber in Tribe\Project\Core.
Block Generator
wp s1 generate block <name>
Generate the files required to register a new block with ACF.
Example usage:
wp s1 generate block image-gallery
This will create two files for you in the core plugin:
src/Blocks/Types/Image_Gallery/Image_Gallery.phpsrc/Blocks/Types/Image_Gallery/Image_Gallery_Model.php
And create the block template in the theme:
blocks/imagegallery.php
And then delegates to the component generator (see above) to generate
the image_gallery component.
The --dry-run flag will show you the files the command would create, without writing to the file system.
Example with Post Loop Field Middleware:
wp s1 generate block image-gallery --with-post-loop-field-middleware
Settings Page Generator
TODO: write documentation for the settings page generator
CLI Command Generator
TODO: write documentation for the CLI command generator
Image Size Generator
wp s1 generate image-size <name> [--width=<width>] [--height=<height>] [--ratio=<ratio>] [--crop=<crop>]
Adds an image size to the core plugin's Image_Sizes class.
Example usage:
wp s1 generate image-size test-size --width=1000 --ratio=0.75 --crop=left,top
This will add the constant TEST_SIZE to the Image_Sizes class and add this definition to the
$sizes array:
self::TEST_SIZE => [
'width' => 1000,
'height' => 750,
'crop' => [ 'left', 'top' ],
]