-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.php
41 lines (37 loc) · 949 Bytes
/
utils.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace Running_Text\Utility;
/**
* Format backslash to slash
* @param string $text text to be formatted
* @return string formatted text
*/
function format_slash($text)
{
return str_replace("\\", "/", $text);
}
/**
* Get formatted WP absolute path
* @return string WP absolute path (formatted)
*/
function get_absolute_path()
{
return format_slash(rtrim(ABSPATH, "/"));
}
/**
* Get formatted relative directory of feature
* @param string $path path to file or folder
* @return string relative directory of feature (formatted)
*/
function feature_dir($path = "")
{
return str_replace(get_absolute_path(), "", feature_absolute_dir($path));
}
/**
* Get formatted absolute directory of feature
* @param string $path path to file or folder
* @return string absolute directory of feature (formatted)
*/
function feature_absolute_dir($path = "")
{
return format_slash(realpath(dirname(__FILE__) . "/" . $path));
}