Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ labels:
color: c2e0c6
- name: command:config
color: c5def5
- name: command:config-edit
color: c5def5
- name: command:config-delete
color: c5def5
- name: command:config-create
color: c5def5
- name: command:config-get
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,24 @@ wp config



### wp config edit

Launches system editor to edit the wp-config.php file.

~~~
wp config edit
~~~

**EXAMPLES**

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

Deletes a specific constant or variable from the wp-config.php file.
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"bundled": true,
"commands": [
"config",
"config edit",
"config delete",
"config create",
"config get",
Expand Down
22 changes: 22 additions & 0 deletions src/Config_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,28 @@ public function create( $_, $assoc_args ) {
}
}

/**
* Launches system editor to edit the wp-config.php file.
*
* ## EXAMPLES
*
* # 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
*/
public function edit() {
$config_path = $this->get_config_path();
$contents = file_get_contents( $config_path );
$r = Utils\launch_editor_for_input( $contents, 'wp-config.php', 'php' );
if ( $r === false ) {
WP_CLI::warning( 'No changes made to wp-config.php.', 'Aborted' );
} else {
file_put_contents( $path, $r );
}
}

/**
* Gets the path to wp-config.php file.
*
Expand Down