-function wp_salt($scheme = 'auth') {
- global $wp_default_secret_key;
- $secret_key = '';
- if ( defined('SECRET_KEY') && ('' != SECRET_KEY) && ( $wp_default_secret_key != SECRET_KEY) )
- $secret_key = SECRET_KEY;
-
- if ( 'auth' == $scheme ) {
- if ( defined('AUTH_KEY') && ('' != AUTH_KEY) && ( $wp_default_secret_key != AUTH_KEY) )
- $secret_key = AUTH_KEY;
-
- if ( defined('AUTH_SALT') && ('' != AUTH_SALT) && ( $wp_default_secret_key != AUTH_SALT) ) {
- $salt = AUTH_SALT;
- } elseif ( defined('SECRET_SALT') && ('' != SECRET_SALT) && ( $wp_default_secret_key != SECRET_SALT) ) {
- $salt = SECRET_SALT;
- } else {
- $salt = get_site_option('auth_salt');
- if ( empty($salt) ) {
- $salt = wp_generate_password( 64, true, true );
- update_site_option('auth_salt', $salt);
- }
- }
- } elseif ( 'secure_auth' == $scheme ) {
- if ( defined('SECURE_AUTH_KEY') && ('' != SECURE_AUTH_KEY) && ( $wp_default_secret_key != SECURE_AUTH_KEY) )
- $secret_key = SECURE_AUTH_KEY;
-
- if ( defined('SECURE_AUTH_SALT') && ('' != SECURE_AUTH_SALT) && ( $wp_default_secret_key != SECURE_AUTH_SALT) ) {
- $salt = SECURE_AUTH_SALT;
- } else {
- $salt = get_site_option('secure_auth_salt');
- if ( empty($salt) ) {
- $salt = wp_generate_password( 64, true, true );
- update_site_option('secure_auth_salt', $salt);
+function wp_salt( $scheme = 'auth' ) {
+ static $cached_salts = array();
+ if ( isset( $cached_salts[ $scheme ] ) )
+ return apply_filters( 'salt', $cached_salts[ $scheme ], $scheme );
+
+ static $duplicated_keys;
+ if ( null === $duplicated_keys ) {
+ $duplicated_keys = array( 'put your unique phrase here' => true );
+ foreach ( array( 'AUTH', 'SECURE_AUTH', 'LOGGED_IN', 'NONCE', 'SECRET' ) as $first ) {
+ foreach ( array( 'KEY', 'SALT' ) as $second ) {
+ if ( ! defined( "{$first}_{$second}" ) )
+ continue;
+ $value = constant( "{$first}_{$second}" );
+ $duplicated_keys[ $value ] = isset( $duplicated_keys[ $value ] );