su_join_paths

The shortcodes-ultimate su join paths function.

Published Date - February 15, 2021

Description

Helper function to join multiple path pieces into one.

su_join_paths();

Usage

The following example is for adding a hook callback.

if ( !function_exists( 'su_join_paths' ) ) {
    require_once ABSPATH . PLUGINDIR . 'shortcodes-ultimateshortcodes-ultimate/includes/functions-helpers.php';
}



// NOTICE! Understand what this does before running.
$result = su_join_paths();
            

Defined

The function is defined in the following location(s).

shortcodes-ultimate/includes/functions-helpers.php

function su_join_paths() {

	$is_absolute = func_get_arg( 0 ) !== ltrim( func_get_arg( 0 ), '\\/' );

	$pieces = array_map(
		function( $piece ) {
			return trim( $piece, '\\/' );
		},
		func_get_args()
	);

	$path = implode( DIRECTORY_SEPARATOR, $pieces );

	if ( $is_absolute ) {
		$path = DIRECTORY_SEPARATOR . $path;
	}

	return $path;

}