| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentCommunity\Framework\Support; |
| 4 |
|
| 5 |
class Util |
| 6 |
{ |
| 7 |
/** |
| 8 |
* Returns a comma-separated string or array of functions that |
| 9 |
* have been called to get to the current point in code. |
| 10 |
* |
| 11 |
* @param string $ignoreClass |
| 12 |
* @param integer $skipFrames |
| 13 |
* @param boolean $pretty |
| 14 |
* @return string|array |
| 15 |
* @see https://developer.wordpress.org/reference/functions/wp_debug_backtrace_summary/ |
| 16 |
*/ |
| 17 |
public static function debugBacktraceSummary( |
| 18 |
$ignoreClass = null, |
| 19 |
$skipFrames = 0, |
| 20 |
$pretty = true |
| 21 |
) { |
| 22 |
return wp_debug_backtrace_summary( |
| 23 |
$ignoreClass, $skipFrames, $pretty |
| 24 |
); |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* @param string|array $value |
| 29 |
* @return mixed |
| 30 |
* @see https://developer.wordpress.org/reference/functions/wp_slash |
| 31 |
*/ |
| 32 |
public static function addslashes($value) |
| 33 |
{ |
| 34 |
return wp_slash($value); |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* Convert an absolute file path to URL. |
| 39 |
* |
| 40 |
* @param string $filePath |
| 41 |
* @return string |
| 42 |
*/ |
| 43 |
public static function pathToUrl($filePath = '') |
| 44 |
{ |
| 45 |
if (!file_exists($filePath)) { |
| 46 |
throw new \RuntimeException("File does not exist: {$filePath}"); |
| 47 |
} |
| 48 |
|
| 49 |
$url = str_replace( |
| 50 |
wp_normalize_path(untrailingslashit(ABSPATH)), |
| 51 |
site_url(), |
| 52 |
wp_normalize_path($filePath) |
| 53 |
); |
| 54 |
|
| 55 |
return esc_url_raw($url); |
| 56 |
} |
| 57 |
} |
| 58 |
|