PluginProbe ʕ •ᴥ•ʔ
Kirki – Freeform Page Builder, Website Builder & Customizer / 6.2.0
Kirki – Freeform Page Builder, Website Builder & Customizer v6.2.0
6.2.0 6.1.1 6.1.0 6.0.14 6.0.13 6.0.12 6.0.11 6.0.10 6.0.9 6.0.8 6.0.7 6.0.6 6.0.5 6.0.4 6.0.3 6.0.2 6.0.1 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.19 4.0.20 4.0.21 4.0.22 4.0.23 4.0.24 4.1 4.2.0 5.0.0 5.1.0 5.1.1 5.2.0 5.2.1 5.2.2 5.2.3 6.0.0 trunk 3.0.40 3.0.41 3.0.42 3.0.43 3.0.44 3.0.45 3.1.0 3.1.1 3.1.2
kirki / libraries / framework / Filesystem / Path.php
kirki / libraries / framework / Filesystem Last commit date
File.php 1 month ago FileSystemServiceProvider.php 1 month ago Fileable.php 1 month ago Filesystem.php 1 month ago MimeTypes.php 5 days ago Path.php 1 month ago UploadedFile.php 1 month ago
Path.php
71 lines
1 <?php
2
3 /**
4 * Static utilities for joining path segments and normalizing filesystem paths.
5 * Handles trailing slashes, parent directory traversal, and cross-platform separators.
6 * Used by Application and generators for consistent path construction.
7 *
8 * @package Framework
9 * @subpackage Filesystem
10 * @since 1.0.0
11 */
12 namespace Kirki\Framework\Filesystem;
13
14 \defined('ABSPATH') || exit;
15 class Path
16 {
17 /**
18 * Join path segments onto a base path.
19 *
20 * @param mixed $base The base.
21 * @param mixed $paths The paths.
22 *
23 * @return string
24 *
25 * @since 1.0.0
26 */
27 public static function join($base, ...$paths)
28 {
29 foreach ($paths as $index => $path) {
30 if (empty($path) && $path !== '0') {
31 unset($paths[$index]);
32 } else {
33 $paths[$index] = \DIRECTORY_SEPARATOR . \ltrim($path, \DIRECTORY_SEPARATOR);
34 }
35 }
36 return $base . \implode('', $paths);
37 }
38 /**
39 * Normalize a filesystem path without requiring it to exist.
40 *
41 * @param mixed $path The path.
42 *
43 * @return string
44 *
45 * @since 1.0.0
46 */
47 public static function normalize($path)
48 {
49 $path = \str_replace('\\', '/', $path);
50 $is_absolute = $path !== '' && $path[0] === '/';
51 $parts = [];
52 foreach (\explode('/', $path) as $part) {
53 if ($part === '' || $part === '.') {
54 continue;
55 }
56 if ($part === '..') {
57 if (!empty($parts)) {
58 \array_pop($parts);
59 }
60 continue;
61 }
62 $parts[] = $part;
63 }
64 $normalized = \implode('/', $parts);
65 if ($is_absolute) {
66 return '/' . $normalized;
67 }
68 return $normalized;
69 }
70 }
71