wp config
Создает и считывает файл wp-config.php.
| Список команд | Описание |
|---|---|
| wp config create | Создает файл wp-config.php. |
| wp config edit | Запускает системный редактор для редактирования wp-config.php. |
| wp config path | Возвращает путь к файлу wp-config.php. |
| wp config list | Список переменных, констант и подключений файлов из wp-config.php. |
| wp config get | Возвращает значение определенной константы или переменной, определенной в wp-config.php. |
| wp config set | Задает значение указанной константы или переменной в wp-config.php. |
| wp config delete | Удаляет определенную константу или переменную из wp-config.php. |
| wp config has | Проверяет, существует ли определенная константа или переменная в wp-config.php. |
| wp config shuffle-salts | Обновляет соли, определенные в wp-config.php. |
Исходный код команд
wp config create
Создает файл wp-config.php.
Creates a new wp-config.php with database constants, and verifies that the database constants are correct.
Использование
wp config create --dbname={dbname} --dbuser={dbuser} [--dbpass={dbpass}] [--dbhost={dbhost}]
[--dbprefix={dbprefix}] [--dbcharset={dbcharset}] [--dbcollate={dbcollate}] [--locale={locale}]
[--extra-php] [--skip-salts] [--skip-check] [--force]
Можно указать Глобальные параметры и следующие:
--dbname={dbname}- Set the database name.
--dbuser={dbuser}- Set the database user.
[--dbpass={dbpass}]- Set the database user password.
[--dbhost={dbhost}]- Set the database host.
По умолчанию: localhost [--dbprefix={dbprefix}]- Set the database table prefix.
По умолчанию: wp_ [--dbcharset={dbcharset}]- Set the database charset.
По умолчанию: utf8 [--dbcollate={dbcollate}]- Set the database collation.
default: [--locale={locale}]- Set the WPLANG constant. Defaults to $wp_local_package variable.
[--extra-php]- If set, the command copies additional PHP code into wp-config.php from STDIN.
[--skip-salts]- If set, keys and salts won't be generated, but should instead be passed via
--extra-php. [--skip-check]- If set, the database connection is not checked.
[--force]- Overwrites existing files, if present.
Примеры
# Standard wp-config.php file $ wp config create --dbname=testing --dbuser=wp --dbpass=securepswd --locale=ro_RO Success: Generated 'wp-config.php' file.
# Enable WP_DEBUG and WP_DEBUG_LOG $ wp config create --dbname=testing --dbuser=wp --dbpass=securepswd --extra-php <<PHP define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); PHP Success: Generated 'wp-config.php' file.
# Avoid disclosing password to bash history by reading from password.txt # Using --prompt=dbpass will prompt for the 'dbpass' argument $ wp config create --dbname=testing --dbuser=wp --prompt=dbpass < password.txt Success: Generated 'wp-config.php' file.
wp config edit
Запускает системный редактор для редактирования wp-config.php.
Использование
wp config edit
Примеры
# Launch system editor to edit wp-config.php file $ wp config edit
# Edit wp-config.php file in a specific editor $ EDITOR=vim wp config edit
wp config path
Возвращает путь к файлу wp-config.php.
Использование
wp config path
Примеры
# Get wp-config.php file path $ wp config path /home/person/htdocs/project/wp-config.php
wp config list
Список переменных, констант и подключений файлов из wp-config.php.
Использование
wp config list [{filter}...] [--fields={fields}] [--format={format}] [--strict]
Можно указать Глобальные параметры и следующие:
[{filter}...]- Name or partial name to filter the list by.
[--fields={fields}]- Limit the output to specific fields. Defaults to all fields.
[--format={format}]- Render output in a particular format.
По умолчанию: table
Может быть:
- table
- csv
- json
- yaml [--strict]- Enforce strict matching when a filter is provided.
Примеры
# List constants and variables defined in wp-config.php file. $ wp config list +------------------+------------------------------------------------------------------+----------+ | key | value | type | +------------------+------------------------------------------------------------------+----------+ | table_prefix | wp_ | variable | | DB_NAME | wp_cli_test | constant | | DB_USER | root | constant | | DB_PASSWORD | root | constant | | AUTH_KEY | r6+@shP1yO&$)1gdu.hl[/j;7Zrvmt~o;#WxSsa0mlQOi24j2cR,7i+QM/#7S:o^ | constant | | SECURE_AUTH_KEY | iO-z!_m--YH$Tx2tf/&V,YW*13Z_HiRLqi)d?$o-tMdY+82pK$`T.NYW~iTLW;xp | constant | +------------------+------------------------------------------------------------------+----------+
# List only database user and password from wp-config.php file. $ wp config list DB_USER DB_PASSWORD --strict +------------------+-------+----------+ | key | value | type | +------------------+-------+----------+ | DB_USER | root | constant | | DB_PASSWORD | root | constant | +------------------+-------+----------+
# List all salts from wp-config.php file.
$ wp config list _SALT
+------------------+------------------------------------------------------------------+----------+
| key | value | type |
+------------------+------------------------------------------------------------------+----------+
| AUTH_SALT | n:]Xditk+_7>Qi=>BmtZHiH-6/Ecrvl(V5ceeGP:{>?;BT^=[B3-0>,~F5z$(+Q$ | constant |
| SECURE_AUTH_SALT | ?Z/p|XhDw3w}?c.z%|+BAr|(Iv*H%%U+Du&kKR y?cJOYyRVRBeB[2zF-`(>+LCC | constant |
| LOGGED_IN_SALT | +$@(1{b~Z~s}Cs>8Y]6[m6~TnoCDpE>O%e75u}&6kUH!>q:7uM4lxbB6[1pa_X,q | constant |
| NONCE_SALT | _x+F li|QL?0OSQns1_JZ{|Ix3Jleox-71km/gifnyz8kmo=w-;@AE8W,(fP<N}2 | constant |
+------------------+------------------------------------------------------------------+----------+
wp config get
Возвращает значение определенной константы или переменной, определенной в wp-config.php.
Использование
wp config get {name} [--type={type}]
Можно указать Глобальные параметры и следующие:
{name}- Name of the wp-config.php constant or variable.
[--type={type}]- Type of config value to retrieve. Defaults to 'all'.
По умолчанию: all
Может быть:
- constant
- variable
- all
Примеры
# Get the table_prefix as defined in wp-config.php file. $ wp config get table_prefix wp_
wp config set
Задает значение указанной константы или переменной в wp-config.php.
Использование
wp config set {name} {value} [--add] [--raw] [--anchor={anchor}] [--placement={placement}]
[--separator={separator}] [--type={type}]
Можно указать Глобальные параметры и следующие:
{name}- Name of the wp-config.php constant or variable.
{value}- Value to set the wp-config.php constant or variable to.
[--add]- Add the value if it doesn't exist yet. This is the default behavior, override with --no-add.
[--raw]- Place the value into the wp-config.php file as is, instead of as a quoted string.
[--anchor={anchor}]- Anchor string where additions of new values are anchored around. Defaults to "/* That's all, stop editing!".
[--placement={placement}]- Where to place the new values in relation to the anchor string.
По умолчанию: 'before'
Может быть:
- before
- after [--separator={separator}]- Separator string to put between an added value and its anchor string. The following escape sequences will be recognized and properly interpreted: '\n' => newline, '\r' => carriage return, '\t' => tab. Defaults to a single EOL ("\n" on *nix and "\r\n" on Windows).
[--type={type}]- Type of the config value to set. Defaults to 'all'.
По умолчанию: all
Может быть:
- constant
- variable
- all
Примеры
# Set the WP_DEBUG constant to true. $ wp config set WP_DEBUG true --raw
wp config delete
Удаляет определенную константу или переменную из wp-config.php.
Использование
wp config delete {name} [--type={type}]
Можно указать Глобальные параметры и следующие:
{name}- Name of the wp-config.php constant or variable.
[--type={type}]- Type of the config value to delete. Defaults to 'all'.
По умолчанию: all
Может быть:
- constant
- variable
- all
Примеры
# Delete the COOKIE_DOMAIN constant from the wp-config.php file. $ wp config delete COOKIE_DOMAIN
wp config has
Проверяет, существует ли определенная константа или переменная в wp-config.php.
Использование
wp config has {name} [--type={type}]
Можно указать Глобальные параметры и следующие:
{name}- Name of the wp-config.php constant or variable.
[--type={type}]- Type of the config value to set. Defaults to 'all'.
По умолчанию: all
Может быть:
- constant
- variable
- all
Примеры
# Check whether the DB_PASSWORD constant exists in the wp-config.php file. $ wp config has DB_PASSWORD
wp config shuffle-salts
Обновляет соли, определенные в wp-config.php.
Использование
wp config shuffle-salts
Можно указать Глобальные параметры и следующие:
Примеры
# Get new salts for your wp-config.php file $ wp config shuffle-salts Success: Shuffled the salt keys.