wp_is_stream

The timeline below displays how wordpress function wp_is_stream has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Tests if a given path is a stream URL
 *
 * @since 3.5.0
 *
 * @param string $path The resource path or URL.
 * @return bool True if the path is a stream URL.
 */
function wp_is_stream($path)
{
    $scheme_separator = strpos($path, '://');
    if (false === $scheme_separator) {
        // $path isn't a stream.
        return false;
    }
    $stream = substr($path, 0, $scheme_separator);
    return in_array($stream, stream_get_wrappers(), true);
}

WordPress Version: 5.4

/**
 * Test if a given path is a stream URL
 *
 * @since 3.5.0
 *
 * @param string $path The resource path or URL.
 * @return bool True if the path is a stream URL.
 */
function wp_is_stream($path)
{
    $scheme_separator = strpos($path, '://');
    if (false === $scheme_separator) {
        // $path isn't a stream.
        return false;
    }
    $stream = substr($path, 0, $scheme_separator);
    return in_array($stream, stream_get_wrappers(), true);
}

WordPress Version: 5.1

/**
 * Test if a given path is a stream URL
 *
 * @since 3.5.0
 *
 * @param string $path The resource path or URL.
 * @return bool True if the path is a stream URL.
 */
function wp_is_stream($path)
{
    $scheme_separator = strpos($path, '://');
    if (false === $scheme_separator) {
        // $path isn't a stream
        return false;
    }
    $stream = substr($path, 0, $scheme_separator);
    return in_array($stream, stream_get_wrappers(), true);
}

WordPress Version: 9.8

/**
 * Test if a given path is a stream URL
 *
 * @since 3.5.0
 *
 * @param string $path The resource path or URL.
 * @return bool True if the path is a stream URL.
 */
function wp_is_stream($path)
{
    if (false === strpos($path, '://')) {
        // $path isn't a stream
        return false;
    }
    $wrappers = stream_get_wrappers();
    $wrappers = array_map('preg_quote', $wrappers);
    $wrappers_re = '(' . join('|', $wrappers) . ')';
    return preg_match("!^{$wrappers_re}://!", $path) === 1;
}

WordPress Version: 9.3

/**
 * Test if a given path is a stream URL
 *
 * @since 3.5.0
 *
 * @param string $path The resource path or URL.
 * @return bool True if the path is a stream URL.
 */
function wp_is_stream($path)
{
    $wrappers = stream_get_wrappers();
    $wrappers_re = '(' . join('|', $wrappers) . ')';
    return preg_match("!^{$wrappers_re}://!", $path) === 1;
}

WordPress Version: .20

/**
 * Test if a given path is a stream URL
 *
 * @since 3.5.0
 *
 * @param string $path The resource path or URL.
 * @return bool True if the path is a stream URL.
 */
function wp_is_stream($path)
{
    if (false === strpos($path, '://')) {
        // $path isn't a stream
        return false;
    }
    $wrappers = stream_get_wrappers();
    $wrappers = array_map('preg_quote', $wrappers);
    $wrappers_re = '(' . join('|', $wrappers) . ')';
    return preg_match("!^{$wrappers_re}://!", $path) === 1;
}

WordPress Version: 9.2

/**
 * Test if a given path is a stream URL
 *
 * @since 3.5.0
 *
 * @param string $path The resource path or URL.
 * @return bool True if the path is a stream URL.
 */
function wp_is_stream($path)
{
    $wrappers = stream_get_wrappers();
    $wrappers_re = '(' . join('|', $wrappers) . ')';
    return preg_match("!^{$wrappers_re}://!", $path) === 1;
}

WordPress Version: .10

/**
 * Test if a given path is a stream URL
 *
 * @since 3.5.0
 *
 * @param string $path The resource path or URL.
 * @return bool True if the path is a stream URL.
 */
function wp_is_stream($path)
{
    if (false === strpos($path, '://')) {
        // $path isn't a stream
        return false;
    }
    $wrappers = stream_get_wrappers();
    $wrappers = array_map('preg_quote', $wrappers);
    $wrappers_re = '(' . join('|', $wrappers) . ')';
    return preg_match("!^{$wrappers_re}://!", $path) === 1;
}

WordPress Version: 4.8

/**
 * Test if a given path is a stream URL
 *
 * @since 3.5.0
 *
 * @param string $path The resource path or URL.
 * @return bool True if the path is a stream URL.
 */
function wp_is_stream($path)
{
    $wrappers = stream_get_wrappers();
    $wrappers_re = '(' . join('|', $wrappers) . ')';
    return preg_match("!^{$wrappers_re}://!", $path) === 1;
}

WordPress Version: 4.0

/**
 * Test if a given path is a stream URL
 *
 * @param string $path The resource path or URL.
 * @return bool True if the path is a stream URL.
 */
function wp_is_stream($path)
{
    $wrappers = stream_get_wrappers();
    $wrappers_re = '(' . join('|', $wrappers) . ')';
    return preg_match("!^{$wrappers_re}://!", $path) === 1;
}

WordPress Version: 3.7

/**
 * Test if a given path is a stream URL
 *
 * @param string $path The resource path or URL
 * @return bool True if the path is a stream URL
 */
function wp_is_stream($path)
{
    $wrappers = stream_get_wrappers();
    $wrappers_re = '(' . join('|', $wrappers) . ')';
    return preg_match("!^{$wrappers_re}://!", $path) === 1;
}