136
|
1 |
<?php |
|
2 |
// Plugin compatability file |
|
3 |
// to help with older versions of WordPress and WordPress MU |
|
4 |
// some concepts taken from compatibility.php from the OpenID plugin at http://code.google.com/p/diso/ |
|
5 |
|
|
6 |
// this will also be the base include for AJAX routines |
|
7 |
// so we need to check if WordPress is loaded, if not, load it |
|
8 |
// we'll use ABSPATH, since that's defined when WordPress loads |
|
9 |
// should be included in the init function of normal plugins |
|
10 |
|
|
11 |
if ( !function_exists( 'compat_get_wp_content_dir' ) ) { |
|
12 |
function compat_get_wp_content_dir() { |
|
13 |
if ( defined( 'WP_CONTENT_DIR' ) ) { |
|
14 |
return WP_CONTENT_DIR; |
|
15 |
} else { |
|
16 |
return get_option( 'siteurl' ) . '/wp-content'; |
|
17 |
} |
|
18 |
} |
|
19 |
} |
|
20 |
|
|
21 |
if ( !function_exists( 'compat_get_wp_content_url' ) ) { |
|
22 |
function compat_get_wp_content_url() { |
|
23 |
if ( defined( 'WP_CONTENT_URL') ) { |
|
24 |
return WP_CONTENT_URL; |
|
25 |
} else { |
|
26 |
return ABSPATH . 'wp-content'; |
|
27 |
} |
|
28 |
} |
|
29 |
} |
|
30 |
|
|
31 |
if ( !function_exists( 'compat_is_wordpress_mu' ) ) { |
|
32 |
function compat_is_wordpress_mu() { |
|
33 |
return file_exists( compat_get_wp_content_dir() . '/mu-plugins' ); |
|
34 |
} |
|
35 |
} |
|
36 |
|
|
37 |
|
|
38 |
if ( !function_exists( 'compat_get_base_plugin_dir' ) ) { |
|
39 |
function compat_get_base_plugin_dir() { |
|
40 |
if ( compat_is_wordpress_mu() && strpos( dirname( __FILE__ ), 'mu-plugins') !== false ) { |
|
41 |
return compat_get_wp_content_dir() . '/mu-plugins'; |
|
42 |
} else { |
|
43 |
return compat_get_wp_content_dir() . '/plugins'; |
|
44 |
} |
|
45 |
} |
|
46 |
} |
|
47 |
|
|
48 |
if ( !function_exists( 'compat_get_base_plugin_url' ) ) { |
|
49 |
function compat_get_base_plugin_url() { |
|
50 |
if ( compat_is_wordpress_mu() && strpos( dirname( __FILE__ ), 'mu-plugins') !== false ) { |
|
51 |
return compat_get_wp_content_url() . '/mu-plugins'; |
|
52 |
} else { |
|
53 |
return compat_get_wp_content_url() . '/plugins'; |
|
54 |
} |
|
55 |
} |
|
56 |
} |
|
57 |
|
|
58 |
if ( !function_exists( 'compat_get_plugin_dir') ) { |
|
59 |
function compat_get_plugin_dir( $plugin_name ) { |
|
60 |
return compat_get_base_plugin_dir() . '/' . $plugin_name; |
|
61 |
} |
|
62 |
} |
|
63 |
|
|
64 |
if ( !function_exists( 'compat_get_plugin_url' ) ) { |
|
65 |
function compat_get_plugin_url( $plugin_name ) { |
|
66 |
return compat_get_base_plugin_url() . '/' . $plugin_name; |
|
67 |
} |
|
68 |
} |
|
69 |
|
|
70 |
if ( !function_exists( 'compat_get_upload_dir' ) ) { |
|
71 |
function compat_get_upload_dir() { |
|
72 |
if ( compat_is_wordpress_mu() ) { |
|
73 |
global $blog_id; |
|
74 |
return compat_get_wp_content_dir() . '/blogs.dir/' . $blog_id . '/uploads'; |
|
75 |
} else { |
|
76 |
$upload_info = wp_upload_dir(); |
|
77 |
return $upload_info['basedir']; |
|
78 |
} |
|
79 |
} |
|
80 |
} |
|
81 |
|
|
82 |
if ( !function_exists( 'compat_get_upload_url' ) ) { |
|
83 |
function compat_get_upload_url() { |
|
84 |
if ( compat_is_wordpress_mu() ) { |
|
85 |
global $blog_id; |
|
86 |
return compat_get_wp_content_url() . '/blogs.dir/' . $blog_id . '/uploads'; |
|
87 |
} else { |
|
88 |
$upload_info = wp_upload_dir(); |
|
89 |
return $upload_info['baseurl']; |
|
90 |
} |
|
91 |
} |
|
92 |
} |
|
93 |
?> |