-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompat.php
92 lines (81 loc) · 2.61 KB
/
compat.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
// Plugin compatability file
// to help with older versions of WordPress and WordPress MU
// some concepts taken from compatibility.php from the OpenID plugin at http://code.google.com/p/diso/
// this will also be the base include for AJAX routines
// so we need to check if WordPress is loaded, if not, load it
// we'll use ABSPATH, since that's defined when WordPress loads
// should be included in the init function of normal plugins
if ( !function_exists( 'compat_get_wp_content_dir' ) ) {
function compat_get_wp_content_dir() {
if ( defined( 'WP_CONTENT_DIR' ) ) {
return WP_CONTENT_DIR;
} else {
return site_url() . '/wp-content';
}
}
}
if ( !function_exists( 'compat_get_wp_content_url' ) ) {
function compat_get_wp_content_url() {
if ( defined( 'WP_CONTENT_URL') ) {
return WP_CONTENT_URL;
} else {
return ABSPATH . 'wp-content';
}
}
}
if ( !function_exists( 'compat_is_wordpress_mu' ) ) {
function compat_is_wordpress_mu() {
return file_exists( compat_get_wp_content_dir() . '/mu-plugins' );
}
}
if ( !function_exists( 'compat_get_base_plugin_dir' ) ) {
function compat_get_base_plugin_dir() {
if ( compat_is_wordpress_mu() && strpos( dirname( __FILE__ ), 'mu-plugins') !== false ) {
return compat_get_wp_content_dir() . '/mu-plugins';
} else {
return compat_get_wp_content_dir() . '/plugins';
}
}
}
if ( !function_exists( 'compat_get_base_plugin_url' ) ) {
function compat_get_base_plugin_url() {
if ( compat_is_wordpress_mu() && strpos( dirname( __FILE__ ), 'mu-plugins') !== false ) {
return compat_get_wp_content_url() . '/mu-plugins';
} else {
return compat_get_wp_content_url() . '/plugins';
}
}
}
if ( !function_exists( 'compat_get_plugin_dir') ) {
function compat_get_plugin_dir( $plugin_name ) {
return compat_get_base_plugin_dir() . '/' . $plugin_name;
}
}
if ( !function_exists( 'compat_get_plugin_url' ) ) {
function compat_get_plugin_url( $plugin_name ) {
return compat_get_base_plugin_url() . '/' . $plugin_name;
}
}
if ( !function_exists( 'compat_get_upload_dir' ) ) {
function compat_get_upload_dir() {
if ( compat_is_wordpress_mu() ) {
global $blog_id;
return compat_get_wp_content_dir() . '/blogs.dir/' . $blog_id . '/uploads';
} else {
$upload_info = wp_upload_dir();
return $upload_info['basedir'];
}
}
}
if ( !function_exists( 'compat_get_upload_url' ) ) {
function compat_get_upload_url() {
if ( compat_is_wordpress_mu() ) {
global $blog_id;
return compat_get_wp_content_url() . '/blogs.dir/' . $blog_id . '/uploads';
} else {
$upload_info = wp_upload_dir();
return $upload_info['baseurl'];
}
}
}