Documentation
Bones Console
Bones Console

Bones Command-Line Interface

Bones is also the name of the command-line interface included with WP Kirk template (opens in a new tab). It provides a number of helpful commands for your use while developing your plugin. You will use bones command-line interface to start your develop. First of all, try the command-line console by running:

php bones

Then, you can change the plugin namespace from WPKirk to MyFirstWPBonesPlugin, for example:

php bones rename 'My First WP Bones Plugin' MyFirstWPBonesPlugin

Awesome! You are quite ready to start to develop.

Update WP Bones

Of course, while you are in developing, you may update the WP Bones framework. You can do this by using update bones command:

php bones update

Versioning your Plugin

You can version your plugin by using:

php bones version 1.0.0

The above command will update the plugin version in the main plugin file and in the readme.txt file.

Despite php bones support the semantic versioning, we suggest you use the same version in the readme.txt file and in the main plugin file. In short avoid to use the v prefix in the version number.

You can see the help by using:

php bones version --help
 
readme.txt > 1.4.0 (Stable tag: 1.4.0)
index.php  > 1.4.0 ( * Version: 1.4.0)
 
Usage:
  version [plugin version]
 
Arguments:
  [plugin version]		    The version of plugin. Examples: '2.0',  'v1.2',  '1.2.0-rc.40', 'v1-beta.4'
  [--major]			        Increment the <major>.y.z of plugin.
  [--minor]			        Increment the x.<minor>.z of plugin.
  [--patch]			        Increment the x.y.<patch> of plugin.
  [--pre-patch] <prefix>	Increment the x.y.<patch>-<prefix>.<i> of plugin.
  [--pre-minor] <prefix>	Increment the x.<minor>.z-<prefix>.<i> of plugin.
  [--pre-major] <prefix>	Increment the <major>.y.z-<prefix>.<i> of plugin.

Available Options

The php bones version command can handle the version starting from the current version of the plugin. You can use the following options:

  • --major to increment the major version number. For example, if the current version is 1.0.0, the new version will be 2.0.0.
  • --minor to increment the minor version number. For example, if the current version is 1.0.0, the new version will be 1.1.0.
  • --patch to increment the patch version number. For example, if the current version is 1.0.0, the new version will be 1.0.1.

You can also use the --pre-patch, --pre-minor, and --pre-major options to increment the version with a prefix. For example, if the current version is 1.0.0, the new version will be 1.0.1-rc.1.

The default prefix is rc. But you can change it by using:

php bones version 1.0.0 --pre-patch beta

The above command will update the plugin version to 1.0.1-beta.1.

Deploy your Plugin

When your plugin is ready, you can use the deploy bones command in order to create a new folder useful to submit your plugin to the wordpress.org repository:

php bones deploy your-path/mydeploy

In the mydeploy folder you'll find only the needed files to run your plugin. For example, the developer resources/assets folder will be removed.

Customize Deploy

Of course, you may customize the deploy process by editing the deploy.php file. In this file you can add your own commands to run before and after the deploy. You will find also some actions and filters to customize the deploy process.

For example, you can add any custom command to run before the deploy by using:

/**
* Fired when the deploy command is started
*
* @param object $console Instance of WPBones Console
* @param string $path Destination path
*/
add_action('wpbones_console_deploy_start', function ($console, $path) {
    // Do something
}, 10, 2);

Or change the list of skipped files by using:

/**
* Filter the list of the folder to skip for the deploy version
*
* @param array $folders List of folders to skip
* @return array List of folders to skip
*/
add_filter('wpbones_console_deploy_skip_folders', function ($folders) {
    return $folders;
});

Creators

The Bones command console provides a set of commands to create some base classes. For example, you may create a Custom Post Type by using:

php bones make:cpt MyCustomPostTypeClass

Third-party Packages

You can install third-party packages by using:

php bones require <PackageName>

I advise you use this command instead of composer require because by doing so, an automatic renaming will be done.