This repository has been archived by the owner on Nov 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcommentpress.php
176 lines (112 loc) · 4.35 KB
/
commentpress.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php /*
----------------------------------------------------------------
Plugin Name: Commentpress
Plugin URI: http://www.futureofthebook.org/commentpress/
Description: Commentpress allows readers to comment paragraph by paragraph in the margins of a text. You can use it to annotate, gloss, workshop, debate and more! <strong>For Wordpress Multisite:</strong> do not network activate this plugin. For more information see the plugin docs.
Author: Institute for the Future of the Book
Version: 3.3.6
Author URI: http://www.futureofthebook.org
----------------------------------------------------------------
Special thanks to:
Eddie Tejeda @ www.visudo.com for Commentpress 2.0
The developers of jQuery www.jquery.com
Mark James, for the icon http://www.famfamfam.com/lab/icons/silk/
----------------------------------------------------------------
*/
// ----------------------------------------------------------------
// No need to edit below this line
// ----------------------------------------------------------------
// set version
define( 'CP_VERSION', '3.3.6' );
// store reference to this file
if ( !defined( 'CP_PLUGIN_FILE' ) ) {
define( 'CP_PLUGIN_FILE', __FILE__ );
}
/*
----------------------------------------------------------------
Begin by establishing Plugin Context
----------------------------------------------------------------
NOTE: force-activated and network-activated contexts are now deprecated
----------------------------------------------------------------
*/
// test for multisite location
if ( basename( dirname(__FILE__) ) == 'mu-plugins' ) {
// directory-based forced activation
if ( !defined( 'CP_PLUGIN_CONTEXT' ) ) {
define( 'CP_PLUGIN_CONTEXT', 'mu_forced' );
}
// test for multisite
} elseif ( is_multisite() ) {
// check if our plugin is one of those activated sitewide
// NOTE: there IS be a better way to do this! See Commentpress for Multisite...
// make a temp array by splitting path on a known directory name
$tmp_array = explode( trailingslashit( WP_PLUGIN_DIR ), CP_PLUGIN_FILE );
// get our plugin path relative to WP_PLUGIN_DIR
$this_plugin = $tmp_array[1];
// init flag
$flag = false;
// get sitewide plugins
$active = (array)get_site_option( 'active_sitewide_plugins' );
$active = array_keys( $active );
// loop through them
foreach( $active AS $plugin_file ) {
// is ours there?
if ( $plugin_file == $this_plugin ) { $flag = true; }
}
// is the plugin network activated?
if ( $flag ) {
// yes, network activated
if ( !defined( 'CP_PLUGIN_CONTEXT' ) ) {
define( 'CP_PLUGIN_CONTEXT', 'mu_sitewide' );
}
} else {
// optional activation per blog in multisite
if ( !defined( 'CP_PLUGIN_CONTEXT' ) ) {
define( 'CP_PLUGIN_CONTEXT', 'mu_optional' );
}
}
} else {
// single user install
if ( !defined( 'CP_PLUGIN_CONTEXT' ) ) {
define( 'CP_PLUGIN_CONTEXT', 'standard' );
}
}
//print_r( CP_PLUGIN_CONTEXT ); //die();
/*
----------------------------------------------------------------
Init plugin
----------------------------------------------------------------
*/
// do we have our class?
if ( !class_exists( 'CommentPress' ) ) {
// Sanity check
// define filename
$cp_class_file = 'class_commentpress.php';
// define path to our class file
$cp_class_file_path = plugin_dir_path( CP_PLUGIN_FILE ) . $cp_class_file;
// is our class definition present?
if ( !is_file( $cp_class_file_path ) ) {
// oh no!
die( 'Class file "'.$cp_class_file.'" is missing from the plugin directory.' );
}
// Include and init
// we're fine, include class definition
require_once( $cp_class_file_path );
// instantiate it
$commentpress_obj = new CommentPress;
/*
----------------------------------------------------------------
Critical Plugin Hooks
----------------------------------------------------------------
moved these three hooks to the main plugin file for sanity's sake and so we can
begin to rationalise the activate, deactivate and uninstall processes
----------------------------------------------------------------
*/
// activation
register_activation_hook( CP_PLUGIN_FILE, array( &$commentpress_obj, 'activate' ) );
// deactivation
register_deactivation_hook( CP_PLUGIN_FILE, array( &$commentpress_obj, 'deactivate' ) );
// uninstall uses the 'uninstall.php' method
// see: http://codex.wordpress.org/Function_Reference/register_uninstall_hook
}
?>