src/Config_Command.php
public function delete( $args, $assoc_args ) {
		$path = $this->get_config_path();

		list( $name ) = $args;
		$type         = Utils\get_flag_value( $assoc_args, 'type' );

		try {
			$config_transformer = new WPConfigTransformer( $path );

			switch ( $type ) {
				case 'all':
					$has_constant = $config_transformer->exists( 'constant', $name );
					$has_variable = $config_transformer->exists( 'variable', $name );
					if ( $has_constant && $has_variable ) {
						WP_CLI::error( "Found both a constant and a variable '{$name}' in the 'wp-config.php' file. Use --type=<type> to disambiguate." );
					}
					if ( ! $has_constant && ! $has_variable ) {
						WP_CLI::error( "The constant or variable '{$name}' is not defined in the 'wp-config.php' file." );
					} else {
						$type = $has_constant ? 'constant' : 'variable';
					}
					break;
				case 'constant':
				case 'variable':
					if ( ! $config_transformer->exists( $type, $name ) ) {
						WP_CLI::error( "The {$type} '{$name}' is not defined in the 'wp-config.php' file." );
					}
			}

			$config_transformer->remove( $type, $name );

		} catch ( Exception $exception ) {
			WP_CLI::error( "Could not process the 'wp-config.php' transformation.\nReason: {$exception->getMessage()}" );
		}

		WP_CLI::success( "Deleted the {$type} '{$name}' from the 'wp-config.php' file." );
	}
public function delete( $args, $assoc_args ) {
		$path = $this->get_config_path();

		list( $name ) = $args;
		$type         = Utils\get_flag_value( $assoc_args, 'type' );

		try {
			$config_transformer = new WPConfigTransformer( $path );

			switch ( $type ) {
				case 'all':
					$has_constant = $config_transformer->exists( 'constant', $name );
					$has_variable = $config_transformer->exists( 'variable', $name );
					if ( $has_constant && $has_variable ) {
						WP_CLI::error( "Found both a constant and a variable '{$name}' in the 'wp-config.php' file. Use --type=<type> to disambiguate." );
					}
					if ( ! $has_constant && ! $has_variable ) {
						WP_CLI::error( "The constant or variable '{$name}' is not defined in the 'wp-config.php' file." );
					} else {
						$type = $has_constant ? 'constant' : 'variable';
					}
					break;
				case 'constant':
				case 'variable':
					if ( ! $config_transformer->exists( $type, $name ) ) {
						WP_CLI::error( "The {$type} '{$name}' is not defined in the 'wp-config.php' file." );
					}
			}

			$config_transformer->remove( $type, $name );

		} catch ( Exception $exception ) {
			WP_CLI::error( "Could not process the 'wp-config.php' transformation.\nReason: {$exception->getMessage()}" );
		}

		WP_CLI::success( "Deleted the {$type} '{$name}' from the 'wp-config.php' file." );
	}
public function delete ( $ args , $ assoc_args ) { $ path = $ this -> get_config_path ( ) ; list ( $ name ) = $ args ; $ type = Utils \ get_flag_value ( $ assoc_args , 'type' ) ; try { $ config_transformer = new WPConfigTransformer ( $ path ) ; switch ( $ type ) { case 'all' : $ has_constant = $ config_transformer -> exists ( 'constant' , $ name ) ; $ has_variable = $ config_transformer -> exists ( 'variable' , $ name ) ; if ( $ has_constant && $ has_variable ) { WP_CLI :: error ( "Found both a constant and a variable '{$name}' in the 'wp-config.php' file. Use --type=<type> to disambiguate." ) ; } if ( ! $ has_constant && ! $ has_variable ) { WP_CLI :: error ( "The constant or variable '{$name}' is not defined in the 'wp-config.php' file." ) ; } else { $ type = $ has_constant ? 'constant' : 'variable' ; } break ; case 'constant' : case 'variable' : if ( ! $ config_transformer -> exists ( $ type , $ name ) ) { WP_CLI :: error ( "The {$type} '{$name}' is not defined in the 'wp-config.php' file." ) ; } } $ config_transformer -> remove ( $ type , $ name ) ; } catch ( Exception $ exception ) { WP_CLI :: error ( "Could not process the 'wp-config.php' transformation.\nReason: {$exception->getMessage()}" ) ; } WP_CLI :: success ( "Deleted the {$type} '{$name}' from the 'wp-config.php' file." ) ; }
Deletes a specific constant or variable from the wp-config.php file.

## OPTIONS

<name>
: Name of the wp-config.php constant or variable.

[--type=<type>]
: Type of the config value to delete. Defaults to 'all'.
---
default: all
options:
- constant
- variable
- all
---

## EXAMPLES

# Delete the COOKIE_DOMAIN constant from the wp-config.php file.
$ wp config delete COOKIE_DOMAIN

@when before_wp_load
Deletes a specific constant or variable from the wp - config . php file .