null ) ); $existing_stylesheets = array_keys( $existing_themes ); if ( ! in_array( $name, $existing_stylesheets, true ) ) { $inexact_match = $this->find_inexact_match( $name, $existing_themes ); if ( false !== $inexact_match ) { $this->msg .= sprintf( " Did you mean '%s'?", $inexact_match ); } return false; } $theme = $existing_themes[ $name ]; return $theme; } /** * Find and return the key in $existing_themes that matches $name with * a case insensitive string comparison. * * @param string $name Name of theme received by command. * @param array $existing_themes Key/value pair of existing themes, key is * a case sensitive name. * @return string|boolean Case sensitive name if match found, otherwise false. */ private function find_inexact_match( $name, $existing_themes ) { $target = strtolower( $name ); $themes = array_map( 'strtolower', array_keys( $existing_themes ) ); if ( in_array( $target, $themes, true ) ) { return $target; } $suggestion = Utils\get_suggestion( $target, $themes ); if ( '' !== $suggestion ) { return $suggestion; } return false; } }