PluginProbe
Stream – Activity Log & Audit Trail / 3.4.2
Stream – Activity Log & Audit Trail v3.4.2
4.4.0 4.3.0 4.2.2 4.2.1 trunk 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1 3.1.1 3.10.0 3.2.0 3.2.1 3.2.2 3.2.3 All 50 releases
← All changes | classes/class-plugin.php +56 -11 3.2.13.4.2 View file →
@@ -2,13 +2,15 @@
2 2 namespace WP_Stream;
3 3
4 4 class Plugin {
5 5 /**
6 - * Plugin version number
6 + * Plugin version number.
7 7 *
8 + * TODO Maybe pass this as a constructor dependency?
9 + *
8 10 * @const string
9 11 */
10 - const VERSION = '3.2.1';
12 + const VERSION = '3.4.2';
11 13
12 14 /**
13 15 * WP-CLI command
14 16 *
@@ -138,9 +140,9 @@
138 140 * Autoloader for classes
139 141 *
140 142 * @param string $class
141 143 */
142 - function autoload( $class ) {
144 + public function autoload( $class ) {
143 145 if ( ! preg_match( '/^(?P<namespace>.+)\\\\(?P<autoload>[^\\\\]+)$/', $class, $matches ) ) {
144 146 return;
145 147 }
146 148
@@ -177,12 +179,12 @@
177 179 *
178 180 * @action init
179 181 */
180 182 public function init() {
181 - $this->settings = new Settings( $this );
182 - $this->connectors = new Connectors( $this );
183 - $this->alerts = new Alerts( $this );
184 - $this->alerts_list = new Alerts_List( $this );
183 + $this->settings = new Settings( $this );
184 + $this->connectors = new Connectors( $this );
185 + $this->alerts = new Alerts( $this );
186 + $this->alerts_list = new Alerts_List( $this );
185 187
186 188 }
187 189
188 190 /**
@@ -217,12 +219,12 @@
217 219 *
218 220 * @return array
219 221 */
220 222 private function locate_plugin() {
221 - $dir_url = trailingslashit( plugins_url( '', dirname( __FILE__ ) ) );
222 - $dir_path = plugin_dir_path( dirname( __FILE__ ) );
223 - $dir_basename = basename( $dir_path );
224 - $plugin_basename = trailingslashit( $dir_basename ) . $dir_basename . '.php';
223 + $dir_url = trailingslashit( plugins_url( '', dirname( __FILE__ ) ) );
224 + $dir_path = plugin_dir_path( dirname( __FILE__ ) );
225 + $dir_basename = basename( $dir_path );
226 + $plugin_basename = trailingslashit( $dir_basename ) . $dir_basename . '.php';
225 227
226 228 return compact( 'dir_url', 'dir_path', 'dir_basename', 'plugin_basename' );
227 229 }
228 230
@@ -245,6 +247,49 @@
245 247 if ( class_exists( $driver_class ) ) {
246 248 $driver = new $driver_class();
247 249 $this->db = new DB( $driver );
248 250 }
251 + }
252 +
253 + /**
254 + * Returns true if Stream is network activated, otherwise false
255 + *
256 + * @return bool
257 + */
258 + public function is_network_activated() {
259 +
260 + $is_network_activated = false;
261 +
262 + if ( $this->is_mustuse() ) {
263 + $is_network_activated = true;
264 + } else {
265 + if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
266 + require_once ABSPATH . '/wp-admin/includes/plugin.php';
267 + }
268 + $is_network_activated = is_plugin_active_for_network( $this->locations['plugin'] );
269 + }
270 +
271 + /**
272 + * Filter allows the network activated detection to be overridden.
273 + *
274 + * @param string $is_network_activated Whether the plugin is network activated
275 + * @param WP_Stream\Plugin $plugin The stream plugin object
276 + */
277 + return apply_filters( 'wp_stream_is_network_activated', $is_network_activated, $this );
278 + }
279 +
280 + /**
281 + * Returns true if Stream is a must-use plugin, otherwise false
282 + *
283 + * @return bool
284 + */
285 + public function is_mustuse() {
286 +
287 + $stream_php = trailingslashit( WPMU_PLUGIN_DIR ) . $this->locations['plugin'];
288 +
289 + if ( file_exists( $stream_php ) && class_exists( 'WP_Stream\Plugin' ) ) {
290 + return true;
291 + }
292 +
293 + return false;
249 294 }
250 295 }