class-wpml-file-name-converter.php
812 Bytes
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
42
43
44
45
46
<?php
class WPML_File_Name_Converter {
/**
* @var string
*/
private $home_path;
/**
* @param string $file
*
* @return string
*/
public function transform_realpath_to_reference( $file ) {
$home_path = $this->get_home_path();
return str_replace( $home_path, '', $file );
}
/**
* @param string $file
*
* @return string
*/
public function transform_reference_to_realpath( $file ) {
$home_path = $this->get_home_path();
return trailingslashit( $home_path ) . ltrim( $file, '/\\' );
}
/**
* @return string
*/
private function get_home_path() {
if ( null === $this->home_path ) {
if ( ! function_exists( 'get_home_path' ) ) {
require_once ABSPATH . 'wp-admin/includes/file.php';
}
$this->home_path = get_home_path();
}
return $this->home_path;
}
}