Welcome to WP-CLIWP-CLIWP-CLI is the Command Line Interface for WordPress, used to do administrative and development tasks in a programmatic way. The project page is http://wp-cli.org/https://make.wordpress.org/cli/!
WP-CLI is the official command line tool for interacting with and managing your WordPress sites.
If you want to create your plugins, WP-CLIWP-CLIWP-CLI is the Command Line Interface for WordPress, used to do administrative and development tasks in a programmatic way. The project page is http://wp-cli.org/https://make.wordpress.org/cli/ has a powerful scaffold command that allows us to generate starter code. In this guide we will see how to generate starter code for a basic pluginPluginA plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party.
The following command uses several options to lets us specify the plugin slug, its name, description, author name and uri as well as the plugin uri. You can replace the values passed to the options below to customize the plugin based on your needs.
$ wp scaffold plugin wpcli-demo-plugin --plugin_name="WP-CLI Demo Plugin" --plugin_description="This is a wp-cli demo plugin" --plugin_author=wp-cli --plugin_author_uri="https://wp-cli.org" --plugin_uri="https://plugins.wp-cli.org/demo-plugin"
Success: Created test files.
The above command generates a new folder called wpcli-demo-plugin in the plugins directory, with the following files structure.
We can now use the scaffold command again to add a custom post typeCustom Post TypeWordPress can hold and display many different types of content. A single item of such a content is generally called a post, although post is also a specific post type. Custom Post Types gives your site the ability to have templated posts, to simplify the concept. inside our new plugin using the wp scaffold post-type command.
You can now use two wp-cli commands to check the list of plugins and activate your newly created plugin. wp plugin list and wp plugin activate. The first command lists all plugins installed while the second
activates a given plugin.
$ wp plugin list
+-------------------+----------+-----------+---------+
| name | status | update | version |
+-------------------+----------+-----------+---------+
| akismet | inactive | available | 4.1.5 |
| hello | inactive | none | 1.7.2 |
| wpcli-demo-plugin | inactive | none | 0.1.0 |
+-------------------+----------+-----------+---------+
From the list above we can see that our plugin wpcli-demo-plugin is inactive. Let’s enable it using the other command.