@@ -46,6 +46,14 @@ wp config
4646 $ wp config get table_prefix
4747 wp_
4848
49+ # Add a new constant to the wp-config.php file.
50+ $ wp config add WP_DEBUG true --raw
51+ Success: Added the constant 'WP_DEBUG' to the 'wp-config.php' file with the raw value 'true'.
52+
53+ # Update or add a constant to the wp-config.php file.
54+ $ wp config update WP_DEBUG false --raw
55+ Success: Updated the constant 'WP_DEBUG' in the 'wp-config.php' file with the raw value 'false'.
56+
4957 # Set the WP_DEBUG constant to true.
5058 $ wp config set WP_DEBUG true --raw
5159 Success: Updated the constant 'WP_DEBUG' in the 'wp-config.php' file with the raw value 'true'.
@@ -73,6 +81,65 @@ wp config
7381
7482
7583
84+ ### wp config add
85+
86+ Adds a new constant or variable to the wp-config.php file.
87+
88+ ~~~
89+ wp config add <name> <value> [--raw] [--anchor=<anchor>] [--placement=<placement>] [--separator=<separator>] [--type=<type>] [--config-file=<path>]
90+ ~~~
91+
92+ ** OPTIONS**
93+
94+ <name>
95+ Name of the wp-config.php constant or variable.
96+
97+ <value>
98+ Value to set the wp-config.php constant or variable to.
99+
100+ [--raw]
101+ Place the value into the wp-config.php file as is, instead of as a quoted string.
102+
103+ [--anchor=<anchor>]
104+ Anchor string where additions of new values are anchored around.
105+ Defaults to "/* That's all, stop editing!".
106+ The special case "EOF" string uses the end of the file as the anchor.
107+
108+ [--placement=<placement>]
109+ Where to place the new values in relation to the anchor string.
110+ ---
111+ default: 'before'
112+ options:
113+ - before
114+ - after
115+ ---
116+
117+ [--separator=<separator>]
118+ Separator string to put between an added value and its anchor string.
119+ The following escape sequences will be recognized and properly interpreted: '\n' => newline, '\r' => carriage return, '\t' => tab.
120+ Defaults to a single EOL ("\n" on *nix and "\r\n" on Windows).
121+
122+ [--type=<type>]
123+ Type of the config value to add. Defaults to 'constant'.
124+ ---
125+ default: constant
126+ options:
127+ - constant
128+ - variable
129+ ---
130+
131+ [--config-file=<path>]
132+ Specify the file path to the config file to be modified. Defaults to the root of the
133+ WordPress installation and the filename "wp-config.php".
134+
135+ ** EXAMPLES**
136+
137+ # Add the WP_DEBUG constant to the wp-config.php file.
138+ $ wp config add WP_DEBUG true --raw
139+ Success: Added the constant 'WP_DEBUG' to the 'wp-config.php' file with the raw value 'true'.
140+
141+
142+
76143### wp config edit
77144
78145Launches system editor to edit the wp-config.php file.
@@ -531,6 +598,68 @@ wp config shuffle-salts [<keys>...] [--force] [--config-file=<path>] [--insecure
531598 $ wp config shuffle-salts WP_CACHE_KEY_SALT --force
532599 Success: Shuffled the salt keys.
533600
601+
602+
603+ ### wp config update
604+
605+ Updates or adds a constant or variable in the wp-config.php file.
606+
607+ ~~~
608+ wp config update <name> <value> [--raw] [--anchor=<anchor>] [--placement=<placement>] [--separator=<separator>] [--type=<type>] [--config-file=<path>]
609+ ~~~
610+
611+ This command will add the constant or variable if it doesn't exist, or update it if it does.
612+
613+ ** OPTIONS**
614+
615+ <name>
616+ Name of the wp-config.php constant or variable.
617+
618+ <value>
619+ Value to set the wp-config.php constant or variable to.
620+
621+ [--raw]
622+ Place the value into the wp-config.php file as is, instead of as a quoted string.
623+
624+ [--anchor=<anchor>]
625+ Anchor string where additions of new values are anchored around.
626+ Defaults to "/* That's all, stop editing!".
627+ The special case "EOF" string uses the end of the file as the anchor.
628+
629+ [--placement=<placement>]
630+ Where to place the new values in relation to the anchor string.
631+ ---
632+ default: 'before'
633+ options:
634+ - before
635+ - after
636+ ---
637+
638+ [--separator=<separator>]
639+ Separator string to put between an added value and its anchor string.
640+ The following escape sequences will be recognized and properly interpreted: '\n' => newline, '\r' => carriage return, '\t' => tab.
641+ Defaults to a single EOL ("\n" on *nix and "\r\n" on Windows).
642+
643+ [--type=<type>]
644+ Type of the config value to update. Defaults to 'all'.
645+ ---
646+ default: all
647+ options:
648+ - constant
649+ - variable
650+ - all
651+ ---
652+
653+ [--config-file=<path>]
654+ Specify the file path to the config file to be modified. Defaults to the root of the
655+ WordPress installation and the filename "wp-config.php".
656+
657+ ** EXAMPLES**
658+
659+ # Update or add the WP_DEBUG constant to the wp-config.php file.
660+ $ wp config update WP_DEBUG true --raw
661+ Success: Updated the constant 'WP_DEBUG' in the 'wp-config.php' file with the raw value 'true'.
662+
534663## Installing
535664
536665This package is included with WP-CLI itself, no additional installation necessary.
0 commit comments