OSDN Git Service

Allows passing existing keys and salts vs generating afresh
authorNikolay Kolev <nikolay@users.noreply.github.com>
Mon, 19 Aug 2013 20:11:16 +0000 (13:11 -0700)
committerNikolay Kolev <nikolay@users.noreply.github.com>
Mon, 19 Aug 2013 20:11:16 +0000 (13:11 -0700)
In a multi-server environment, if you want a consistent configuration without having to patch the automatically generated wp-config.php, there should be a way to pass the common keys and salts.

php/commands/core.php

index 5dc62c9..d26f0e0 100644 (file)
@@ -153,6 +153,9 @@ class Core_Command extends WP_CLI_Command {
         *
         * --extra-php
         * : If set, the command reads additional PHP code from STDIN.
+        * 
+        * --keys-and-salts
+        * : Use existing secrets versus generating afresh as the default behavior.
         *
         * ## EXAMPLES
         *
@@ -196,9 +199,10 @@ class Core_Command extends WP_CLI_Command {
                }
 
                // TODO: adapt more resilient code from wp-admin/setup-config.php
-
-               $assoc_args['keys-and-salts'] = self::_read(
-                       'https://api.wordpress.org/secret-key/1.1/salt/' );
+               if ( ! isset( $assoc_args['keys-and-salts'] ) ) {
+                       $assoc_args['keys-and-salts'] = self::_read(
+                               'https://api.wordpress.org/secret-key/1.1/salt/' );
+               }
 
                $out = Utils\mustache_render( 'wp-config.mustache', $assoc_args );
                file_put_contents( ABSPATH . 'wp-config.php', $out );