PHP 클래스 Option_Command, wp-cli

## EXAMPLES # Get site URL. $ wp option get siteurl http://example.com # Add option. $ wp option add my_option foobar Success: Added 'my_option' option. # Update option. $ wp option update my_option '{"foo": "bar"}' --format=json Success: Updated 'my_option' option. # Delete option. $ wp option delete my_option Success: Deleted 'my_option' option.
상속: extends WP_CLI_Command
파일 보기 프로젝트 열기: wp-cli/wp-cli

공개 메소드들

메소드 설명
add ( $args, $assoc_args ) Add a new option value.
delete ( $args ) Delete an option.
get ( $args, $assoc_args ) Get the value for an option.
list_ ( $args, $assoc_args ) List options and their values.
update ( $args, $assoc_args ) Update an option value.

비공개 메소드들

메소드 설명
esc_like ( $old )

메소드 상세

add() 공개 메소드

Errors if the option already exists. ## OPTIONS : The name of the option to add. [] : The value of the option to add. If ommited, the value is read from STDIN. [--format=] : The serialization format for the value. --- default: plaintext options: - plaintext - json --- [--autoload=] : Should this option be automatically loaded. --- options: - 'yes' - 'no' --- ## EXAMPLES # Create an option by reading a JSON file. $ wp option add my_option --format=json < config.json Success: Added 'my_option' option.
public add ( $args, $assoc_args )

delete() 공개 메소드

## OPTIONS : Key for the option. ## EXAMPLES # Delete an option. $ wp option delete my_option Success: Deleted 'my_option' option.
public delete ( $args )

get() 공개 메소드

## OPTIONS : Key for the option. [--format=] : Get value in a particular format. --- default: var_export options: - var_export - json - yaml --- ## EXAMPLES # Get option. $ wp option get home http://example.com # Get option in JSON format. $ wp option get active_plugins --format=json {"0":"dynamically-dynamic-sidebar\/dynamically-dynamic-sidebar.php","1":"monster-widget\/monster-widget.php","2":"show-current-template\/show-current-template.php","3":"theme-check\/theme-check.php","5":"wordpress-importer\/wordpress-importer.php"}
public get ( $args, $assoc_args )

list_() 공개 메소드

## OPTIONS [--search=] : Use wildcards ( * and ? ) to match option name. [--exclude=] : Pattern to exclude. Use wildcards ( * and ? ) to match option name. [--autoload=] : Match only autoload options when value is on, and only not-autoload option when off. [--transients] : List only transients. Use --no-transients to ignore all transients. [--field=] : Prints the value of a single field. [--fields=] : Limit the output to specific object fields. [--format=] : The serialization format for the value. total_bytes displays the total size of matching options in bytes. --- default: table options: - table - json - csv - count - yaml - total_bytes --- ## AVAILABLE FIELDS This field will be displayed by default for each matching option: * option_name * option_value These fields are optionally available: * autoload * size_bytes ## EXAMPLES # Get the total size of all autoload options. $ wp option list --autoload=on --format=total_bytes 33198 # Find biggest transients. $ wp option list --search="*_transient_*" --fields=option_name,size_bytes | sort -n -k 2 | tail option_name size_bytes _site_transient_timeout_theme_roots 10 _site_transient_theme_roots 76 _site_transient_update_themes 181 _site_transient_update_core 808 _site_transient_update_plugins 6645 # List all options begining with "i2f_". $ wp option list --search="i2f_*" +-------------+--------------+ | option_name | option_value | +-------------+--------------+ | i2f_version | 0.1.0 | +-------------+--------------+ # Delete all options begining with "theme_mods_". $ wp option list --search="theme_mods_*" --field=option_name | xargs -I % wp option delete % Success: Deleted 'theme_mods_twentysixteen' option. Success: Deleted 'theme_mods_twentyfifteen' option. Success: Deleted 'theme_mods_twentyfourteen' option.
public list_ ( $args, $assoc_args )

update() 공개 메소드

## OPTIONS : The name of the option to update. [] : The new value. If ommited, the value is read from STDIN. [--autoload=] : Requires WP 4.2. Should this option be automatically loaded. --- options: - 'yes' - 'no' --- [--format=] : The serialization format for the value. --- default: plaintext options: - plaintext - json --- ## EXAMPLES # Update an option by reading from a file. $ wp option update my_option < value.txt Success: Updated 'my_option' option. # Update one option on multiple sites using xargs. $ wp site list --field=url | xargs -n1 -I } sh -c 'wp --url=} option update my_option my_value' Success: Updated 'my_option' option. Success: Updated 'my_option' option.
public update ( $args, $assoc_args )