Contract::ENVIRONMENT_LABEL_MAX_LENGTH ) { $value = rtrim( substr( $value, 0, Contract::ENVIRONMENT_LABEL_MAX_LENGTH ), '-' ); } return $value; } /** * Default label for a site, guessed from its URL host: "staging" when the host carries a * non-production hint, else "production". The installer is shown the value and can change it. * * @param string|null $url Site URL. * @return string */ public static function derive_from_url( $url ) { $host = wp_parse_url( (string) $url, PHP_URL_HOST ); if ( ! is_string( $host ) || '' === $host ) { return 'production'; } $host = strtolower( $host ); foreach ( self::NON_PRODUCTION_HINTS as $hint ) { if ( false !== strpos( $host, $hint ) ) { return 'staging'; } } return 'production'; } }