Skip to content
This repository was archived by the owner on Mar 17, 2022. It is now read-only.

Commit 9e6dd41

Browse files
committed
Identify woocommerce and polylang if installed as mu-plugins
1 parent c7eb1f7 commit 9e6dd41

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

src/Hyyan/WPI/Plugin.php

+24-6
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,21 @@ public static function canActivate()
108108
$polylang = false;
109109
$woocommerce = false;
110110

111+
$polylang_file = 'polylang/polylang.php';
112+
$polylang_pro_file = 'polylang-pro/polylang.php';
113+
$woocommerce_file = 'woocommerce/woocommerce.php';
114+
111115
/* check polylang plugin */
112116
if (
113117
(
114-
is_plugin_active('polylang/polylang.php') ||
115-
is_plugin_active('polylang-pro/polylang.php')
118+
is_plugin_active($polylang_file) ||
119+
self::isMuPlugin($polylang_file) ||
120+
is_plugin_active($polylang_pro_file) ||
121+
self::isMuPlugin($polylang_pro_file)
116122
) ||
117123
(
118-
is_plugin_active_for_network('polylang/polylang.php') ||
119-
is_plugin_active_for_network('polylang-pro/polylang.php')
124+
is_plugin_active_for_network($polylang_file) ||
125+
is_plugin_active_for_network($polylang_pro_file)
120126
)
121127
) {
122128
if (isset($GLOBALS['polylang'], \PLL()->model, PLL()->links_model)) {
@@ -128,8 +134,9 @@ public static function canActivate()
128134

129135
/* check woocommerce plugin */
130136
if (
131-
is_plugin_active('woocommerce/woocommerce.php') ||
132-
is_plugin_active_for_network('woocommerce/woocommerce.php')
137+
is_plugin_active($woocommerce_file) ||
138+
self::isMuPlugin($woocommerce_file) ||
139+
is_plugin_active_for_network($woocommerce_file)
133140
) {
134141
$woocommerce = true;
135142
}
@@ -139,6 +146,17 @@ public static function canActivate()
139146
($woocommerce && Utilities::woocommerceVersionCheck(self::WOOCOMMERCE_VERSION));
140147
}
141148

149+
/**
150+
* Check if Mu-plugin
151+
*
152+
* @param string $plugin
153+
* @return boolean
154+
*/
155+
public static function isMuPlugin($plugin)
156+
{
157+
return file_exists( trailingslashit( WPMU_PLUGIN_DIR ) . $plugin ) ;
158+
}
159+
142160
/**
143161
* On Upgrade
144162
*

0 commit comments

Comments
 (0)