/
shared-functions.php
executable file
·58 lines (35 loc) · 1.11 KB
/
shared-functions.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/*
* Needs to be at the same level with config.php,
* because of the use of __FILE__
*/
// first, let's get the debug functions
include_once 'debug-functions.php';
function get_smt2wp_base_path(){
return dirname(__FILE__);
}
function get_smt2wp_base_path_slash(){
return smt2wp_forwardslashit( get_smt2wp_base_path() );
}
function get_smt2wp_cache_path(){
return get_wp_base_dir() . '/wp-content/smt2wp-cache/' ; // needs slash "/" at the end
}
function get_smt2wp_path_relative_to_wp(){
return '/wp-content/plugins/' . basename( get_smt2wp_base_path() );
}
function get_wp_base_dir(){
return smt2wp_substract_strings( get_smt2wp_base_path_slash(), get_smt2wp_path_relative_to_wp() );
}
// helpers:
function smt2wp_sanitize_dir_path( $path ){
return str_replace('//', '/', $path);
}
function smt2wp_forwardslashit( $path ){
return str_replace( '\\', '/', $path );
}
function get_smt2wp_server_root(){
return smt2wp_forwardslashit( $_SERVER['DOCUMENT_ROOT'] );
}
function smt2wp_substract_strings( $big_string, $small_string ){
return str_ireplace( $small_string, '', $big_string );
}