path_join

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

WordPress Version: 6.1

/**
 * Joins two filesystem paths together.
 *
 * For example, 'give me $path relative to $base'. If the $path is absolute,
 * then it the full path is returned.
 *
 * @since 2.5.0
 *
 * @param string $base Base path.
 * @param string $path Path relative to $base.
 * @return string The path with the base or absolute path.
 */
function path_join($base, $path)
{
    if (path_is_absolute($path)) {
        return $path;
    }
    return rtrim($base, '/') . '/' . $path;
}

WordPress Version: 4.0

/**
 * Join two filesystem paths together.
 *
 * For example, 'give me $path relative to $base'. If the $path is absolute,
 * then it the full path is returned.
 *
 * @since 2.5.0
 *
 * @param string $base Base path.
 * @param string $path Path relative to $base.
 * @return string The path with the base or absolute path.
 */
function path_join($base, $path)
{
    if (path_is_absolute($path)) {
        return $path;
    }
    return rtrim($base, '/') . '/' . ltrim($path, '/');
}

WordPress Version: 3.7

/**
 * Join two filesystem paths together (e.g. 'give me $path relative to $base').
 *
 * If the $path is absolute, then it the full path is returned.
 *
 * @since 2.5.0
 *
 * @param string $base
 * @param string $path
 * @return string The path with the base or absolute path.
 */
function path_join($base, $path)
{
    if (path_is_absolute($path)) {
        return $path;
    }
    return rtrim($base, '/') . '/' . ltrim($path, '/');
}