This is a CLI that adds a README, .gitignore
or composer.json
file to your custom WordPress theme or plugin to make your WordPress asset compatible with Composer and/or Bedrock.
- Requires: coreutils. This enables the
-f
option in thereadlink
command to work. Note: this is not required if using MacOS v12.3 or greater or if using Linux systems. You can install it from your terminal using the commandbrew install coreutils
. - Tested on: MacOS v10.15.7
The CLI uses the following syntax:
wp-template [-h|mu|p|t|V] [-a|i|m] [replace-string]
The options include:
h
: Shows the Help for the CLI.mu
: Copy the mu-plugincomposer.json
template.p
: Copy the plugincomposer.json
template.t
: Copy the themecomposer.json
template.V
: Prints the software version and exits.a
: Automatic mode. Adds in any of the missing recommended files.i
: Interactive mode. Includes the missing recommended files with step by step prompts.m
: Manual mode (lets you update the template files yourself).replace-string
: Replaces the default name of plugin or theme in composer.json file with custom name.
NB: These installation instructions work on Mac OS. The instructions may work in similar fashion on Linux or Windows, or you may need to use equivalent commands.
- Clone this repository to your system.
- Make the script in the root folder a CLI by making a symlink of the script to the path where your other commands are stored:
- The path you will want to make the symlink in will most likely
/usr/local/bin
, but you can verify which directories are in your$PATH
and the correct path to use with the commandecho $PATH | tr \: \\n
. - Find the path for the root folder of the
wp-template.sh
file usingpwd
in your terminal. - Enter the command
ln -s `pwd`/wp-template.sh /path/to/directory/wp-template
from the root folder of this project. For example, if you'd like to add a symlink of the script located in~/wp-template
to/usr/local/bin
, type the commandln -s `pwd`/wp-template.sh /usr/local/bin/wp-template
.
- The path you will want to make the symlink in will most likely
You should now be able to use the command wp-template
in the root folder of your WordPress theme or plugin and easily add the missing recommended files to it. Enjoy!