Completed
Push — master ( 29ee89...16fdff )
by Roy
02:20
created

WC_Dependencies::init()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * WC Dependency Checker
4
 *
5
 * Checks if WooCommerce is enabled
6
 */
7
class WC_Dependencies {
8
9
	private static $active_plugins;
10
11
	public static function init() {
12
13
		self::$active_plugins = (array) get_option( 'active_plugins', array() );
14
15
		if ( is_multisite() )
16
			self::$active_plugins = array_merge( self::$active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
17
	}
18
19
	public static function woocommerce_active_check() {
20
21
		if ( ! self::$active_plugins ) self::init();
0 ignored issues
show
Bug Best Practice introduced by
The expression self::$active_plugins of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
22
23
		return in_array( 'woocommerce/woocommerce.php', self::$active_plugins ) || array_key_exists( 'woocommerce/woocommerce.php', self::$active_plugins );
24
	}
25
26
}
27
28
29