PHP Class WP_CLI\CommandWithTranslation

Inheritance: extends WP_CLI_Command
Show file Open project: wp-cli/wp-cli

Protected Properties

Property Type Description
$obj_fields
$obj_type

Public Methods

Method Description
activate ( $args, $assoc_args ) Activate a given language.
install ( $args, $assoc_args ) Install a given language.
list_ ( $args, $assoc_args ) List all available languages.
uninstall ( $args, $assoc_args ) Uninstall a given language.
update ( $args, $assoc_args ) Update installed languages.

Protected Methods

Method Description
get_all_languages ( ) : array Return a list of all languages
get_formatter ( array &$assoc_args ) : Formatter Get Formatter object based on supplied parameters.
get_installed_languages ( ) : array Return a list of installed languages.
sort_translations_callback ( $a, $b ) Callback to sort array by a 'language' key.

Private Methods

Method Description
download_language_pack ( string $download ) : string | WP_Error Download a language pack.
get_translation_updates ( ) : array Get all updates available for all translations
wp_clean_update_cache ( ) Replicates wp_clean_update_cache() for use in WP 4.0

Method Details

activate() public method

: Language code to activate. ## EXAMPLES $ wp core language activate ja Success: Language activated.
public activate ( $args, $assoc_args )

get_all_languages() protected method

Return a list of all languages
protected get_all_languages ( ) : array
return array

get_formatter() protected method

Get Formatter object based on supplied parameters.
protected get_formatter ( array &$assoc_args ) : Formatter
$assoc_args array Parameters passed to command. Determines formatting.
return Formatter

get_installed_languages() protected method

Return a list of installed languages.
protected get_installed_languages ( ) : array
return array

install() public method

Downloads the language pack from WordPress.org. : Language code to install. [--activate] : If set, the language will be activated immediately after install. ## EXAMPLES # Install the Japanese language. $ wp core language install ja Success: Language installed.
public install ( $args, $assoc_args )

list_() public method

[--field=] : Display the value of a single field [--=] : Filter results by key=value pairs. [--fields=] : Limit the output to specific fields. [--format=] : Accepted values: table, csv, json. Default: table ## AVAILABLE FIELDS These fields will be displayed by default for each translation: * language * english_name * native_name * status * update * updated These fields are optionally available: * version * package ## EXAMPLES # List language,english_name,status fields of available languages. $ wp core language list --fields=language,english_name,status +----------------+-------------------------+-------------+ | language | english_name | status | +----------------+-------------------------+-------------+ | ar | Arabic | uninstalled | | ary | Moroccan Arabic | uninstalled | | az | Azerbaijani | uninstalled |
public list_ ( $args, $assoc_args )

sort_translations_callback() protected method

Callback to sort array by a 'language' key.
protected sort_translations_callback ( $a, $b )

uninstall() public method

: Language code to uninstall. ## EXAMPLES $ wp core language uninstall ja Success: Language uninstalled.
public uninstall ( $args, $assoc_args )

update() public method

Updates installed languages for core, plugins and themes. [--dry-run] : Preview which translations would be updated. ## EXAMPLES $ wp core language update Updating 'Japanese' translation for Akismet 3.1.11... Downloading translation from https://downloads.wordpress.org/translation/plugin/akismet/3.1.11/ja.zip... Translation updated successfully. Updating 'Japanese' translation for Twenty Fifteen 1.5... Downloading translation from https://downloads.wordpress.org/translation/theme/twentyfifteen/1.5/ja.zip... Translation updated successfully. Success: Updated 2/2 translations.
public update ( $args, $assoc_args )

Property Details

$obj_fields protected property

protected $obj_fields

$obj_type protected property

protected $obj_type