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.
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.
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.
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.
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
TODO: write documentation for the settings page generator
TODO: write documentation for the CLI command 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' ],
]