Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Dereckson

    (@dereckson)

    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
    https://wordpresslanguagestack.threyscend.drake/nl
    Plugin Author Chouby

    (@chouby)

    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 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

    (@dereckson)

    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

    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 https://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 https://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, https://wp-cli.org/commands/post/ allows to create a new post and https://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.