Title: WP-CLI support
Last modified: August 21, 2016

---

# WP-CLI support

 *  [Dereckson](https://wordpress.org/support/users/dereckson/)
 * (@dereckson)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/wp-cli-support/)
 * WP-CLI is a command line interface for WordPress to ease both system administration
   and DevOps work.
 * On the DevOps side, I’m working on a CI project where I wish to deploy and configure
   a WordPress engine from a unique Makefile.
 * I so added support for your Polylang plug-in to WP-CLI:
 * * WP-CLI support: [https://github.com/dereckson/polylang/compare/feature%2Fapi…feature%2Fcli?expand=1](https://github.com/dereckson/polylang/compare/feature%2Fapi…feature%2Fcli?expand=1)
   *
   API new methods for this support: [https://github.com/dereckson/polylang/compare/feature;api?expand=1](https://github.com/dereckson/polylang/compare/feature;api?expand=1)
 * The goal is to be able to add languages with the default configuration with commands
   like:
    wp polylang language add en wp polylang language add nl wp polylang language
   add fr
 * This is my work in progress of my afternoon work, for comments and code review.
 * I’m soon intending to offer a more formal patch, when the language delete command.
 * Are you interested to implement this CLI support in your plugin?
 * [https://wordpress.org/plugins/polylang/](https://wordpress.org/plugins/polylang/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [Dereckson](https://wordpress.org/support/users/dereckson/)
 * (@dereckson)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/wp-cli-support/#post-4629234)
 * Oh a little demo of what we can do with a command line support:
 *     ```
       $ wp polylang language info fr
       Code:      fr
       Locale     fr_FR
       Name:      Français
       RTL:       no
       Installed: yes
   
       $ wp polylang get post 1 en
       1
   
       $ wp polylang get post 1 fr
       7
   
       $ wp polylang languages
       fr — Français [DEFAULT]
       en — English
   
       $ wp polylang language add nl
       Success: language added.
   
       $ wp polylang languages
       fr — Français [DEFAULT]
       en — English
       nl — Nederlands
   
       $ wp polylang language del xx
       Error: xx isn't a valid language code.
   
       $ wp polylang language del eo
       Warning: This language isn't installed.
   
       $ wp polylang home nl
       http://wordpresslanguagestack.threyscend.drake/nl
       ```
   
 *  Plugin Author [Chouby](https://wordpress.org/support/users/chouby/)
 * (@chouby)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/wp-cli-support/#post-4629467)
 * I don’t use WP-CLI, but such functionality may interest some other users.
 * Just some comments / questions:
    Why did you not include all the code in the 
   Polylang_Command class? Is there a specific reason for adding these two lines
 *     ```
       if (defined('WP_CLI') && WP_CLI)
       	require_once(PLL_INC.'/cli.php');
       ```
   
 * in polylang.php, rather than making a separate plugin?
 * There was also [this question](http://wordpress.org/support/topic/wp-cli) a couple
   of months ago. Do you set the language of a post / term using WP-CLI? Or maybe
   you just setup the website and don’t add content.
 *  Thread Starter [Dereckson](https://wordpress.org/support/users/dereckson/)
 * (@dereckson)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/wp-cli-support/#post-4629482)
 * **How to offer a WP-CLI command.**
 * There are three strategies to offer a WP-CLI command:
 * (1) in WP-CLI itself, for WordPress core (not usable here so)
 * (2) in a plug-in
 * (3) as a WP-CLI community package
 * For 3, the requirement is to have a repository with Polylang_Command class file,
   and a JSON Composer file to load it:
    [https://github.com/dereckson/wp-cli-polylang/blob/master/composer.json](https://github.com/dereckson/wp-cli-polylang/blob/master/composer.json)
 * The drawback of a community package is it requires an extra installation. If 
   we include it directly in the plug-in, every Polylang user who have WP-CLI installed
   has access to the command.
 * There is a slight advantage for the community package: it’s listed on [http://wp-cli.org/package-index/](http://wp-cli.org/package-index/).
 * I don’t know the best solution.
 * **The WP-CLI interest in Polylang context.**
 * WP-CLI becomes more and more mainstream. WP-CLI is included in some popular hosting
   companies like MediaTemple or DreamHost. It’s also available on [http://vip.wordpress.com/](http://vip.wordpress.com/).
 * It allows to do continuous integration like Puppet/Chef/Ansible VM provisioning,
   run tests on Jenkins, etc.
 * For a small project, it allows to deliver to the customer two files: a description
   file (like a Composer.json) and a task runner file (a plain old Makefile, or 
   something more modern like Grun). Then, writing `make` or `grunt`, WordPress 
   and the plug-ins repo are cloned, installed in the relevant directories. WP-CLI
   allows at this stage to add some configuration.
 * For example:
 *     ```
       ...
       wp option add sitetitle "Agentschap agentschappen"
       wp polylang language add en
       wp polylang language add fr
       wp polylang language add nl
       ...
       ```
   
 * I found that very interesting to automate stuff.
 * **Features.**
 * > There was also this question a couple of months ago. Do you set the language
   > of a post / term using WP-CLI? Or maybe you just setup the website and don’t
   > add content.
 * Yes, we could add this, it’s a good idea.
 * For example, [http://wp-cli.org/commands/post/](http://wp-cli.org/commands/post/)
   allows to create a new post and [http://wp-cli.org/commands/post-meta/](http://wp-cli.org/commands/post-meta/)
   to set meta options.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘WP-CLI support’ is closed to new replies.

 * ![](https://ps.w.org/polylang/assets/icon-256x256.png?rev=3433336)
 * [Polylang](https://wordpress.org/plugins/polylang/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/polylang/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/polylang/)
 * [Active Topics](https://wordpress.org/support/plugin/polylang/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/polylang/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/polylang/reviews/)

## Tags

 * [api](https://wordpress.org/support/topic-tag/api/)
 * [cli](https://wordpress.org/support/topic-tag/cli/)
 * [code review](https://wordpress.org/support/topic-tag/code-review/)

 * 3 replies
 * 2 participants
 * Last reply from: [Dereckson](https://wordpress.org/support/users/dereckson/)
 * Last activity: [12 years, 2 months ago](https://wordpress.org/support/topic/wp-cli-support/#post-4629482)
 * Status: not resolved